0

I am trying to list all the Azure subscriptions under a specific management group by using Azure Python SDK. But I couldn't find any function which retrieves them.

Do you have any idea?

MoonHorse
  • 1,966
  • 2
  • 24
  • 46

2 Answers2

0

For this kind of thing you should you Azure Resource Graph, which is simply

Azure Resource Graph is an Azure service designed to extend Azure Resource Management by providing efficient and performant resource exploration with the ability to query at scale across a given set of subscriptions so that you can effectively govern your environment.

There's also an REST API on place to be consumed by various SDKs including Python

Hope it will helps :)

catJam
  • 224
  • 1
  • 10
0
from azure.mgmt.subscription import SubscriptionClient

credential = DefaultAzureCredential()    
subscription_client = SubscriptionClient(credential)
subscription_list = subscription_client.subscriptions.list()
result = [item for item in subscription_list]
for item in result:
    print("The subscription that will be checked: ", item.display_name)

With the SubscriptionClient class, I have achieved to list the subscriptions that an account has access.

MoonHorse
  • 1,966
  • 2
  • 24
  • 46