Skip to content

Commit 23da9e4

Browse files
authored
Merge pull request #101070 from cephalin/runpackage
add run-from-package to app service docs
2 parents e3276ba + 3bf9f0b commit 23da9e4

File tree

6 files changed

+119
-33
lines changed

6 files changed

+119
-33
lines changed

articles/app-service/containers/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@
103103
items:
104104
- name: Deploy the app
105105
items:
106+
- name: Run from package
107+
href: ../deploy-run-package.md?toc=%2fazure%2fapp-service%2fcontainers%2ftoc.json
106108
- name: Deploy via FTP
107109
href: ../deploy-ftp.md?toc=%2fazure%2fapp-service%2fcontainers%2ftoc.json
108110
- name: Deploy via cloud sync
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
title: Run your app from a ZIP package
3+
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:
41+
42+
```azurecli-interactive
43+
az webapp deployment source config-zip --resource-group <group-name> --name <app-name> --src <filename>.zip
44+
```
45+
46+
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)

articles/app-service/deploy-zip.md

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -16,74 +16,50 @@ This ZIP file deployment uses the same Kudu service that powers continuous integ
1616

1717
- Deletion of files left over from a previous deployment.
1818
- 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.
2020
- Deployment logs.
2121
- A file size limit of 2048 MB.
2222

2323
For more information, see [Kudu documentation](https://github.com/projectkudu/kudu/wiki/Deploying-from-a-zip-file).
2424

2525
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).
2626

27-
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
28-
2927
## Prerequisites
3028

31-
To complete the steps in this article:
32-
33-
* [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.
4430

45-
Create a ZIP archive of everything in your project. The following command uses the default tool in your terminal:
46-
47-
```
48-
# Bash
49-
zip -r <file-name>.zip .
31+
[!INCLUDE [quickstarts-free-trial-note](../../includes/quickstarts-free-trial-note.md)]
5032

51-
# PowerShell
52-
Compress-Archive -Path * -DestinationPath <file-name>.zip
53-
```
33+
[!INCLUDE [Create a project ZIP file](../../includes/app-service-web-deploy-zip-prepare.md)]
5434

5535
[!INCLUDE [Deploy ZIP file](../../includes/app-service-web-deploy-zip.md)]
5636
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.
5737

5838
## Deploy ZIP file with Azure CLI
5939

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-
6240
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.
6341

6442
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`.
6543

6644
```azurecli-interactive
67-
az webapp deployment source config-zip --resource-group myResourceGroup --name <app_name> --src clouddrive/<filename>.zip
45+
az webapp deployment source config-zip --resource-group <group-name> --name <app-name> --src clouddrive/<filename>.zip
6846
```
6947

7048
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.
7149

7250
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):
7351

7452
```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
7654
```
7755

78-
79-
8056
For more information, see [Kudu documentation](https://github.com/projectkudu/kudu/wiki/Deploying-from-a-zip-file-or-url).
8157

8258
[!INCLUDE [app-service-deploy-zip-push-rest](../../includes/app-service-deploy-zip-push-rest.md)]
8359

8460
## Deploy WAR file
8561

86-
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.
8763

8864
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.
8965

@@ -94,7 +70,7 @@ For the HTTP BASIC authentication, you need your App Service deployment credenti
9470
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.
9571

9672
```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
9874
```
9975

10076
### With PowerShell

articles/app-service/toc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@
117117
items:
118118
- name: Deploy the app
119119
items:
120+
- name: Run from package
121+
href: deploy-run-package.md
120122
- name: Deploy ZIP or WAR
121123
href: deploy-zip.md
122124
- name: Deploy via FTP

includes/app-service-deploy-atomicity.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ ms.custom: "include file"
1414

1515
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:
1616

17+
- [Run your app from the ZIP package directly](../articles/app-service/deploy-run-package.md) without unpacking it.
1718
- 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).
1819
- 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.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
---
2+
title: "include file"
3+
description: "include file"
4+
services: app-service
5+
author: cephalin
6+
ms.service: app-service
7+
ms.topic: "include"
8+
ms.date: 01/14/2020
9+
ms.author: cephalin
10+
ms.custom: "include file"
11+
---
12+
13+
## Create a project ZIP file
14+
15+
>[!NOTE]
16+
> 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:
26+
27+
```
28+
# Bash
29+
zip -r <file-name>.zip .
30+
31+
# PowerShell
32+
Compress-Archive -Path * -DestinationPath <file-name>.zip
33+
```
34+

0 commit comments

Comments
 (0)