question

MohanDass-2003 avatar image
0 Votes"
MohanDass-2003 asked bhargaviannadevara-msft commented

How to Take the complete list of appservice URLs

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-webapps
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@MohanDass-2003 Are you intending to list all the slot URLs that exist for a single webapp? Or list URLs for all app service slots across your subscription?

0 Votes 0 ·
MohanDass-2003 avatar image MohanDass-2003 bhargaviannadevara-msft ·

@bhargaviannadevara-msft I have to get list URLs for all app service's and all slots(Prod, Stage) across my subscription

1 Vote 1 ·

@MohanDass-2003 Thanks for the context. Please check my response below.

0 Votes 0 ·

1 Answer

bhargaviannadevara-msft avatar image
1 Vote"
bhargaviannadevara-msft answered bhargaviannadevara-msft commented

@MohanDass-2003 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.


image.png (111.4 KiB)
image.png (82.7 KiB)
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


@bhargaviannadevara-msft: Thanks for your response. It's working as expected.

1 Vote 1 ·

@MohanDass-2003 Thanks for confirming, glad that helped!

0 Votes 0 ·