List All Deployment Slots in Azure

1.6k views Asked by At

I am trying to find a PowerShell, Azure CLI or portal blade that lists all the deployments slots in use (with or without production included).

It has come to my attention that there were some apps deployed as slots that were never shutdown/deleted and they're just hanging out taking up resources (or potentially taking up resources).

I did find a CLI option that allows me to go through each resource group and list them, which also lists the slots. But if onehas a lot of resources, this is not an easy way to go about it.

 azure list webappp { resource group name }

UPDATE - APR 26 2018

Here's one place in the portal that will list slots next to apps:

App Service Plans > Plan > Apps

1

There are 1 answers

1
huysmania On BEST ANSWER

I don't believe there's a single command for this. But in PowerShell, assuming you're logged in and have selected the subscription you're interested in, you could simply loop through and look for all instances of the resource provider 'Microsoft.Web/sites/slots', like so:

$resources = Get-AzureRmResource
foreach($resource in $resources)
{
    if ($resource.ResourceType -eq 'Microsoft.Web/sites/slots')
    {
        echo $resource.Name
    }
}

You'd need a similar enclosing loop if want to do this for more than one subscription.