Azure REST API to fetch all Subscription names in tenant and all Resource groups in a given subscription

MS Techie 2,751 Reputation points
2021-11-04T08:03:42.437+00:00

1) Do we have a REST API to fetch all the subscriptions in a given tenant. Please give an example of the same.

2) Given a azure subscription, do we have a REST API to fetch all resource groups in a given subscription.

Please share any example links for the above

Azure Cost Management
Azure Cost Management
A Microsoft offering that enables tracking of cloud usage and expenditures for Azure and other cloud providers.
3,577 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,916 Reputation points
    2021-11-04T20:38:32.733+00:00

    Hello @MS Techie

    there is a way described how to get all subscriptions for a tenant.

    Subscriptions - List
    https://learn.microsoft.com/en-us/rest/api/resources/subscriptions/list

    The azure.Subscriptions.List() will just list the subscriptions in one tenant. Even if you use common parameter, actually it will also specify a default tenant, not all the tenant.

    Azure REST API reference
    https://learn.microsoft.com/en-us/rest/api/azure/

    Hope this helps with your query!

    ------------

    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.