Skip to content

Commit 6d6aee3

Browse files
committed
Initial refresh of article
1 parent b6018be commit 6d6aee3

File tree

1 file changed

+40
-43
lines changed

1 file changed

+40
-43
lines changed
Lines changed: 40 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
---
22
title: Run your functions from a package file in Azure
3-
description: Have the Azure Functions runtime run your functions by mounting a deployment package file that contains your function app project files.
3+
description: Learn how to configure Azure Functions to run your function app from a deployment package file that contains your function app project files.
4+
mw-service: azure-functions
45
ms.topic: conceptual
5-
ms.date: 02/05/2022
6+
ms.date: 06/21/2024
67

8+
# Customer intent: As a function developer, I want to understand how to run my function app from a deployment package file, so I can make my function app run faster and easier to update.
79
---
810

911
# Run your functions from a package file in Azure
@@ -14,26 +16,26 @@ This article describes the benefits of running your functions from a package. It
1416

1517
## Benefits of running from a package file
1618

17-
There are several benefits to running from a package file:
19+
There are several benefits to running functions from a package file:
1820

1921
+ Reduces the risk of file copy locking issues.
2022
+ Can be deployed to a production app (with restart).
21-
+ You can be certain of the files that are running in your app.
23+
+ Verifies the files that are running in your app.
2224
+ Improves the performance of [Azure Resource Manager deployments](functions-infrastructure-as-code.md).
23-
+ May reduce cold-start times, particularly for JavaScript functions with large npm package trees.
25+
+ Can reduce cold-start times, particularly for JavaScript functions with large npm package trees.
2426

2527
For more information, see [this announcement](https://github.com/Azure/app-service-announcements/issues/84).
2628

2729
## Enable functions to run from a package
2830

29-
To enable your function app to run from a package, 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:
31+
To enable your function app to run from a package, add a `WEBSITE_RUN_FROM_PACKAGE` app setting to your function app. The `WEBSITE_RUN_FROM_PACKAGE` app setting can have one of the following values:
3032

3133
| Value | Description |
3234
|---------|---------|
3335
| **`1`** | Indicates that the function app runs from a local package file deployed in the `c:\home\data\SitePackages` (Windows) or `/home/data/SitePackages` (Linux) folder of your function app. |
3436
|**`<URL>`** | Sets a URL that is the remote location of the specific package file you want to run. Required for functions apps running on Linux in a Consumption plan. |
3537

36-
The following table indicates the recommended `WEBSITE_RUN_FROM_PACKAGE` options for deployment to a specific operating system and hosting plan:
38+
The following table indicates the recommended `WEBSITE_RUN_FROM_PACKAGE` values for deployment to a specific operating system and hosting plan:
3739

3840
| Hosting plan | Windows | Linux |
3941
| --- | --- | --- |
@@ -43,98 +45,93 @@ The following table indicates the recommended `WEBSITE_RUN_FROM_PACKAGE` options
4345

4446
## General considerations
4547

46-
+ The package file must be .zip formatted. Tar and gzip formats aren't currently supported.
48+
+ The package file must be .zip formatted. Tar and gzip formats aren't supported.
4749
+ [Zip deployment](#integration-with-zip-deployment) is recommended.
4850
+ When deploying your function app to Windows, you should set `WEBSITE_RUN_FROM_PACKAGE` to `1` and publish with zip deployment.
49-
+ When you run from a package, the `wwwroot` folder becomes read-only and you'll receive an error when writing files to this directory. Files are also read-only in the Azure portal.
50-
+ The maximum size for a deployment package file is currently 1 GB.
51-
+ You can't use local cache when running from a deployment package.
52-
+ If your project needs to use remote build, don't use the `WEBSITE_RUN_FROM_PACKAGE` app setting. Instead add the `SCM_DO_BUILD_DURING_DEPLOYMENT=true` deployment customization app setting. For Linux, also add the `ENABLE_ORYX_BUILD=true` setting. To learn more, see [Remote build](functions-deployment-technologies.md#remote-build).
51+
+ When you run from a package, the `wwwroot` folder is read-only and you receive an error if you write files to this directory. Files are also read-only in the Azure portal.
52+
+ The maximum size for a deployment package file is 1 GB.
53+
+ You can't use the local cache when running from a deployment package.
54+
+ If your project needs to use remote build, don't use the `WEBSITE_RUN_FROM_PACKAGE` app setting. Instead, add the `SCM_DO_BUILD_DURING_DEPLOYMENT=true` deployment customization app setting. For Linux, also add the `ENABLE_ORYX_BUILD=true` setting. For more information, see [Remote build](functions-deployment-technologies.md#remote-build).
5355

5456
> [!NOTE]
55-
> WEBSITE_RUN_FROM_PACKAGE does not work with MSDeploy as described [here](https://github.com/projectkudu/kudu/wiki/MSDeploy-VS.-ZipDeploy). You will receive an error during deployment like `ARM-MSDeploy Deploy Failed`. Change /MSDeploy to /ZipDeploy and this error will be resolved.
57+
> The `WEBSITE_RUN_FROM_PACKAGE` app setting does not work with MSDeploy as described in [MSDeploy VS. ZipDeploy](https://github.com/projectkudu/kudu/wiki/MSDeploy-VS.-ZipDeploy). You will receive an error during deployment, such as `ARM-MSDeploy Deploy Failed`. To resolve this error, hange `/MSDeploy` to `/ZipDeploy`.
5658
57-
### Adding the WEBSITE_RUN_FROM_PACKAGE setting
59+
### Add the WEBSITE_RUN_FROM_PACKAGE setting
5860

5961
[!INCLUDE [Function app settings](../../includes/functions-app-settings.md)]
6062

61-
## Using WEBSITE_RUN_FROM_PACKAGE = 1
63+
## Use WEBSITE_RUN_FROM_PACKAGE = 1
6264

6365
This section provides information about how to run your function app from a local package file.
6466

6567
### Considerations for deploying from an on-site package
6668

67-
+ Using an on-site package is the recommended option for running from the deployment package, except on Linux hosted in a Consumption plan.
69+
+ Using an on-site package is the recommended option for running from the deployment package, except when running on Linux hosted in a Consumption plan.
6870
+ [Zip deployment](#integration-with-zip-deployment) is the recommended way to upload a deployment package to your site.
6971
+ When not using zip deployment, make sure the `c:\home\data\SitePackages` (Windows) or `/home/data/SitePackages` (Linux) folder has a file named `packagename.txt`. This file contains only the name, without any whitespace, of the package file in this folder that's currently running.
7072

7173
### Integration with zip deployment
7274

73-
[Zip deployment][Zip deployment for Azure Functions] 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 `c:\home\data\SitePackages` (Windows) or `/home/data/SitePackages` (Linux) folder.
75+
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 `c:\home\data\SitePackages` (Windows) or `/home/data/SitePackages` (Linux) folder.
7476

75-
With the `WEBSITE_RUN_FROM_PACKAGE` app setting value of `1`, the zip deployment APIs copy your package to the `c:\home\data\SitePackages` (Windows) or `/home/data/SitePackages` (Linux) folder instead of extracting the files to `c:\home\site\wwwroot` (Windows) or `/home/site/wwwroot` (Linux). 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](deployment-zip-push.md).
77+
When you set the `WEBSITE_RUN_FROM_PACKAGE` app setting value to `1`, the zip deployment APIs copy your package to the `c:\home\data\SitePackages` (Windows) or `/home/data/SitePackages` (Linux) folder instead of extracting the files to `c:\home\site\wwwroot` (Windows) or `/home/site/wwwroot` (Linux). It also creates the `packagename.txt` file. After your function app is automatically restarted, the package is mounted to `wwwroot` as a read-only filesystem. For more information about zip deployment, see [Zip deployment for Azure Functions](deployment-zip-push.md).
7678

7779
> [!NOTE]
78-
> When a deployment occurs, a restart of the function app is triggered. Function executions currently running during the deploy are terminated. Please review [Improve the performance and reliability of Azure Functions](performance-reliability.md#write-functions-to-be-stateless) to learn how to write stateless and defensive functions.
80+
> When a deployment occurs, a restart of the function app is triggered. Function executions currently running during the deploy are terminated. For information about how to write stateless and defensive functions, sett [Write functions to be stateless](performance-reliability.md#write-functions-to-be-stateless).
7981
80-
## Using WEBSITE_RUN_FROM_PACKAGE = URL
82+
## Use WEBSITE_RUN_FROM_PACKAGE = URL
8183

82-
This section provides information about how to run your function app from a package deployed to a URL endpoint. This option is the only one supported for running from a package on Linux hosted in a Consumption plan.
84+
This section provides information about how to run your function app from a package deployed to a URL endpoint. This option is the only one supported for running from a Linux-hosted package with a Consumption plan.
8385

8486
### Considerations for deploying from a URL
8587

86-
<a name="troubleshooting"></a>
87-
88-
+ Function apps running on Windows experience a slight increase in [cold start time](event-driven-scaling.md#cold-start) when the application package is deployed to a URL endpoint via `WEBSITE_RUN_FROM_PACKAGE = <URL>`.
88+
+ Function apps running on Windows experience a slight increase in [cold-start time](event-driven-scaling.md#cold-start) when the application package is deployed to a URL endpoint via `WEBSITE_RUN_FROM_PACKAGE = <URL>`.
8989
+ When you specify a URL, you must also [manually sync triggers](functions-deployment-technologies.md#trigger-syncing) after you publish an updated package.
9090
+ The Functions runtime must have permissions to access the package URL.
91-
+ You shouldn't deploy your package to Azure Blob Storage as a public blob. Instead, use a private container with a [Shared Access Signature (SAS)](../storage/common/storage-sas-overview.md) or [use a managed identity](#fetch-a-package-from-azure-blob-storage-using-a-managed-identity) to enable the Functions runtime to access the package.
91+
+ Don't deploy your package to Azure Blob Storage as a public blob. Instead, use a private container with a [shared access signature (SAS)](../storage/common/storage-sas-overview.md) or [use a managed identity](#fetch-a-package-from-azure-blob-storage-using-a-managed-identity) to enable the Functions runtime to access the package.
9292
+ You must maintain any SAS URLs used for deployment. When an SAS expires, the package can no longer be deployed. In this case, you must generate a new SAS and update the setting in your function app. You can eliminate this management burden by [using a managed identity](#fetch-a-package-from-azure-blob-storage-using-a-managed-identity).
9393
+ When running on a Premium plan, make sure to [eliminate cold starts](functions-premium-plan.md#eliminate-cold-starts).
94-
+ When running on a Dedicated plan, make sure you've enabled [Always On](dedicated-plan.md#always-on).
95-
+ You can use the [Azure Storage Explorer](../vs-azure-tools-storage-manage-with-storage-explorer.md) to upload package files to blob containers in your storage account.
94+
+ When your running on a Dedicated plan, ensure you enable [Always On](dedicated-plan.md#always-on).
95+
+ You can use [Azure Storage Explorer](../vs-azure-tools-storage-manage-with-storage-explorer.md) to upload package files to blob containers in your storage account.
9696

9797
### Manually uploading a package to Blob Storage
9898

99-
To deploy a zipped package when using the URL option, you must create a .zip compressed deployment package and upload it to the destination. This example deploys to a container in Blob Storage.
99+
To deploy a zipped package when using the URL option, you must create a .zip compressed deployment package and upload it to the destination. The following procedure deploys to a container in Blob Storage:
100100

101101
1. Create a .zip package for your project using the utility of your choice.
102102

103-
1. In the [Azure portal](https://portal.azure.com), search for your storage account name or browse for it in storage accounts.
103+
1. In the [Azure portal](https://portal.azure.com), search for your storage account name or browse for it in the storage accounts list.
104104

105105
1. In the storage account, select **Containers** under **Data storage**.
106106

107107
1. Select **+ Container** to create a new Blob Storage container in your account.
108108

109-
1. In the **New container** page, provide a **Name** (for example, "deployments"), make sure the **Public access level** is **Private**, and select **Create**.
109+
1. In the **New container** page, provide a **Name** (for example, *deployments*), ensure the **Anonymous access level** is **Private**, and then select **Create**.
110110

111-
1. Select the container you created, select **Upload**, browse to the location of the .zip file you created with your project, and select **Upload**.
111+
1. Select the container you created, select **Upload**, browse to the location of the .zip file you created with your project, and then select **Upload**.
112112

113-
1. After the upload completes, choose your uploaded blob file, and copy the URL. You may need to generate a SAS URL if you aren't [using an identity](#fetch-a-package-from-azure-blob-storage-using-a-managed-identity)
113+
1. After the upload completes, choose your uploaded blob file, and copy the URL. If you aren't [using a managed identity](#fetch-a-package-from-azure-blob-storage-using-a-managed-identity), you might need to generate a SAS URL.
114114

115115
1. Search for your function app or browse for it in the **Function App** page.
116116

117-
1. In your function app, select **Configurations** under **Settings**.
117+
1. In your function app, expand **Settings**, and then select **Environment variables**.
118118

119-
1. In the **Application Settings** tab, select **New application setting**
119+
1. In the **App settings** tab, select **+ Add**.
120120

121121
1. Enter the value `WEBSITE_RUN_FROM_PACKAGE` for the **Name**, and paste the URL of your package in Blob Storage as the **Value**.
122122

123-
1. Select **OK**. Then select **Save** > **Continue** to save the setting and restart the app.
123+
1. Select **Apply**. Select **Apply** again, and then select **Confirm** to save the setting and restart the app.
124124

125-
Now you can run your function in Azure to verify that deployment has succeeded using the deployment package .zip file.
125+
Now you can run your function in Azure to verify that deployment of the deployment package .zip file was successful.
126126

127-
The following shows a function app configured to run from a .zip file hosted in Azure Blob storage:
127+
The following screenshot shows a function app configured to run from a .zip file hosted in Azure Blob storage:
128128

129-
![WEBSITE_RUN_FROM_ZIP app setting](./media/run-functions-from-deployment-package/run-from-zip-app-setting-portal.png)
129+
![Screenshot that shows the WEBSITE_RUN_FROM_ZIP app setting.](./media/run-functions-from-deployment-package/run-from-zip-app-setting-portal.png)
130130

131131
### Fetch a package from Azure Blob Storage using a managed identity
132132

133133
[!INCLUDE [Run from package via Identity](../../includes/app-service-run-from-package-via-identity.md)]
134134

135-
## Next steps
136-
137-
> [!div class="nextstepaction"]
138-
> [Continuous deployment for Azure Functions](functions-continuous-deployment.md)
135+
## Related content
139136

140-
[Zip deployment for Azure Functions]: deployment-zip-push.md
137+
+ [Continuous deployment for Azure Functions](functions-continuous-deployment.md)

0 commit comments

Comments
 (0)