title | description | ms.topic | ms.date |
---|---|---|---|
Run your Azure Functions from a package |
Have the Azure Functions runtime run your functions by mounting a deployment package file that contains your function app project files. |
conceptual |
07/15/2019 |
In Azure, you can run your functions directly from a deployment package file in your function app. The other option is to deploy your files in the d:\home\site\wwwroot
directory of your function app.
This article describes the benefits of running your functions from a package. It also shows how to enable this functionality in your function app.
There are several benefits to running from a package file:
- Reduces the risk of file copy locking issues.
- Can be deployed to a production app (with restart).
- You can be certain of the files that are running in your app.
- Improves the performance of Azure Resource Manager deployments.
- May reduce cold-start times, particularly for JavaScript functions with large npm package trees.
For more information, see this announcement.
To enable your function app to run from a package, you just add a WEBSITE_RUN_FROM_PACKAGE
setting to your function app settings. The WEBSITE_RUN_FROM_PACKAGE
setting can have one of the following values:
Value | Description |
---|---|
1 |
Recommended for function apps running on Windows. Run from a package file in the d:\home\data\SitePackages folder of your function app. If not deploying with zip deploy, this option requires the folder to also have a file named packagename.txt . This file contains only the name of the package file in folder, without any whitespace. |
<URL> |
Location of a specific package file you want to run. When you specify a URL, you must also sync triggers after you publish an updated package. When using Blob storage, you typically should not use a public blob. Instead, use a private container with a Shared Access Signature (SAS) or use a managed identity to enable the Functions runtime to access the package. You can use the Azure Storage Explorer to upload package files to your Blob storage account. |
Caution
When running a function app on Windows, the external URL option yields worse cold-start performance. When deploying your function app to Windows, you should set WEBSITE_RUN_FROM_PACKAGE
to 1
and publish with zip deployment.
The following shows a function app configured to run from a .zip file hosted in Azure Blob storage:
Note
Currently, only .zip package files are supported.
[!INCLUDE Run from package via Identity]
Zip deployment is a feature of Azure App Service that lets you deploy your function app project to the wwwroot
directory. The project is packaged as a .zip deployment file. The same APIs can be used to deploy your package to the d:\home\data\SitePackages
folder. With the WEBSITE_RUN_FROM_PACKAGE
app setting value of 1
, the zip deployment APIs copy your package to the d:\home\data\SitePackages
folder instead of extracting the files to d:\home\site\wwwroot
. It also creates the packagename.txt
file. After a restart, the package is mounted to wwwroot
as a read-only filesystem. For more information about zip deployment, see Zip deployment for Azure Functions.
Note
When a deployment occurs, a restart of the function app is triggered. Before a restart, all existing function executions are allowed to complete or time out. To learn more, see Deployment behaviors.
[!INCLUDE Function app settings]
- Run From Package makes
wwwroot
read-only, so you will receive an error when writing files to this directory. - Tar and gzip formats are not supported.
- The ZIP file can be at most 1GB.
- This feature does not compose with local cache.
- For improved cold-start performance, use the local Zip option (
WEBSITE_RUN_FROM_PACKAGE
=1). - Run From Package is incompatible with deployment customization option (
SCM_DO_BUILD_DURING_DEPLOYMENT=true
), the build step will be ignored during deployment.
[!div class="nextstepaction"] Continuous deployment for Azure Functions