How to Take the complete list of appservice URLs

Mohan Dass 31 Reputation points
2021-07-12T17:26:33.533+00:00

Hi,

I have to take all the app service's slot URLs. Is there any azure query or any option to get the list of URLs?

Thanks & Regards
Mohan Dass.P

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,968 questions
{count} votes

Accepted answer
  1. BhargaviAnnadevara-MSFT 5,466 Reputation points
    2021-07-13T19:11:10.057+00:00

    @Mohan Dass You can use any of the following options that suits you best:

    Azure PowerShell:

       # Get Azure WebApps across all resource groups in your Subscription  
       $siteNames = Get-AzWebApp  
         
       # Get Azure WebApp Slots across all resource groups in your Subscription  
       $slotNames = Get-AzWebApp | Get-AzWebAppSlot  
         
       # Combine the result  
       $result = $siteNames + $slotNames  
         
       # Extract necessary properties from the result  
       $result | Format-Table -Property Name, Type, ResourceGroup, DefaultHostName  
    

    Sample Output:
    114278-image.png

    Azure Resource Graph through Azure CLI:

    Alternatively, you can consider pulling this data from Azure Resource Graph, as it is engineered for fast responses!

    With the resource-graph extension for Azure CLI, you can craft a command to query this information as under:

       az graph query -q "resources | where type == 'microsoft.web/sites' or type == 'microsoft.web/sites/slots' | extend resourceProperties = parse_json(properties) | extend defaultHostName = tostring(resourceProperties.defaultHostName) | project name, resourceGroup, defaultHostName" --subscriptions 00000000-0000-0000-0000-000000000000 -o table  
    

    and work through the result as needed. Another great advantage that comes with using Azure Resource Graph in this way is the ability to query across subscriptions. Use the --subscriptions parameter to pass in a space-separated list of Subscription IDs to scope your results appropriately.

    Sample Output:
    114343-image.png

    Additional resources:

    Hope this helps. Do let us know if you have further questions.

    ----------

    If an answer is helpful, please "Accept answer" and/or "Up-Vote" which might help other community members reading this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.