Skip to content

Commit 5ad8fc9

Browse files
Freshness.
1 parent b39eb12 commit 5ad8fc9

File tree

1 file changed

+45
-39
lines changed

1 file changed

+45
-39
lines changed

articles/app-service/deploy-best-practices.md

Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,61 +3,61 @@ title: Deployment best practices
33
description: Learn about the key mechanisms of deploying to Azure App Service. Find language-specific recommendations and other caveats.
44
keywords: azure app service, web app, deploy, deployment, pipelines, build
55
ms.assetid: bb51e565-e462-4c60-929a-2ff90121f41d
6-
ms.topic: article
7-
ms.date: 07/31/2019
6+
ms.topic: best-practice
7+
ms.date: 01/17/2025
88
ms.custom: UpdateFrequency3
99
author: cephalin
1010
ms.author: cephalin
11-
#customer intent
11+
#customer intent: As a build developer, I want to understand the components of deploying to Azure App Service to design the best build solution for the technologies we use in our project.
1212
---
1313

14-
# Deployment Best Practices
14+
# Deployment best practices
1515

1616
[!INCLUDE [regionalization-note](./includes/regionalization-note.md)]
1717

18-
Every development team has unique requirements that can make implementing an efficient deployment pipeline difficult on any cloud service. This article introduces the three main components of deploying to Azure App Service: deployment sources, build pipelines, and deployment mechanisms. This article also covers some best practices and tips for specific language stacks.
18+
Every development team has unique requirements that can make implementing an efficient deployment pipeline difficult on any cloud service. This article introduces the three main components of deploying to Azure App Service: *deployment sources*, *build pipelines*, and *deployment mechanisms*. This article also covers some best practices and tips for specific language stacks.
1919

20-
## Deployment Components
20+
## Deployment components
2121

2222
This section describes the three main components for deploying to App Service.
2323

24-
### Deployment Source
24+
### Deployment source
2525

26-
A deployment source is the location of your application code. For production apps, the deployment source is usually a repository hosted by version control software such as [GitHub, BitBucket, or Azure Repos](deploy-continuous-deployment.md). For development and test scenarios, the deployment source might be [a project on your local machine](deploy-local-git.md).
26+
A *deployment source* is the location of your application code. For production apps, the deployment source is usually a repository hosted by version control software such as [GitHub, BitBucket, or Azure Repos](deploy-continuous-deployment.md). For development and test scenarios, the deployment source might be [a project on your local machine](deploy-local-git.md).
2727

28-
### Build Pipeline
28+
### Build pipeline
2929

30-
After you decide on a deployment source, your next step is to choose a build pipeline. A build pipeline reads your source code from the deployment source and runs a series of steps to get the application in a runnable state. Steps can include as compiling code, minifying HTML and JavaScript, running tests, and packaging components. The specific commands executed by the build pipeline depend on your language stack. These operations can be executed on a build server such as Azure Pipelines, or executed locally.
30+
After you decide on a deployment source, your next step is to choose a *build pipeline*. A build pipeline reads your source code from the deployment source and runs a series of steps to get the application in a runnable state. Steps can include as compiling code, minifying HTML and JavaScript, running tests, and packaging components. The specific commands run by the build pipeline depend on your language stack. You can run these operations on a build server, such as Azure Pipelines, or locally.
3131

32-
### Deployment Mechanism
32+
### Deployment mechanism
3333

34-
The deployment mechanism is the action used to put your built application into the */home/site/wwwroot* directory of your web app. The */wwwroot* directory is a mounted storage location shared by all instances of your web app. When the deployment mechanism puts your application in this directory, your instances receive a notification to sync the new files. App Service supports the following deployment mechanisms:
34+
The *deployment mechanism* is the action used to put your built application into the */home/site/wwwroot* directory of your web app. The */wwwroot* directory is a mounted storage location shared by all instances of your web app. When the deployment mechanism puts your application in this directory, your instances receive a notification to sync the new files. App Service supports the following deployment mechanisms:
3535

36-
- Kudu endpoints: [Kudu](https://github.com/projectkudu/kudu/wiki) is the open-source developer productivity tool that runs as a separate process in Windows App Service, and as a second container in Linux App Service. Kudu handles continuous deployments and provides HTTP endpoints for deployment, such as [zipdeploy/](deploy-zip.md).
36+
- Kudu endpoints: [Kudu](https://github.com/projectkudu/kudu/wiki) is the open-source developer productivity tool that runs as a separate process in Windows App Service. It runs as a second container in Linux App Service. Kudu handles continuous deployments and provides HTTP endpoints for deployment, such as [zipdeploy/](deploy-zip.md).
3737
- FTP and WebDeploy: Using your [site or user credentials](deploy-configure-credentials.md), you can upload files [via FTP](deploy-ftp.md) or WebDeploy. These mechanisms don't go through Kudu.
3838

3939
Deployment tools such as Azure Pipelines, Jenkins, and editor plugins use one of these deployment mechanisms.
4040

4141
## Use deployment slots
4242

43-
Whenever possible, use [deployment slots](deploy-staging-slots.md) when deploying a new production build. When using a Standard App Service Plan tier or better, you can deploy your app to a staging environment, validate your changes, and do smoke tests. When you're ready, you can swap your staging and production slots. The swap operation warms up the necessary worker instances to match your production scale, thus eliminating downtime.
43+
Whenever possible, use [deployment slots](deploy-staging-slots.md) when you deploy a new production build. When using a Standard App Service Plan tier or better, you can deploy your app to a staging environment, validate your changes, and do smoke tests. When you're ready, swap your staging and production slots. The swap operation warms up the necessary worker instances to match your production scale, which eliminates downtime.
4444

4545
### Continuously deploy code
4646

47-
If your project has branches designated for testing, QA, and staging, then each of those branches should be continuously deployed to a staging slot. This approach is known as the [Gitflow design](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow). This design allows your stakeholders to easily assess and test the deployed branch.
47+
If your project has branches designated for testing, QA, and staging, each of those branches should be continuously deployed to a staging slot. This approach is known as the [Gitflow design](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow). This design allows your stakeholders to easily assess and test the deployed branch.
4848

49-
Continuous deployment should never be enabled for your production slot. Instead, your production branch (often main) should be deployed onto a nonproduction slot. When you're ready to release the base branch, swap it into the production slot. Swapping into productioninstead of deploying to productionprevents downtime and allows you to roll back the changes by swapping again.
49+
Continuous deployment should never be enabled for your production slot. Instead, your production branch (often main) should be deployed onto a nonproduction slot. When you're ready to release the base branch, swap it into the production slot. Swapping into production, instead of deploying to production, prevents downtime and allows you to roll back the changes by swapping again.
5050

51-
:::image type="content" source="media/app-service-deploy-best-practices/slot_flow_code_diagam.png" alt-text="Diagram that shows the flow between the Dev, Staging, and Main branches and the slots they are deployed to.":::
51+
:::image type="content" source="media/app-service-deploy-best-practices/slot_flow_code_diagam.png" alt-text="Diagram that shows the flow between the Dev, Staging, and Main branches and the slots they're deployed to.":::
5252

5353
### Continuously deploy containers
5454

5555
For custom containers from Docker or other container registries, deploy the image into a staging slot and swap into production to prevent downtime. The automation is more complex than code deployment because you must push the image to a container registry and update the image tag on the webapp.
5656

5757
For each branch you want to deploy to a slot, set up automation to do these tasks on each commit to the branch.
5858

59-
1. **Build and tag the image**. As part of the build pipeline, tag the image with the git commit ID, timestamp, or other identifiable information. It's best not to use the default *latest* tag. Otherwise, it's difficult to trace back what code is currently deployed, which makes debugging far more difficult.
60-
1. **Push the tagged image**. Once the image is built and tagged, the pipeline pushes the image to our container registry. In the next step, the deployment slot will pull the tagged image from the container registry.
59+
1. **Build and tag the image**. As part of the build pipeline, tag the image with the git commit ID, timestamp, or other identifiable information. It's best not to use the default *latest* tag. Otherwise, it's difficult to trace back what code is currently deployed, which makes debugging more difficult.
60+
1. **Push the tagged image**. After the image is built and tagged, the pipeline pushes the image to the container registry. In the next step, the deployment slot pulls the tagged image from the container registry.
6161
1. **Update the deployment slot with the new image tag**. When this property is updated, the site automatically restarts and pulls the new container image.
6262

6363
:::image type="content" source="media/app-service-deploy-best-practices/slot_flow_container_diagram.png" alt-text="Diagram shows slot usage visual representing Web App, Container Registry, and repository branches.":::
@@ -70,7 +70,7 @@ App Service has [built-in continuous delivery](deploy-continuous-deployment.md)
7070

7171
### Use GitHub Actions
7272

73-
You can also automate your container deployment [with GitHub Actions](https://github.com/Azure/webapps-deploy). The workflow file builds and tags the container with the commit ID, push it to a container registry, and update the specified web app with the new image tag.
73+
You can also automate your container deployment [with GitHub Actions](https://github.com/Azure/webapps-deploy). The workflow file builds and tags the container with the commit ID, pushes it to a container registry, and updates the specified web app with the new image tag.
7474

7575
```yaml
7676
on:
@@ -115,45 +115,51 @@ az ad sp create-for-rbac --name "myServicePrincipal" --role contributor \
115115
--sdk-auth
116116
```
117117

118-
In your script, sign in using `az login --service-principal`, providing the principal’s information. You can then use `az webapp config container set` to set the container name, tag, registry URL, and registry password. Here's a link for you to construct your container CI process.
118+
In your script, sign in using `az login --service-principal`, providing the principal information. You can then use `az webapp config container set` to set the container name, tag, registry URL, and registry password. For more information, see [How to sign in to the Azure CLI on Circle CI](https://circleci.com/orbs/registry/orb/circleci/azure-cli).
119119

120-
- [How to sign in to the Azure CLI on Circle CI](https://circleci.com/orbs/registry/orb/circleci/azure-cli)
120+
## Language-specific considerations
121121

122-
## Language-Specific Considerations
122+
Keep in mind the following considerations for Java, Node, and .NET implementations.
123123

124124
### Java
125125

126-
Use the Kudu [zipdeploy/](deploy-zip.md) API for deploying JAR applications, and [wardeploy/](deploy-zip.md#deploy-warjarear-packages) for WAR apps. If you're using Jenkins, you can use those APIs directly in your deployment phase. For more information, see [this article](/azure/developer/jenkins/deploy-to-azure-app-service-using-azure-cli).
126+
Use the Kudu [zipdeploy/](deploy-zip.md) API for deploying JAR applications. Use [wardeploy/](deploy-zip.md#deploy-warjarear-packages) for WAR apps. If you're using Jenkins, you can use those APIs directly in your deployment phase. For more information, see [Deploy to Azure App Service with Jenkins](/azure/developer/jenkins/deploy-to-azure-app-service-using-azure-cli).
127127

128128
### Node
129129

130-
By default, Kudu executes the build steps for your Node application (`npm install`). If you're using a build service such as Azure DevOps, then the Kudu build is unnecessary. To disable the Kudu build, create an app setting, `SCM_DO_BUILD_DURING_DEPLOYMENT`, with a value of `false`.
130+
By default, Kudu runs the build steps for your Node application (`npm install`). If you're using a build service such as Azure DevOps, the Kudu build is unnecessary. To disable the Kudu build, create an app setting, `SCM_DO_BUILD_DURING_DEPLOYMENT`, with a value of `false`.
131131

132-
### .NET
132+
### .NET
133133

134-
By default, Kudu executes the build steps for your .NET application (`dotnet build`). If you're using a build service such as Azure DevOps, then the Kudu build is unnecessary. To disable the Kudu build, create an app setting, `SCM_DO_BUILD_DURING_DEPLOYMENT`, with a value of `false`.
134+
By default, Kudu runs the build steps for your .NET application (`dotnet build`). If you're using a build service such as Azure DevOps, the Kudu build is unnecessary. To disable the Kudu build, create an app setting, `SCM_DO_BUILD_DURING_DEPLOYMENT`, with a value of `false`.
135135

136-
## Other Deployment Considerations
136+
## Other deployment considerations
137137

138-
### Local Cache
138+
Other considerations include local cache and high CPU or memory.
139139

140-
Azure App Service content is stored on Azure Storage and is surfaced up in a durable manner as a content share. However, some apps just need a high-performance, read-only content store that they can run with high availability. These apps can benefit from using [local cache](overview-local-cache.md). Local cache isn't recommended for content management sites such as WordPress.
140+
### Local cache
141141

142-
To prevent downtime, always use local cache with [deployment slots](deploy-staging-slots.md). See [this section](overview-local-cache.md#best-practices-for-using-app-service-local-cache) for information on using these features together.
142+
Azure App Service content is stored on Azure Storage and is surfaced up in a durable manner as a content share. However, some apps just need a high-performance, read-only content store that they can run with high availability. These apps can benefit from using *local cache*. For more information, see [Azure App Service Local Cache overview](overview-local-cache.md).
143143

144-
### High CPU or Memory
144+
> [!NOTE]
145+
> Local cache isn't recommended for content management sites such as WordPress.
146+
147+
To prevent downtime, always use local cache with [deployment slots](deploy-staging-slots.md). For information on using these features together, see [Best practices](overview-local-cache.md#best-practices-for-using-app-service-local-cache).
148+
149+
### High CPU or memory
145150

146151
If your App Service Plan is using over 90% of available CPU or memory, the underlying virtual machine might have trouble processing your deployment. When this situation happens, temporarily scale up your instance count to perform the deployment. After the deployment finishes, you can return the instance count to its previous value.
147152

148-
For more information on best practices, visit [App Service Diagnostics](./overview-diagnostics.md) to find out actionable best practices specific to your resource.
153+
For more information, visit [App Service Diagnostics](./overview-diagnostics.md) to find out actionable best practices specific to your resource.
154+
155+
1. Navigate to your Web App in the [Azure portal](https://portal.azure.com).
156+
1. Select **Diagnose and solve problems** in the left navigation, which opens App Service Diagnostics.
157+
1. Choose **Availability and Performance** or explore other options, such as **High CPU Analysis**.
149158

150-
- Navigate to your Web App in the [Azure portal](https://portal.azure.com).
151-
- Select on **Diagnose and solve problems** in the left navigation, which opens App Service Diagnostics.
152-
- Choose **Best Practices** homepage tile.
153-
- Select **Best Practices for Availability & Performance** or **Best Practices for Optimal Configuration** to view the current state of your app in regards to these best practices.
159+
View the current state of your app in regards to these best practices.
154160

155161
You can also use this link to directly open App Service Diagnostics for your resource: `https://portal.azure.com/?websitesextension_ext=asd.featurePath%3Ddetectors%2FParentAvailabilityAndPerformance#@microsoft.onmicrosoft.com/resource/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/troubleshoot`.
156162

157-
## More resources
163+
## Related content
158164

159-
[Environment variables and app settings reference](reference-app-settings.md)
165+
- [Environment variables and app settings reference](reference-app-settings.md)

0 commit comments

Comments
 (0)