Rediger

Del via


Deployment technologies in Azure Functions

You can use a few different technologies to deploy your Azure Functions project code to Azure. This article provides an overview of the deployment methods available to you and recommendations for the best method to use in various scenarios. It also provides an exhaustive list of and key details about the underlying deployment technologies.

Deployment methods

The deployment technology you use to publish code to your function app in Azure depends on your specific needs and the point in the development cycle. For example, during development and testing you may deploy directly from your development tool, such as Visual Studio Code. When your app is in production, you're more likely to publish continuously from source control or by using an automated publishing pipeline, which can include validation and testing.

The following table describes the available deployment methods for your code project.

Deployment type Methods Best for...
Tools-based • Visual Studio Code publish
• Visual Studio publish
• Core Tools publish
Deployments during development and other improvised deployments. Deploying your code on-demand using local development tools.
App Service-managed • Deployment Center (CI/CD)
• Container deployments
Continuous deployment (CI/CD) from source control or from a container registry. Deployments are managed by the App Service platform (Kudu).
External pipelines • Azure Pipelines
• GitHub Actions
Production pipelines that include validation, testing, and other actions that must be run as part of an automated deployment. Deployments are managed by the pipeline.

Specific deployments should use the best technology based on the specific scenario. Many of the deployment methods are based on zip deployment, which is recommended for deployment.

Deployment technology availability

The deployment method also depends on the hosting plan and operating system on which you run your function app.

Currently, Functions offers five options for hosting your function apps:

Each plan has different behaviors. Not all deployment technologies are available for each hosting plan and operating system. This chart provides information on the supported deployment technologies:

Deployment technology Flex Consumption Consumption Elastic Premium Dedicated Container Apps
OneDeploy
Zip deploy
External package URL1
Docker container Linux-only Linux-only Linux-only
Source control Windows-only
Local Git1 Windows-only
FTPS1 Windows-only
In-portal editing2

1 Deployment technologies that require you to manually sync triggers aren't recommended.
2 In-portal editing is disabled when code is deployed to your function app from outside the portal. For more information, including language support details for in-portal editing, see Language support details.

Key concepts

Some key concepts are critical to understanding how deployments work in Azure Functions.

Trigger syncing

When you change any of your triggers, the Functions infrastructure must be aware of the changes. Synchronization happens automatically for many deployment technologies. However, in some cases, you must manually sync your triggers.

You must manually sync triggers when using these deployment options:

You can sync triggers in one of these ways:

  • Restart your function app in the Azure portal.

  • Use the az rest command to send an HTTP POST request that calls the syncfunctiontriggers API, as in this example:

    az rest --method post --url https://management.azure.com/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP>/providers/Microsoft.Web/sites/<APP_NAME>/syncfunctiontriggers?api-version=2016-08-01
    

When you deploy an updated version of the deployment package and maintain the same external package URL, you need to manually restart your function app. This indicates to the host that it should synchronize and redeploy your updates from the same package URL. The Functions host also performs a background trigger sync after the application has started. However, for the Consumption and Elastic Premium hosting plans you should also manually sync triggers in these scenarios:

  • Deployments using an external package URL with either ARM Templates or Terraform.
  • When updating the deployment package at the same external package URL.

Remote build

You can request Azure Functions to perform a remote build of your code project during deployment. In these scenarios, you should request a remote build instead of building locally:

  • You're deploying an app to a Linux-based function app that was developed on a Windows computer. This is commonly the case for Python app development. You can end up with in incorrect libraries being used when building the deployment package locally on Windows.
  • Your project has dependencies on a custom package index.
  • You want to reduce the size of your deployment package.

How you request a remote build depends on whether your app runs in Azure on Windows or Linux.

All function apps running on Windows have a small management app, the scm site provided by Kudu. This site handles much of the deployment and build logic for Azure Functions.

When an app is deployed to Windows, language-specific commands, like dotnet restore (C#) or npm install (JavaScript) are run.

The following considerations apply when using remote builds during deployment:

  • Remote builds are supported for function apps running on Linux in the Consumption plan. However, deployment options are limited for these apps because they don't have an scm (Kudu) site.
  • Function apps running on Linux in a Premium plan or in a Dedicated (App Service) plan do have an scm (Kudu) site, but it's limited compared to Windows.
  • Remote builds aren't performed when an app is using run-from-package. To learn how to use remote build in these cases, see Zip deploy.
  • You may have issues with remote build when your app was created before the feature was made available (August 1, 2019). For older apps, either create a new function app or run az functionapp update --resource-group <RESOURCE_GROUP_NAME> --name <APP_NAME> to update your function app. This command might take two tries to succeed.

App content storage

Package-based deployment methods store the package in the storage account associated with the function app, which is defined in the AzureWebJobsStorage setting. When available, Consumption and Elastic Premium plan apps try to use the Azure Files content share from this account, but you can also maintain the package in another location. Flex Consumption plan apps instead use a storage container in default storage account, unless you configure a different storage account to use for deployment. For more information, review the details in Where app content is stored in each deployment technology covered in the next section.

Important

The storage account is used to store important app data, sometimes including the application code itself. You should limit access from other apps and users to the storage account.

Deployment technology details

The following deployment methods are available in Azure Functions.

One deploy

One deploy is the only deployment technology supported for apps on the Flex Consumption plan. The end result is a ready-to-run .zip package that your function app runs on.

How to use it: Deploy with the Visual Studio Code publish feature, or from the command line using Azure Functions Core Tools or the Azure CLI. Our Azure Dev Ops Task and GitHub Action similarly leverage one deploy when they detect that a Flex Consumption app is being deployed to.

When you create a Flex Consumption app, you will need to specify a deployment storage (blob) container as well as an authentication method to it. By default the same storage account as the AzureWebJobsStorage connection is used, with a connection string as the authentication method. Thus, your deployment settings are configured during app create time without any need of application settings.

When to use it: One deploy is the only deployment technology available for function apps running on the Flex Consumption plan.

Where app content is stored: When you create a Flex Consumption function app, you specify a deployment storage container. This is a blob container where the platform will upload the app content you deployed. To change the location, you can visit the Deployment Settings blade in the Azure portal or use the Azure CLI.

Zip deploy

Zip deploy is the default and recommended deployment technology for function apps on the Consumption, Elastic Premium, and App Service (Dedicated) plans. The end result a ready-to-run .zip package that your function app runs on. It differs from external package URL in that our platform is responsible for remote building and storing your app content.

How to use it: Deploy by using your favorite client tool: Visual Studio Code, Visual Studio, or from the command line using Azure Functions Core Tools or the Azure CLI. Our Azure Dev Ops Task and GitHub Action similarly leverage zip deploy.

When you deploy by using zip deploy, you can set your app to run from package. To run from package, set the WEBSITE_RUN_FROM_PACKAGE application setting value to 1. We recommend zip deployment. It yields faster loading times for your applications, and it's the default for VS Code, Visual Studio, and the Azure CLI.

When to use it: Zip deploy is the default and recommended deployment technology for function apps on the Windows Consumption, Windows and Linux Elastic Premium, and Windows and Linux App Service (Dedicated) plans.

Where app content is stored: App content from a zip deploy by default is stored on the file system, which may be backed by Azure Files from the storage account specified when the function app was created. In Linux Consumption, the app content is instead persisted on a blob in the storage account specified by the AzureWebJobsStorage app setting, and the app setting WEBSITE_RUN_FROM_PACKAGE will take on the value of the blob URL.

External package URL

External package URL is an option if you want to manually control how deployments are performed. You take responsibility for uploading a ready-to-run .zip package containing your built app content to blob storage and referencing this external URL as an application setting on your function app. Whenever your app restarts, it fetches the package, mounts it, and runs in Run From Package mode.

How to use it: Add WEBSITE_RUN_FROM_PACKAGE to your application settings. The value of this setting should be a blob URL pointing to the location of the specific package you want your app to run. You can add settings either in the portal or by using the Azure CLI.

If you use Azure Blob Storage, your Function app can access the container either by using a managed identity-based connection or with a shared access signature (SAS). The option you choose affects what kind of URL you use as the value for WEBSITE_RUN_FROM_PACKAGE. Managed identity is recommended for overall security and because SAS tokens expire and must be manually maintained.

Whenever you deploy the package file that a function app references, you must manually sync triggers, including the initial deployment. When you change the contents of the package file and not the URL itself, you must also restart your function app to sync triggers. Refer to our how-to guide on configuring this deployment technology.

When to use it: External package URL is the only supported deployment method for apps running on the Linux Consumption plan when you don't want a remote build to occur. This method is also the recommended deployment technology when you create your app without Azure Files. For scalable apps running on Linux, you should instead consider Flex Consumption plan hosting.

Where app content is stored: You are responsible for uploading your app content to blob storage. You may use any blob storage account, though Azure Blob Storage is recommended.

Docker container

You can deploy a function app running in a Linux container.

How to use it: Create your functions in a Linux container then deploy the container to a Premium or Dedicated plan in Azure Functions or another container host. Use the Azure Functions Core Tools to create a customized Dockerfile for your project that you use to build a containerized function app. You can use the container in the following deployments:

When to use it: Use the Docker container option when you need more control over the Linux environment where your function app runs and where the container is hosted. This deployment mechanism is available only for functions running on Linux.

Where app content is stored: App content is stored in the specified container registry as a part of the image.

Source control

You can enable continuous integration between your function app and a source code repository. With source control enabled, an update to code in the connected source repository triggers deployment of the latest code from the repository. For more information, see the Continuous deployment for Azure Functions.

How to use it: The easiest way to set up publishing from source control is from the Deployment Center in the Functions area of the portal. For more information, see Continuous deployment for Azure Functions.

When to use it: Using source control is the best practice for teams that collaborate on their function apps. Source control is a good deployment option that enables more sophisticated deployment pipelines. Source control is usually enabled on a staging slot, which can be swapped into production after validation of updates from the repository. For more information, see Azure Functions deployment slots.

Where app content is stored: The app content is in the source control system, but a locally cloned and built app content from is stored on the app file system, which may be backed by Azure Files from the storage account specified when the function app was created.

Local Git

You can use local Git to push code from your local machine to Azure Functions by using Git.

How to use it: Follow the instructions in Local Git deployment to Azure App Service.

When to use it: To reduce the chance of errors, you should avoid using deployment methods that require the additional step of manually syncing triggers. Use zip deployment when possible.

Where app content is stored: App content is stored on the file system, which may be backed by Azure Files from the storage account specified when the function app was created.

FTP/S

You can use FTP/S to directly transfer files to Azure Functions, although this deployment method isn't recommended. When you're not planning on using FTP, you should disable it. If you do choose to use FTP, you should enforce FTPS. To learn how in the Azure portal, see Enforce FTPS.

How to use it: Follow the instructions in FTPS deployment settings to get the URL and credentials you can use to deploy to your function app using FTPS.

When to use it: To reduce the chance of errors, you should avoid using deployment methods that require the additional step of manually syncing triggers. Use zip deployment when possible.

Where app content is stored: App content is stored on the file system, which may be backed by Azure Files from the storage account specified when the function app was created.

Portal editing

In the portal-based editor, you can directly edit the files that are in your function app (essentially deploying every time you save your changes).

How to use it: To be able to edit your functions in the Azure portal, you must have created your functions in the portal. To preserve a single source of truth, using any other deployment method makes your function read-only and prevents continued portal editing. To return to a state in which you can edit your files in the Azure portal, you can manually turn the edit mode back to Read/Write and remove any deployment-related application settings (like WEBSITE_RUN_FROM_PACKAGE).

When to use it: The portal is a good way to get started with Azure Functions. For more advanced development work, we recommend that you use one of the following client tools:

Where app content is stored: App content is stored on the file system, which may be backed by Azure Files from the storage account specified when the function app was created.

The following table shows the operating systems and languages that support in-portal editing:

Language Windows Consumption Windows Premium Windows Dedicated Linux Consumption Linux Premium Linux Dedicated
C#1
Java
JavaScript (Node.js)
Python2
PowerShell
TypeScript (Node.js)

1 In-portal editing is only supported for C# script files, which run in-process with the host. For more information, see the Azure Functions C# script (.csx) developer reference.
2 In-portal editing is only supported for the v1 Python programming model.

Deployment behaviors

When you deploy updates to your function app code, currently executing functions are terminated. After deployment completes, the new code is loaded to begin processing requests. Review Improve the performance and reliability of Azure Functions to learn how to write stateless and defensive functions.

If you need more control over this transition, you should use deployment slots.

Deployment slots

When you deploy your function app to Azure, you can deploy to a separate deployment slot instead of directly to production. Deploying to a deployment slot and then swapping into production after verification is the recommended way to configure continuous deployment.

The way that you deploy to a slot depends on the specific deployment tool you use. For example, when using Azure Functions Core Tools, you include the--slot option to indicate the name of a specific slot for the func azure functionapp publish command.

For more information on deployment slots, see the Azure Functions Deployment Slots documentation for details.

Next steps

Read these articles to learn more about deploying your function apps: