Stage a .NET Web App Using App Service Deployment Slots and Azure CLI

30 minutes
  • 4 Learning Objectives

About this Hands-on Lab

The Azure App Service includes deployment slots to help improve the way in which updates to your code can be deployed to production.

In this hands-on lab, we’ll use Azure CLI within the Cloud Shell, in order to deploy a basic .NET web application to a staging slot. We’ll then use the Azure Portal to promote the staging slot to production.

Cloud Shell includes Azure CLI and the .NET CLI, which we will use to perform all tasks.

**Scenario**
You’ve recently been employed as a cloud developer for a company that uses Azure App Service. A web application has been deployed by a previous cloud consultant, but no one you work with is familiar with Azure.

After a recent change to the production web app caused an outage, your manager has asked whether you could recommend any improvements to the code deployment processes.

You have suggested the use of App Service deployment slots.

Before implementing this change, you must demonstrate the functionality to your manager. In order to perform this proof of concept, you will need to:

* Deploy a simple .NET Core web application to a new web app in Azure App Service
* Make changes to your web application, and deploy these to a staging slot
* Perform a slot swap, so that your changes are promoted to production

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Set Up Cloud Shell
  1. Set the location to be the same as the storage account’s location.
  2. Use the existing resource group.
  3. Use the existing storage account.
Set Up a .NET Web App in Azure App Service
  1. Create a new demonstration web application.
  2. Build the web application.
  3. Create and deploy your web app.

    NOTE:

    • We recommend you use the same location for your new web app, as your existing storage account (to avoid possible Cloud Shell errors).
    • Remember, the APP_NAME must be unique across Azure.
    • You can press the TAB key to auto-complete the RESOURCE_GROUP and the APP_NAME value.
Update Your App and Upload to a Staging Slot
  1. Update your application.
  2. Create a staging slot.
  3. Deploy to the staging slot:
    a) Publish the updated code
    b) Zip the deployment
    c) ZipDeploy to the staging slot
Swap Staging and Production Slots
  1. Swap staging to production.

Additional Resources

Log in to the Azure Portal by right-clicking on Open Azure Portal, and selecting the option to open it in a new private browser window (this option will read differently depending on your browser — e.g., in Chrome, it says "Open Link in Incognito Window"). Then, sign in using the credentials provided on the lab page.

Some of the objectives for this hands-on lab will be completed using the Cloud Shell within the Azure Portal. We will be using the Bash shell, and will complete commands using Azure CLI.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?