Search code examples
azureazure-cli

How can I list webapp extensions using Azure CLI?


I need to remove a Site Extension across ~50 Azure App Services. The az webapp command space doesn't list anything for Site Extensions: https://learn.microsoft.com/en-us/cli/azure/webapp?view=azure-cli-latest

The Azure team won't touch Site Extensions: https://github.com/Azure/azure-cli/issues/7617

However, a comment shows it's possible to delete the extension, if you know the resource ID: https://github.com/Azure/azure-cli/issues/7617#issuecomment-952743871

This command does not return installed extensions:

az resource list --resource-type Microsoft.Web/sites

And this command returns nothing:

az resource list --resource-type Microsoft.Web/sites/siteextensions

So how can I get a list of installed webapp extensions with Azure CLI?


Solution

  • Even Iam unable to get the Extensions list with az resource list --resource-type Microsoft.Web/sites command.

    enter image description here

    Instead of az resource list use show az resource show.

    az resource show --resource-group 'YourRGName' --resource-type 'Microsoft.Web/sites/siteextensions'  --name 'mywebapp15June/siteextensions'                    
    

    enter image description here

    • This command work only if we provide the webapp name. At a time, we can retrieve only 1 webapp.
    • To retrieve the extensions for all the webapps, need to run the above command in loop.

    I have tried to run the command in loop using Bash.

    RG="YourRGName"
    AppNames=$(az webapp list --resource-group $RG --query "[].name" -o tsv)
    
    for AppName in $AppNames; do
        echo "WebApp: $AppName"
        
        extensions=$(az resource show --resource-group $RG --resource-type Microsoft.Web/sites/siteextensions --name "$AppName/siteextensions")
        
        echo "Site Extensions:"
        echo $extensions.title
        echo "=========================="
    done
    

    Output:

    enter image description here

    enter image description here

    The webapps which has extensions installed will be listed.