Skip to content

Commit 3ae2999

Browse files
Merge pull request #293148 from TimShererWithAquent/us345675-04
Freshness Edit: Azure App Service (4 of several)
2 parents 94440f2 + 8c51553 commit 3ae2999

File tree

1 file changed

+58
-45
lines changed

1 file changed

+58
-45
lines changed

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

Lines changed: 58 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,71 +3,78 @@ 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: 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.
1112
---
1213

13-
# Deployment Best Practices
14+
# Deployment best practices
1415

1516
[!INCLUDE [regionalization-note](./includes/regionalization-note.md)]
1617

17-
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 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.
1819

19-
## Deployment Components
20+
## Deployment components
2021

21-
### Deployment Source
22+
This section describes the three main components for deploying to App Service.
2223

23-
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 may be [a project on your local machine](deploy-local-git.md).
24+
### Deployment source
2425

25-
### Build Pipeline
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).
2627

27-
Once 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 executes a series of steps (such as compiling code, minifying HTML and JavaScript, running tests, and packaging components) to get the application in a runnable state. 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.
28+
### Build pipeline
2829

29-
### Deployment Mechanism
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.
3031

31-
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:
32+
Steps can include 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.
3233

33-
- 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).
34+
### Deployment mechanism
35+
36+
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.
37+
38+
App Service supports the following deployment mechanisms:
39+
40+
- 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).
3441
- 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.
3542

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

3845
## Use deployment slots
3946

40-
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.
47+
Whenever possible, when you deploy a new production build, use [deployment slots](deploy-staging-slots.md). With 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.
4148

4249
### Continuously deploy code
4350

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

46-
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.
53+
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.
4754

48-
![Diagram that shows the flow between the Dev, Staging, and Main branches and the slots they are deployed to.](media/app-service-deploy-best-practices/slot_flow_code_diagam.png)
55+
:::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.":::
4956

5057
### Continuously deploy containers
5158

52-
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.
59+
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. You must push the image to a container registry and update the image tag on the webapp.
5360

54-
For each branch you want to deploy to a slot, set up automation to do the following on each commit to the branch.
61+
For each branch you want to deploy to a slot, set up automation to do these tasks on each commit to the branch.
5562

56-
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. Its best not to use the default latest tag. Otherwise, its difficult to trace back what code is currently deployed, which makes debugging far more difficult.
57-
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.
58-
1. **Update the deployment slot with the new image tag**. When this property is updated, the site will automatically restart and pull the new container image.
63+
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.
64+
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.
65+
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.
5966

60-
![Slot usage visual](media/app-service-deploy-best-practices/slot_flow_container_diagram.png)
67+
:::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.":::
6168

62-
There are examples below for common automation frameworks.
69+
This article contains examples for common automation frameworks.
6370

6471
### Use Azure DevOps
6572

66-
App Service has [built-in continuous delivery](deploy-continuous-deployment.md) for containers through the Deployment Center. Navigate to your app in the [Azure portal](https://portal.azure.com) and select **Deployment Center** under **Deployment**. Follow the instructions to select your repository and branch. This will configure a DevOps build and release pipeline to automatically build, tag, and deploy your container when new commits are pushed to your selected branch.
73+
App Service has [built-in continuous delivery](deploy-continuous-deployment.md) for containers through the Deployment Center. Navigate to your app in the [Azure portal](https://portal.azure.com). Under **Deployment**, select **Deployment Center**. Follow the instructions to select your repository and branch. This approach configures a DevOps build-and-release pipeline to automatically build, tag, and deploy your container when new commits are pushed to your selected branch.
6774

6875
### Use GitHub Actions
6976

70-
You can also automate your container deployment [with GitHub Actions](https://github.com/Azure/webapps-deploy). The workflow file below will build and tag the container with the commit ID, push it to a container registry, and update the specified web app with the new image tag.
77+
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.
7178

7279
```yaml
7380
on:
@@ -112,45 +119,51 @@ az ad sp create-for-rbac --name "myServicePrincipal" --role contributor \
112119
--sdk-auth
113120
```
114121

115-
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. Below are some helpful links for you to construct your container CI process.
122+
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).
116123

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

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

121128
### Java
122129

123-
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).
130+
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).
124131

125132
### Node
126133

127-
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`.
134+
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`.
135+
136+
### .NET
137+
138+
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`.
139+
140+
## Other deployment considerations
128141

129-
### .NET
142+
Other considerations include local cache and high CPU or memory.
130143

131-
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`.
144+
### Local cache
132145

133-
## Other Deployment Considerations
146+
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).
134147

135-
### Local Cache
148+
> [!NOTE]
149+
> Local cache isn't recommended for content management sites such as WordPress.
136150
137-
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.
151+
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).
138152

139-
Always use local cache in conjunction with [deployment slots](deploy-staging-slots.md) to prevent downtime. See [this section](overview-local-cache.md#best-practices-for-using-app-service-local-cache) for information on using these features together.
153+
### High CPU or memory
140154

141-
### High CPU or Memory
155+
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.
142156

143-
If your App Service Plan is using over 90% of available CPU or memory, the underlying virtual machine may have trouble processing your deployment. When this happens, temporarily scale up your instance count to perform the deployment. Once the deployment has finished, you can return the instance count to its previous value.
157+
For more information, visit [App Service Diagnostics](./overview-diagnostics.md) to find out actionable best practices specific to your resource.
144158

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

147-
- Navigate to your Web App in the [Azure portal](https://portal.azure.com).
148-
- Select on **Diagnose and solve problems** in the left navigation, which opens App Service Diagnostics.
149-
- Choose **Best Practices** homepage tile.
150-
- 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.
163+
View the current state of your app in regards to these best practices.
151164

152165
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`.
153166

154-
## More resources
167+
## Related content
155168

156-
[Environment variables and app settings reference](reference-app-settings.md)
169+
- [Environment variables and app settings reference](reference-app-settings.md)

0 commit comments

Comments
 (0)