Skip to content

Commit ad7d287

Browse files
CopilotIEvangelist
andcommitted
Add documentation for deployment slot support in Azure App Service (#290)
* Initial plan * Add documentation for deployment slot support to Azure App Service Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: IEvangelist <7679720+IEvangelist@users.noreply.github.com>
1 parent 9898bda commit ad7d287

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

src/frontend/src/content/docs/integrations/cloud/azure/azure-app-service.mdx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,67 @@ The preceding code:
129129
- Adds an application setting for `ASPNETCORE_ENVIRONMENT`.
130130
- Adds multiple tags for metadata and organization.
131131

132+
## Deployment slots
133+
134+
[Deployment slots](https://learn.microsoft.com/azure/app-service/deploy-staging-slots) let you deploy your app to a staging environment for testing before swapping it into production. The `WithDeploymentSlot` extension method configures a deployment slot for the App Service environment:
135+
136+
```csharp title="C# — AppHost.cs"
137+
var builder = DistributedApplication.CreateBuilder(args);
138+
139+
builder.AddAzureAppServiceEnvironment("appservice")
140+
.WithDeploymentSlot("staging");
141+
142+
var apiService = builder.AddProject<Projects.ApiService>("apiservice")
143+
.WithHttpHealthCheck("/health")
144+
.WithExternalHttpEndpoints();
145+
146+
builder.AddProject<Projects.Web>("webfrontend")
147+
.WithExternalHttpEndpoints()
148+
.WithHttpHealthCheck("/health")
149+
.WithReference(apiService)
150+
.WaitFor(apiService);
151+
152+
builder.Build().Run();
153+
```
154+
155+
The preceding code configures all App Service websites to be deployed to a `staging` slot.
156+
157+
### Deployment slot behavior
158+
159+
When you deploy to a slot, the deployment behavior depends on whether the production App Service already exists:
160+
161+
- **New App Service**: If the production App Service (production slot) doesn't exist at the time of deployment, Aspire deploys to both the production App Service and the specified deployment slot.
162+
- **Existing App Service**: If the production App Service already exists, Aspire deploys only to the specified deployment slot.
163+
164+
This behavior allows you to safely deploy and test changes in a staging environment before swapping to production.
165+
166+
### Using parameters for deployment slots
167+
168+
You can also specify the deployment slot value as a parameter, allowing the slot name to be provided at deployment time:
169+
170+
```csharp title="C# — AppHost.cs"
171+
var builder = DistributedApplication.CreateBuilder(args);
172+
173+
var slotName = builder.AddParameter("deploymentSlot");
174+
175+
builder.AddAzureAppServiceEnvironment("appservice")
176+
.WithDeploymentSlot(slotName);
177+
178+
// Add your projects and other resources...
179+
180+
builder.Build().Run();
181+
```
182+
183+
With this configuration, you can specify the slot name when running `aspire deploy` by providing a value for the `deploymentSlot` parameter.
184+
185+
### Applying customizations to slots
186+
187+
<Aside type="caution">
188+
Customizations applied to the production App Service are not automatically applied to deployment slots. You must explicitly apply any customizations to the slot as well.
189+
</Aside>
190+
191+
When you customize App Service resources using `PublishAsAzureAppServiceWebsite` or `ConfigureInfrastructure`, those customizations apply to the production slot by default. If you need the same customizations on your deployment slot, you must apply them separately. This gives you fine-grained control over the configuration of each slot, allowing staging and production environments to have different settings when needed.
192+
132193
## Provisioning-generated Bicep
133194

134195
If you're new to [Bicep](https://learn.microsoft.com/azure/azure-resource-manager/bicep/overview), it's a domain-specific language for defining Azure resources. With Aspire, you don't need to write Bicep by-hand, instead the provisioning APIs generate Bicep for you. When you publish your app, the generated Bicep is output alongside the manifest file.

0 commit comments

Comments
 (0)