0

I am having an issue trying to retrieve all the instance names in an Azure App Service Plan.

In Azure Monitor, if you specify a "Scope" to "App Service Plan" and look at the Metric "CPU Percentage" and then add a filter to specify the "Instance" property, you can see which instance uses the most CPU. I am trying to do a PowerShell script to get these values. Unfortunatly I have not found any Azure REST Api that would give me this information so that my script would be 100% dynamic. I looked at the AzureRm or Az PowerShell modules but did not find anything there.

Any ideas how I can retrieve this list? The instances names looks like this :RD123456.

Thanks for you help !

FidelCasto
  • 176
  • 2
  • 15

1 Answers1

2

Suppose you want to get the web instance name, if that's right you could get it from instance process with Web Apps - Get Instance Process.

And under the environment_variables there is a COMPUTERNAME suppose this is what you want.

enter image description here

George Chen
  • 13,703
  • 2
  • 11
  • 26
  • is not it the same thing answered below? – Sajeetharan Jan 16 '20 at 07:59
  • Check the rest description, it's not same thing. – George Chen Jan 16 '20 at 08:00
  • @Sajeetharan,what you give is list app plan and what I give is Get Instance Process. And did you check my picture content? – George Chen Jan 16 '20 at 08:01
  • check the comment below, I have mentioned he needs to use List to get all instances and get method to get the name – Sajeetharan Jan 16 '20 at 08:09
  • @Sajeetharan,Did you try your get method? Yours is this [one](https://learn.microsoft.com/en-us/rest/api/appservice/appserviceplans/get) and check again what's mine. One is plan get and one is web instance get. If you insist they are same, I have nothing to say. – George Chen Jan 16 '20 at 08:20
  • Thanks for the awnser. I remember trying this out but the values where all nulls. I will give it a try with another account and let you guys know. It seems to be what I am looking for. – FidelCasto Jan 16 '20 at 13:29
  • I actually tested this solution before without success (the environment variable was empty). I investigated and it seems that the account I was using did not have enough rights to view the environment variables. Using a contributor account worked. I will take a look at which authorization would be necessary other than "Contibutor" – FidelCasto Jan 16 '20 at 16:55
  • After further testing, the "Contributor" role is necessary in order to be able to read Environment_Variables properties. Otherwise, the values will be empty in the property. Hope this helps. – FidelCasto Jan 16 '20 at 18:28