Search code examples
azureazure-web-app-serviceazure-cloud-shell

How to get a swap config preview when swapping Azure App Service from cli?


When swapping the production slot with a staging slot for a Azure App Service through the portal you get a little warning in case the configs differ between the slots.

I would like to get the same warning when I swap from command line (for example with az in bash), is that possible, and if so how to do it?


Solution

  • There does not seem to be any way to get a confirmation before the swap is completed using Azure CLI.

    If you want a confirmation dialog you need to script it separately, e.g. like this

    read -r -p "Are you sure? [y/N] " response
    if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
    then
        az webapp deployment slot swap  -g MyResourceGroup -n MyUniqueApp --slot staging --target-slot production
    fi
    

    References

    • see this page for more info about the swapping slots using the cli.
    • and this page for details on conditionally executing statements in bash