question

shmhs-6694 avatar image
0 Votes"
shmhs-6694 asked SamaraSoucy-MSFT answered

How to fetch Azure Subscription / Resource Group details by passing only the (VM/SQL) Name

I am looking for an implementation / suggestion or is there exist any REST API that will fetch me , the subscription or the resource group details just by passing the Server name.?
How can this be achieved?

An example : Virtual Machines - Get


But in this above API we are passing multiple parameters. Is there any workaround to pass only the Server name and fetch the Subscription and RG details.


azure-functionsazure-bot-service
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.

1 Answer

SamaraSoucy-MSFT avatar image
0 Votes"
SamaraSoucy-MSFT answered

You can use the generic Resource List endpoint and filter it by things like name and resource type without specifying resource group, but this will still require a subscription ID: https://docs.microsoft.com/en-us/rest/api/resources/resources/list

If you needed to do this without a subscription ID, you would need to loop through the subscriptions available to that user and test each one to find the specific VM. I do understand that this might not be ideal in a case where a login has access to many subscriptions.

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.