I have a number of instance running under my app service in Azure. I need to get back all the id’s of these instances.
I am currently using
Get-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType
Microsoft.Web/sites/instances -Name $WebAppName -ApiVersion 2016-03-01
But is there an equivalent command using the az cmdlets ?
2
Answers
I’ve tried the exact PowerShell command that you executed in Azure PowerShell. I could be able to get the expected results as shown:
I’ve tried to get the desired outcome with
AZ cmdlet
(Bash) and received the expected results using:To get the instances running info with their respective ID’s on app service in Azure:
If you want to retrieve "default hostname, EnabledHostName as well as state" of WebApp, Use below command as shown:
Refer MSDoc az.webapp cmdlets
It is always recommended to use latest
Az
PowerShell module cmdlets instead ofAzureRM
sinceAzureRm
is going to retire soon.In the above answer shared by @jahanvi replace
Get-AzureRMResource
withGet-AzResource
which is a relevant Az module cmdlet.Alternatively, you can use the Azure Management RestAPI to get the list of instances running under a particular webapp using
Invoke-RequestMethod
you call the rest api from powershell as well.Here is the sample script:
Here is the sample screenshot for reference: