For the complete documentation index, see llms.txt. This page is also available as Markdown.

Azure Functions deployments

Set up and run an Azure Functions deployment in Harness.

Harness supports the deployment of Azure Functions, enabling you to automate and manage serverless function deployments to Azure.

This topic walks you through setting up and running an Azure Functions deployment in Harness.

What you will learn from this topic

Before you begin

Before you set up an Azure Functions deployment, ensure you have the following:

  • An Azure Cloud Provider connector connected to your Azure subscription and tenant. For setup steps, go to Add a Microsoft Azure Cloud connector.

  • The Subscription Id and Resource Group of your target Azure Function, available from the Azure Function's Overview section in the Azure portal.

  • A Harness Delegate installed to perform the deployment.

The basic steps are:

  1. Specify the Azure Function artifact and configuration required for the function.

  2. Connect Harness with your Azure subscription.

  3. Define the target function in Harness and install a Harness Delegate to perform the deployment.

  4. Define the steps for the different deployment strategies:

    • Basic: In a Basic deployment, all nodes (pods, instances, and so on) within a single environment are replaced at the same time with new nodes containing the new service or artifact version.

Step by step guide

Azure Function pipeline stages

Azure deployments are performed using a Deploy stage with the deployment type Azure Function.

For more information on stages, go to Add a stage and CD pipeline modeling overview.

Azure Function services

In Harness, the service represents your Azure Function.

You define the service for your deployment in the service settings of the pipeline stage. You can either define the service separately in your project's service section and select it in the stage, or create the service directly within the stage's service tab.

It is an artifact-based service, where a manifest is not required, and setting up Variables is optional.

Containerized function apps

The artifact must contain the Azure function app. For more information on how to create containerized function apps, go to Azure documentation.

You can also deploy Azure Function Apps packaged as ZIP bundles. For more information, go to Azure documentation.

Important: When creating the Function App in Azure, make sure you select the Container Apps Environment hosting plan. This is essential for deploying containerized Function Apps.

To add an artifact source, click Add Artifact Source.

Harness supports Docker Registry, ACR, Nexus3, and Artifactory for artifact repositories. Choose where your artifact is stored, and then click Continue.

Under Artifact Repository, configure your connector to connect to your artifact repository.

Under Artifact Location, specify the necessary details such as Artifact Source Identifier, Image Path, and Tag, and then click Submit.

You can also create and use a template for artifacts.

Private Docker registry configuration

When you set Artifact type = Other for a private Docker registry, you need to populate the PLUGIN_DOCKER_USERNAME and the full registry URL in the slot's Full Image Name and Tag. To do so, add:

  • PLUGIN_DOCKER_USERNAME: <+secrets.getValue("account.<SECRET_ID>")>

  • PLUGIN_DOCKER_CONTAINER_NAME: https://<your-registry-url>/<repository>/<image>:<tag>

in the Azure Deployment step so that your function can authenticate and pull the correct image.

Azure Function environments

Define the environment you want to use to deploy the Azure function.

You define the target infrastructure for your deployment in the Environment settings of the pipeline stage. You can either define the environment separately in your project's Environments section and select it in the stage, or create the environment directly within the stage's Environment tab.

Azure Functions target infrastructure

For deploying Azure Functions, you need to specify the pre-existing target infrastructure.

For details on Harness provisioning, go to Provisioning overview.

Pre-existing infrastructure

The target Azure environment for your Harness Azure Function deployment is defined in a Harness Environment's Infrastructure. You provide the Azure Function name later in your stage's Execution.

Select or create an Azure Cloud Provider connector and then select the Azure Function's Subscription Id and Resource Group.

In your stage Environment, in Specify Infrastructure, select an infrastructure or select New Infrastructure and define the infrastructure settings:

  • Connector: Select or create an Azure Cloud Provider connector that connects to your Azure application and tenant Ids.

    For steps on setting up a new Azure Cloud Provider connector, go to Add a Microsoft Azure Cloud connector.

  • Subscription Id: Select the Azure subscription used by your Azure Function.

    The subscription is located in the Azure Function Overview section of the Azure portal.

  • Resource Group: Select the resource group used by your Azure Function.

    The resource group is located in the Azure Function Overview section of the Azure portal.

Within the same resource group, you cannot mix Windows and Linux apps in the same region. For more information, go to Limitations from Azure.

Azure Function deploy

In the execution tab of the pipeline stage, select Add Step and select Azure Function Deploy.

Azure function deployment supports the basic and custom deployment strategy.

Container execution requirements

The Azure Function Deploy step requires a containerized execution environment:

  • If you select the Basic deployment strategy, Harness automatically adds a container Step Group with the Azure Function Deploy step inside it.

  • If you select the Custom deployment strategy, you need to manually:

    1. Add a Step Group to your pipeline

    2. Enable the Container option in the Step Group

    3. Configure the Step Group to use your Kubernetes connector

    4. Add the Azure function Deploy step inside this Step Group

Failure to run the step in a containerized execution context will likely result in deployment failures.

The Azure function Deploy step has the following settings:

  • Name: Enter a name for the step.

  • Timeout: Enter a minimum of 10m. The slot deployment relies on Azure and can take time.

  • Container Registry: Specify the connector that connects to the Azure infrastructure and container registry you want to use.

  • Image: Specify the artifact image you want to run. For example, use harness/azure-function-plugin:1.0.24-linux-amd64. You can refer to the latest available images from the linked registry.

Container image by registry

In the deploy steps under Container Configuration, specify the appropriate image based on your container registry:

  1. GAR Images for Azure Function Plugin:

  • Function app: Specify the Azure Container to be used.

  • Deployment Slot: Enter the name of the Source slot for the deployment. This slot is where Harness deploys the new Azure Function version. Make sure the slot you enter is running.

You can also configure the following optional settings:

  • Pre-Execution Command: A command that runs before the main execution starts.

  • Image Pull Policy: Specifies when the container image should be pulled from the registry.

  • Run as User: Configures the user identity under which the function or container should run, useful for security and access control.

  • Limit Memory: Defines the maximum memory that can be allocated to the container or function during execution.

  • Limit CPU: Sets a limit on the CPU usage for the function or container, ensuring the function does not consume excessive resources.

  • Deploy Command Options: Options that can be passed to customize the deployment process.

  • Environment Variables: Additional environment variables that you need to specify.

Azure Function rollback

Harness tries to recover the state before deployment.

For a Docker image deployment rollback, Harness fetches the Web App details (artifact, app settings, connection strings, startup script) of the existing slot and uses this data to bring the slot to its previous state.

For non-containerized artifact rollback, Harness rolls back to the last successful deployment done with Harness. Harness saves deployment details after a successful deployment and uses this data for rollback in the next deployment.

The Azure Function Rollback step has the following settings:

  • Name: Enter a name for the step.

  • Timeout: Enter a minimum of 10m. The slot deployment relies on Azure and can take time.

  • Azure Connector: Specify the connector that connects to the Azure infrastructure.

  • Image: Specify the artifact image you want to deploy. For example, use harness/azure-function-plugin:1.0.24-linux-amd64. You can refer to the latest available images from the linked registry.

You can also configure the following optional settings:

  • Image Pull Policy: Specifies when the container image should be pulled from the registry.

  • Run as User: Configures the user identity under which the function or container should run, useful for security and access control.

  • Limit Memory: Defines the maximum memory that can be allocated to the container or function during execution.

  • Limit CPU: Sets a limit on the CPU usage for the function or container, ensuring the function does not consume excessive resources.

Azure Function deployment sample

For an example of how to deploy Azure Functions using Harness, go to the Harness Community Repository.

This repository provides a ready-to-use sample application and the necessary configuration files to help you get started.

Next steps

Last updated

Was this helpful?