Ciągłe wdrażanie dla usługi Azure FunctionsContinuous deployment for Azure Functions

You can use Azure Functions to deploy your code continuously by using source control integration.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.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.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.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.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: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.The unit of deployment for functions in Azure is the function app. All functions in a function app are deployed at the same time.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.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 deploymentRequirements for continuous deployment

For continuous deployment to succeed, your directory structure must be compatible with the basic folder structure that Azure Functions expects.For continuous deployment to succeed, your directory structure must be compatible with the basic folder structure that Azure Functions expects.

Kod dla wszystkich funkcji w aplikacji określonych funkcji znajduje się w katalogu głównego folderu projektu, który zawiera plik konfiguracji hosta i jego podfolderach co najmniej jeden.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. Każdy podfolder zawiera kod to oddzielna funkcja.Each subfolder contains the code for a separate function. Struktury folderów przedstawiono w następujących reprezentacji:The folder structure is shown in the following representation:

FunctionApp
 | - host.json
 | - Myfirstfunction
 | | - function.json
 | | - ...  
 | - mysecondfunction
 | | - function.json
 | | - ...  
 | - SharedCode
 | - bin

W wersji 2.x środowisko uruchomieniowe usługi Functions, wszystkie funkcje w aplikacji funkcji muszą współużytkować ten sam stos języka.In version 2.x of the Functions runtime, all functions in the function app must share the same language stack.

Host.json plik zawiera konfiguracje specyficzne dla środowiska uruchomieniowego i znajduje się w folderze głównym aplikacji funkcji.The host.json file contains runtime-specific configurations and is in the root folder of the function app. A bin folder zawiera pakiety i inne pliki biblioteki, których wymaga aplikacja funkcji.A bin folder contains packages and other library files that the function app requires. Wymagania językowe dla projektu aplikacji funkcji:See the language-specific requirements for a function app project:

Uwaga

Continuous deployment is not yet supported for Linux apps running on a Consumption plan.Continuous deployment is not yet supported for Linux apps running on a Consumption plan.

Set up continuous deploymentSet up continuous deployment

To configure continuous deployment for an existing function app, complete these steps.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.The steps demonstrate integration with a GitHub repository, but similar steps apply for Azure Repos or other source code repositories.

  1. In your function app in the Azure portal, select Platform features > Deployment Center.In your function app in the Azure portal, select Platform features > Deployment Center.

    Open Deployment Center

  2. In Deployment Center, select GitHub, and then select Authorize.In Deployment Center, select GitHub, and then select Authorize. If you've already authorized GitHub, select Continue.If you've already authorized GitHub, select Continue.

    Azure App Service Deployment Center

  3. In GitHub, select the Authorize AzureAppService button.In GitHub, select the Authorize AzureAppService button.

    Authorize Azure App Service

    In Deployment Center in the Azure portal, select Continue.In Deployment Center in the Azure portal, select Continue.

  4. Select one of the following build providers: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.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.Azure Pipelines (Preview): Best when you need more control over the build. This provider currently is in preview.This provider currently is in preview.

    Select a build provider

  5. Configure information specific to the source control option you specified.Configure information specific to the source control option you specified. For GitHub, you must enter or select values for Organization, Repository, and Branch.For GitHub, you must enter or select values for Organization, Repository, and Branch. The values are based on the location of your code.The values are based on the location of your code. Then, select Continue.Then, select Continue.

    Configure GitHub

  6. Review all details, and then select Finish to complete your deployment configuration.Review all details, and then select Finish to complete your deployment configuration.

    Podsumowanie

When the process is finished, all code from the specified source is deployed to your app.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.At that point, changes in the deployment source trigger a deployment of those changes to your function app in Azure.

Scenariusze wdrażaniaDeployment scenarios

Move existing functions to continuous deploymentMove 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.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.Select the Download app content button.

Download app content

Uwaga

After you configure continuous integration, you can no longer edit your source files in the Functions portal.After you configure continuous integration, you can no longer edit your source files in the Functions portal.

Następne krokiNext steps