AZ-104 Question 195
Single answerYou are an Azure Administrator managing a web application hosted in an Azure App Service. Your team wants to test new code in a staging environment before pushing it to production, ensuring that key-value pairs and environment variables differ between the two environments. After testing, they want to promote the staged deployment to production with minimal downtime. Which approach should you take?
- A
Create a new deployment slot, enable Auto Swap, and put staging environment variables directly in the web.config.
- B
Create a staging slot, configure slot settings for environment variables, and use the Swap feature to move the staged app into production.
- C
Configure a new slot and store the environment variables in the appsettings.json file, then manually copy them to production when ready.
- D
Create a new App Service Plan for the staging environment and configure separate variables in the same slot.
Show answer and explanation
Correct answer: B
Explanation
Deployment slots provide an efficient way to separate environments and perform zero-downtime deployments. By creating a staging slot and assigning unique slot settings, changes can be tested thoroughly. When ready, use the Swap feature to promote the code to production with minimal impact to users.
- A. Incorrect.
Enabling Auto Swap might immediately push every build on the staging slot into production. Also, environment variables set directly in web.config do not guarantee proper isolation between slots.
- B. Correct.
This is the recommended practice. Staging slots allow you to configure distinct slot settings for variables and then perform a controlled Swap for minimal downtime.
- C. Incorrect.
While you can store environment variables in appsettings.json, this approach complicates environment isolation and requires manual copying, increasing the risk of errors.
- D. Incorrect.
Setting up an additional App Service Plan for staging is typically unnecessary and incurs extra cost. Deployment slots within the same plan are more cost-effective and straightforward.