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?
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
On
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.
For this kind of thing you should you Azure Resource Graph, which is simply
There's also an REST API on place to be consumed by various SDKs including Python
Hope it will helps :)