This post was brought to you by Lohith (kashyapa) (opens new window).

# Deployment Slots for Web Apps using the Azure CLI

# What are Deployment Slots?

Deployment Slots are a feature of Azure App Service. They actually are live apps with their own hostnames. You can create different slots for your application (for e.g. Dev, Test or Stage). The Production slot is the slot where your live app resides. With deploymet slots, you can validate app changes in staging before swapping it with your production slot. You can read more about deployment slots here (opens new window).

# Pre-Requisites

# Log in to Azure

Before executing any Azure CLI commands, you will need to login first.

  • Open Command Prompt or a Powershell session
  • Enter following command:

az login

The command will prompt you to log in with an authentication code via a website.

# Listing Deployment Slots

To list deployment slots in an Azure App Service, execute the following command:

az webapp deployment slot list -n "web app name" -g "resource group name"

# Creating Deployment Slot

To create a new deployment slot in an Azure App Service, execute the following command:

az webapp deployment slot create -n "web app name" -g "resource group name" -s "deployment slot name"

# Swapping Deployment Slot

To swap a deployment slot in an Azure App Service, execute the following command:

az webapp deployment slot swap -n "web app name" -g "resource group name" -s "source slot name" --target-slot "target slot"

# Deleting a Deployment Slot

To delete a deployment slot in an Azpp Service, execute the following command:

az webapp deployment slot delete -n "web app name" -g "resource group name" -s "deployment slot name"

# Conclusion