AZ-104 Microsoft Azure Administrator Exam
You're a great admin... on-prem. Now, become a great admin in the cloud and prove it by passing the Microsoft Certified: Azure Administrator Associate exam!
Practice Test

Practice Test

Configure deployment slots for an App Service
Implement Deployment Slot Configuration
Understanding Deployment Slots
Deployment slots are a useful feature of Microsoft Azure's App Service supporting both staging and production workflows. By creating these slots, you have separate live apps within the same resource group, meaning each slot has its unique host name and app URL. This allows you to test changes safely in a staging environment without affecting the live production app. When you're confident your changes are correct, you can perform a slot swap to route traffic seamlessly to the updated version, ensuring minimal downtime for users.
Setting up Deployment Slots
Setting up deployment slots is straightforward using Azure tools. You can use Azure CLI or Azure PowerShell commands to create slots. For example:
- Azure CLI:
az webapp deployment slot create --name <app-name> --resource-group <group-name> --slot <slot-name>
- Azure PowerShell:
New-AzWebAppSlot -ResourceGroupName <group-name> -Name <app-name> -Slot <slot-name> -AppServicePlan <plan-name>
When creating a new slot, you can either clone settings from an existing slot or start fresh. Keep in mind that combined site and slot names should be under 59 characters to avoid DNS limitations.
Executing a Slot Swap
A swap operation prepares the source slot to ensure zero downtime. During the swap, App Service applies slot-specific settings, restarts instances, triggers local cache or custom warm-up procedures, and finally modifies traffic routing rules. Importantly, if instances fail to initialize correctly, the system automatically rolls back—maintaining app stability. After the swap, the former production app moves to the staging slot, ready for additional testing or quick rollback.
Best Practices for Deployment Slots
Following some best practices can make your deployment process smoother and more reliable. It’s advisable not to enable continuous deployment on your production slot directly; instead, deploy main branches to staging slots. Use these staging slots for QA, smoke tests, and reviews before finalizing swaps into production.
In container setups, it's smart to tag images explicitly and push them to your registry, then update the slot's image tag to ensure automated and safe rollouts. This method aids in preventing downtime and simplifies rollback procedures by leveraging swaps instead of direct production redeployments.
Conclusion
Deployment slots are an integral feature of Azure App Services that help maintain uptime and streamline transitions between staging and production environments. By understanding how deployment slots work and mastering their setup using Azure tools, one can efficiently manage application updates. Remember the best practices mentioned—such as using staging slots for quality assurance and deploying main branches for minimal risk—ensure successful management with deployment slots.