英文:
How to retrieve managament groups in hierarchy (managment groups /subscription / resources in each group) using java
问题
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
英文:
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
答案1
得分: 0
请参考MSDOC 使用Azure REST API调用管理组列表来访问Azure。要访问上述API,我们需要以下详细信息:
- 客户端ID
- 客户端密钥
- 租户ID
使用上述凭据,我们可以生成访问令牌以访问Azure中的API。
以下是生成访问令牌的API:
https://login.microsoftonline.com/<your-tenant-id>/oauth2/token
- 使用Postman访问API: *
在下面的API中将生成的令牌用作标头以访问管理组:
https://management.azure.com/providers/Microsoft.Management/managementGroups?api-version=2020-05-01
我已经使用Java和Spring Boot实现了上述场景,按照这个代码进行操作。
输出:
在我的情况下,我只有一个管理组。因此,我会得到一个管理组,如下所示。
英文:
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:
- Client ID
- Client Secret
- Tenant ID
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
- Hit the api using postman: *
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论