You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Deploy your app's ZIP package with atomicity. Improve the predictability and reliability of your app's behavior during the ZIP deployment process.
4
+
ms.topic: article
5
+
ms.date: 01/14/2020
6
+
7
+
---
8
+
9
+
# Run your app in Azure App Service directly from a ZIP package
10
+
11
+
In [Azure App Service](overview.md), you can run your apps directly from a deployment ZIP package file. This article shows how to enable this functionality in your app.
12
+
13
+
All other deployment methods in App Service have something in common: your files are deployed to *D:\home\site\wwwroot* in your app (or */home/site/wwwroot* for Linux apps). Since the same directory is used by your app at runtime, it's possible for deployment to fail because of file lock conflicts, and for the app to behave unpredictably because some of the files are not yet updated.
14
+
15
+
In contrast, when you run directly from a package, the files in the package are not copied to the *wwwroot* directory. Instead, the ZIP package itself gets mounted directly as the read-only *wwwroot* directory. There are several benefits to running directly from a package:
16
+
17
+
- Eliminates file lock conflicts between deployment and runtime.
18
+
- Ensures only full-deployed apps are running at any time.
19
+
- Can be deployed to a production app (with restart).
20
+
- Improves the performance of Azure Resource Manager deployments.
21
+
- May reduce cold-start times, particularly for JavaScript functions with large npm package trees.
22
+
23
+
> [!NOTE]
24
+
> Currently, only ZIP package files are supported.
25
+
26
+
[!INCLUDE [Create a project ZIP file](../../includes/app-service-web-deploy-zip-prepare.md)]
27
+
28
+
## Enable running from package
29
+
30
+
The `WEBSITE_RUN_FROM_PACKAGE` app setting enables running from a package. To set it, run the following command with Azure CLI.
31
+
32
+
```azurecli-interactive
33
+
az webapp config appsettings set --resource-group <group-name> --name <app-name> --settings WEBSITE_RUN_FROM_PACKAGE="1"
34
+
```
35
+
36
+
`WEBSITE_RUN_FROM_PACKAGE="1"` lets you run your app from a package local to your app. You can also [run from a remote package](#run-from-external-url-instead).
37
+
38
+
## Run the package
39
+
40
+
The easiest way to run a package in your App Service is with the Azure CLI [az webapp deployment source config-zip](/cli/azure/webapp/deployment/source?view=azure-cli-latest#az-webapp-deployment-source-config-zip) command. For example:
Because the `WEBSITE_RUN_FROM_PACKAGE` app setting is set, this command doesn't extract the package content to the *D:\home\site\wwwroot* directory of your app. Instead, it uploads the ZIP file as-is to *D:\home\data\SitePackages*, and creates a *packagename.txt* in the same directory, that contains the name of the ZIP package to load at runtime. If you upload your ZIP package in a different way (such as [FTP](deploy-ftp.md)), you need to create the *D:\home\data\SitePackages* directory and the *packagename.txt* file manually.
47
+
48
+
The command also restarts the app. Because `WEBSITE_RUN_FROM_PACKAGE` is set, App Service mounts the uploaded package as the read-only *wwwroot* directory and runs the app directly from that mounted directory.
49
+
50
+
## Run from external URL instead
51
+
52
+
You can also run a package from an external URL, such as Azure Blob Storage. You can use the [Azure Storage Explorer](../vs-azure-tools-storage-manage-with-storage-explorer.md) to upload package files to your Blob storage account. You should use a private storage container with a [Shared Access Signature (SAS)](../vs-azure-tools-storage-manage-with-storage-explorer.md#generate-a-sas-in-storage-explorer) to enable the App Service runtime to access the package securely.
53
+
54
+
Once you upload your file to Blob storage and have an SAS URL for the file, set the `WEBSITE_RUN_FROM_PACKAGE` app setting to the URL. The following example does it by using Azure CLI:
55
+
56
+
```azurecli-interactive
57
+
az webapp config appsettings set --name <app-name> --resource-group <resource-group-name> --settings WEBSITE_RUN_FROM_PACKAGE="https://myblobstorage.blob.core.windows.net/content/SampleCoreMVCApp.zip?st=2018-02-13T09%3A48%3A00Z&se=2044-06-14T09%3A48%3A00Z&sp=rl&sv=2017-04-17&sr=b&sig=bNrVrEFzRHQB17GFJ7boEanetyJ9DGwBSV8OM3Mdh%2FM%3D"
58
+
```
59
+
60
+
If you publish an updated package with the same name to Blob storage, you need to restart your app so that the updated package is loaded into App Service.
61
+
62
+
## Troubleshooting
63
+
64
+
- Running directly from a package makes `wwwroot` read-only. Your app will receive an error if it tries to write files to this directory.
65
+
- TAR and GZIP formats are not supported.
66
+
- This feature is not compatible with [local cache](overview-local-cache.md).
67
+
- For improved cold-start performance, use the local Zip option (`WEBSITE_RUN_FROM_PACKAGE`=1).
68
+
69
+
## More resources
70
+
71
+
-[Continuous deployment for Azure App Service](deploy-continuous-deployment.md)
72
+
-[Deploy code with a ZIP or WAR file](deploy-zip.md)
Copy file name to clipboardExpand all lines: articles/app-service/deploy-zip.md
+8-32Lines changed: 8 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,74 +16,50 @@ This ZIP file deployment uses the same Kudu service that powers continuous integ
16
16
17
17
- Deletion of files left over from a previous deployment.
18
18
- Option to turn on the default build process, which includes package restore.
19
-
-[Deployment customization](https://github.com/projectkudu/kudu/wiki/Configurable-settings#repository-and-deployment-related-settings), including running deployment scripts.
19
+
- Deployment customization, including running deployment scripts.
20
20
- Deployment logs.
21
21
- A file size limit of 2048 MB.
22
22
23
23
For more information, see [Kudu documentation](https://github.com/projectkudu/kudu/wiki/Deploying-from-a-zip-file).
24
24
25
25
The WAR file deployment deploys your [WAR](https://wikipedia.org/wiki/WAR_(file_format)) file to App Service to run your Java web app. See [Deploy WAR file](#deploy-war-file).
*[Create an App Service app](/azure/app-service/), or use an app that you created for another tutorial.
34
-
35
-
## Create a project ZIP file
36
-
37
-
>[!NOTE]
38
-
> If you downloaded the files in a ZIP file, extract the files first. For example, if you downloaded a ZIP file from GitHub, you cannot deploy that file as-is. GitHub adds additional nested directories, which do not work with App Service.
39
-
>
40
-
41
-
In a local terminal window, navigate to the root directory of your app project.
42
-
43
-
This directory should contain the entry file to your web app, such as _index.html_, _index.php_, and _app.js_. It can also contain package management files like _project.json_, _composer.json_, _package.json_, _bower.json_, and _requirements.txt_.
29
+
To complete the steps in this article, [create an App Service app](/azure/app-service/), or use an app that you created for another tutorial.
44
30
45
-
Create a ZIP archive of everything in your project. The following command uses the default tool in your terminal:
[!INCLUDE [Create a project ZIP file](../../includes/app-service-web-deploy-zip-prepare.md)]
54
34
55
35
[!INCLUDE [Deploy ZIP file](../../includes/app-service-web-deploy-zip.md)]
56
36
The above endpoint does not work for Linux App Services at this time. Consider using FTP or the [ZIP deploy API](https://docs.microsoft.com/azure/app-service/containers/app-service-linux-faq#continuous-integration-and-deployment) instead.
57
37
58
38
## Deploy ZIP file with Azure CLI
59
39
60
-
Make sure your Azure CLI version is 2.0.21 or later. To see which version you have, run `az --version` command in your terminal window.
61
-
62
40
Deploy the uploaded ZIP file to your web app by using the [az webapp deployment source config-zip](/cli/azure/webapp/deployment/source?view=azure-cli-latest#az-webapp-deployment-source-config-zip) command.
63
41
64
42
The following example deploys the ZIP file you uploaded. When using a local installation of Azure CLI, specify the path to your local ZIP file for `--src`.
This command deploys the files and directories from the ZIP file to your default App Service application folder (`\home\site\wwwroot`) and restarts the app.
71
49
72
50
By default, the deployment engine assumes that a ZIP file is ready to run as-is and doesn't run any build automation. To enable the same build automation as in a [Git deployment](deploy-local-git.md), set the `SCM_DO_BUILD_DURING_DEPLOYMENT` app setting by running the following command in the [Cloud Shell](https://shell.azure.com):
73
51
74
52
```azurecli-interactive
75
-
az webapp config appsettings set --resource-group <resource-group-name> --name <app-name> --settings SCM_DO_BUILD_DURING_DEPLOYMENT=true
53
+
az webapp config appsettings set --resource-group <group-name> --name <app-name> --settings SCM_DO_BUILD_DURING_DEPLOYMENT=true
76
54
```
77
55
78
-
79
-
80
56
For more information, see [Kudu documentation](https://github.com/projectkudu/kudu/wiki/Deploying-from-a-zip-file-or-url).
To deploy a WAR file to App Service, send a POST request to `https://<app_name>.scm.azurewebsites.net/api/wardeploy`. The POST request must contain the .war file in the message body. The deployment credentials for your app are provided in the request by using HTTP BASIC authentication.
62
+
To deploy a WAR file to App Service, send a POST request to `https://<app-name>.scm.azurewebsites.net/api/wardeploy`. The POST request must contain the .war file in the message body. The deployment credentials for your app are provided in the request by using HTTP BASIC authentication.
87
63
88
64
Always use `/api/wardeploy` when deploying WAR files. This API will expand your WAR file and place it on the shared file drive. using other deployment APIs may result in inconsistent behavior.
89
65
@@ -94,7 +70,7 @@ For the HTTP BASIC authentication, you need your App Service deployment credenti
94
70
The following example uses the cURL tool to deploy a .war file. Replace the placeholders `<username>`, `<war-file-path>`, and `<app-name>`. When prompted by cURL, type in the password.
95
71
96
72
```bash
97
-
curl -X POST -u <username> --data-binary @"<war-file-path>" https://<app_name>.scm.azurewebsites.net/api/wardeploy
73
+
curl -X POST -u <username> --data-binary @"<war-file-path>" https://<app-name>.scm.azurewebsites.net/api/wardeploy
Copy file name to clipboardExpand all lines: includes/app-service-deploy-atomicity.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,6 +14,6 @@ ms.custom: "include file"
14
14
15
15
All the officially supported deployment methods make changes to the files in the `/home/site/wwwroot` folder of your app. These files are used to run your app. Therefore, the deployment can fail because of locked files. The app may also behave unpredictably during deployment, because not all the files updated at the same time. This is undesirable for a customer-facing app. There are a few different ways to avoid these issues:
16
16
17
+
-[Run your app from the ZIP package directly](../articles/app-service/deploy-run-package.md) without unpacking it.
17
18
- Stop your app or enable offline mode for your app during deployment. For more information, see [Deal with locked files during deployment](https://github.com/projectkudu/kudu/wiki/Dealing-with-locked-files-during-deployment).
18
19
- Deploy to a [staging slot](../articles/app-service/deploy-staging-slots.md) with [auto swap](../articles/app-service/deploy-staging-slots.md#configure-auto-swap) enabled.
19
-
- Use [Run From Package](https://github.com/Azure/app-service-announcements/issues/84) instead of continuous deployment.
> If you downloaded the files in a ZIP file, extract the files first. For example, if you downloaded a ZIP file from GitHub, you cannot deploy that file as-is. GitHub adds additional nested directories, which do not work with App Service.
17
+
>
18
+
19
+
In a local terminal window, navigate to the root directory of your app project.
20
+
21
+
This directory should contain the entry file to your web app, such as _index.html_, _index.php_, and _app.js_. It can also contain package management files like _project.json_, _composer.json_, _package.json_, _bower.json_, and _requirements.txt_.
22
+
23
+
Unless you want App Service to run deployment automation for you, run all the build tasks (for example, `npm`, `bower`, `gulp`, `composer`, and `pip`) and make sure that you have all the files you need to run the app. This step is required if you want to [run your package directly](../articles/app-service/deploy-run-package.md).
24
+
25
+
Create a ZIP archive of everything in your project. The following command uses the default tool in your terminal:
0 commit comments