Continuous deployment for Azure Functions
You can use Azure Functions to deploy your code continuously by using source control integration. Source control integration enables a workflow in which a code update triggers deployment to Azure. If you're new to Azure Functions, get started by reviewing the Azure Functions overview.
Continuous deployment is a good option for projects where you integrate multiple and frequent contributions. When you use continuous deployment, you maintain a single source of truth for your code, which allows teams to easily collaborate. You can configure continuous deployment in Azure Functions from the following source code locations:
The unit of deployment for functions in Azure is the function app. All functions in a function app are deployed at the same time. After you enable continuous deployment, access to function code in the Azure portal is configured as read-only because the source of truth is set to be elsewhere.
Requirements for continuous deployment
For continuous deployment to succeed, your directory structure must be compatible with the basic folder structure that Azure Functions expects.
The code for all the functions in a specific function app is located in a root project folder that contains a host configuration file and one or more subfolders. Each subfolder contains the code for a separate function. The folder structure is shown in the following representation:
FunctionApp | - host.json | - MyFirstFunction | | - function.json | | - ... | - MySecondFunction | | - function.json | | - ... | - SharedCode | - bin
In version 2.x and higher of the Functions runtime, all functions in the function app must share the same language stack.
The host.json file contains runtime-specific configurations and is in the root folder of the function app. A bin folder contains packages and other library files that the function app requires. See the language-specific requirements for a function app project:
Continuous deployment is not yet supported for Linux apps running on a Consumption plan.
Set up continuous deployment
To configure continuous deployment for an existing function app, complete these steps. The steps demonstrate integration with a GitHub repository, but similar steps apply for Azure Repos or other source code repositories.
In your function app in the Azure portal, select Platform features > Deployment Center.
In Deployment Center, select GitHub, and then select Authorize. If you've already authorized GitHub, select Continue.
In GitHub, select the Authorize AzureAppService button.
In Deployment Center in the Azure portal, select Continue.
Select one of the following build providers:
- App Service build service: Best when you don't need a build or if you need a generic build.
- Azure Pipelines (Preview): Best when you need more control over the build. This provider currently is in preview.
Configure information specific to the source control option you specified. For GitHub, you must enter or select values for Organization, Repository, and Branch. The values are based on the location of your code. Then, select Continue.
Review all details, and then select Finish to complete your deployment configuration.
When the process is finished, all code from the specified source is deployed to your app. At that point, changes in the deployment source trigger a deployment of those changes to your function app in Azure.
Move existing functions to continuous deployment
If you've already written functions in the Azure portal and you want to download the contents of your app before you switch to continuous deployment, go to the Overview tab of your function app. Select the Download app content button.
After you configure continuous integration, you can no longer edit your source files in the Functions portal.