@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:
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:
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.