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 three hosting plans:
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 | Windows Consumption | Windows Premium | Windows Dedicated | Linux Consumption | Linux Premium | Linux Dedicated |
---|---|---|---|---|---|---|
External package URL1 | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
Zip deploy | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
Docker container | ✔ | ✔ | ||||
Source control | ✔ | ✔ | ✔ | ✔ | ✔ | |
Local Git1 | ✔ | ✔ | ✔ | ✔ | ✔ | |
FTPS1 | ✔ | ✔ | ✔ | ✔ | ✔ | |
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 three ways:
- Restart your function app in the Azure portal.
- Send an HTTP POST request to
https://{functionappname}.azurewebsites.net/admin/host/synctriggers?code=<API_KEY>
using the master key. - Send an HTTP POST request to
https://management.azure.com/subscriptions/<SUBSCRIPTION_ID>/resourceGroups/<RESOURCE_GROUP_NAME>/providers/Microsoft.Web/sites/<FUNCTION_APP_NAME>/syncfunctiontriggers?api-version=2016-08-01
. Replace the placeholders with your subscription ID, resource group name, and the name of your function app. This request requires an access token in theAuthorization
request header.
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
Azure Functions can automatically perform builds on the code it receives after zip deployments. These builds differ depending on whether your app is running 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 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
Several deployment methods store the deployed or built application payload on the storage account associated with the function app. Functions tries to use the Azure Files content share when configured, but some methods instead store the payload in the blob storage instance associated with the AzureWebJobsStorage
connection. See the details in the Where app content is stored paragraphs of 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.
External package URL
You can use an external package URL to reference a remote package (.zip) file that contains your function app. The file is downloaded from the provided URL, and the app 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 URL (the location of the specific package file you want to run). You can add settings either in the portal or by using the Azure CLI.If you use Azure Blob storage, use a private container with a shared access signature (SAS) to give Functions access to the package. Any time the application restarts, it fetches a copy of the content. Your reference must be valid for the lifetime of the application.
When to use it: External package URL is the only supported deployment method for Azure Functions running on Linux in the Consumption plan, if the user doesn't want a remote build to occur. 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.
Where app content is stored: App content is stored at the URL specified. This could be on Azure Blobs, possibly in the storage account specified by the
AzureWebJobsStorage
connection. Some client tools may default to deploying to a blob in this account. For example, for Linux Consumption apps, the Azure CLI will attempt to deploy through a package stored in a blob on the account specified byAzureWebJobsStorage
.
Zip deploy
Use zip deploy to push a .zip file that contains your function app to Azure. Optionally, you can set your app to start running from package, or specify that a remote build occurs.
How to use it: Deploy by using your favorite client tool: Visual Studio Code, Visual Studio, or from the command line using the Azure Functions Core Tools. By default, these tools use zip deployment and run from package. Core Tools and the Visual Studio Code extension both enable remote build when deploying to Linux. To manually deploy a .zip file to your function app, follow the instructions in Deploy from a .zip file or URL.
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 to1
. 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 recommended deployment technology for Azure Functions.
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 instead is persisted on a blob in the storage account specified by the
AzureWebJobsStorage
connection.
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:
- Deploy to Azure Functions resources you create in the Azure portal. For more information, see Azure portal create using containers.
- Deploy to Azure Functions resources you create from the command line. Requires either a Premium or Dedicated (App Service) plan. To learn how, see Create your first containerized Azure Functions.
- Deploy to Azure Container Apps. To learn how, see Create your first containerized Azure Functions on Azure Container Apps.
- Deploy to Azure Arc (preview). To learn how, see Create your first containerized Azure Functions on Azure Arc (preview).
- Deploy to a Kubernetes cluster. You can deploy to a cluster using Azure Functions Core Tools. Use the
func kubernetes deploy
command.
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 (likeWEBSITE_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:
Feedback
https://aka.ms/ContentUserFeedback.
Disponibbli dalwaqt: Matul l-2024 se nkunu qed inwaqqfu gradwalment Problemi GitHub bħala l-mekkaniżmu ta’ feedback għall-kontenut u se nibdluh b’sistema ġdida ta’ feedback. Għal aktar informazzjoni, ara:Issottometti u ara feedback għal