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

shmhs 1 Reputation point
2021-11-08T11:16:13.973+00:00

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 AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
742 questions
Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,209 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Samara Soucy - MSFT 5,051 Reputation points
    2021-11-10T00:07:32.22+00:00

    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://learn.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.

    0 comments No comments