Azure
I have two AAD(Azure Active Directory) in my account.
Entities in first AAD: ['Tenant Root Group', 'group A', 'subGroup B', 'Microsoft Partner Network', 'subscription 2']
Entities in second AAD: ['Tenant Root Group', 'subscription 3']
Python
I'm trying to use python azure SDK to get management groups
and subscriptions
per directory
.
The code below can list entities in first directory, but other entities in second directory does not listed as my expectation.
Does anyone know how to get all entities in both directories?
Code
from azure.mgmt.managementgroups import ManagementGroupsAPI
from msrestazure.azure_active_directory import UserPassCredentials
def get_entities(credentials):
mgmt_groups_api = ManagementGroupsAPI(credentials)
entities = mgmt_groups_api.entities.list()
entity_infos = [entity for entity in entities]
entity_names = [entity.display_name for entity in entity_infos]
print(entity_names)
def main():
credentials = UserPassCredentials(
'account',
'password',
)
get_entities(credentials)
if __name__ == '__main__':
main()
Output
['Group A', 'subGroup B', 'subGroup C', 'subscription 1', 'subscription 2']