I'm building an application and I need to retrieve all management groups in a hierarchical style like the subscription IDs and that resource informations .
I looked up in the SDK for java :(https://github.com/Azure/azure-sdk-for-java)
but can't find anything related with my topic
I went through tones of documentations but still didn't find any significant class that can help
Refer to MSDOC to access the management group list from azure by using azure REST Api call for the list management api.
To access the above api we should have the following details:
With the help of above credentials, we can generate access token to access the api’s in azure.
Below is the API to generate the access token.
https://login.microsoftonline.com/<your-tenant-id>/oauth2/token
Use the generated token as header in the below api to access management groups:
https://management.azure.com/providers/Microsoft.Management/managementGroups?api-version=2020-05-01
I have implemented the above scenario using java and spring boot by following the code.
Output:
In my case, I have only one management groups. So, I'm getting one management group as shown below.