How to retrieve managament groups in hierarchy (managment groups /subscription / resources in each group) using java

huangapple go评论50阅读模式
英文:

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 How to retrieve managament groups in hierarchy (managment groups /subscription / resources in each group) using javahttps://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 How to retrieve managament groups in hierarchy (managment groups /subscription / resources in each group) using javahttps://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,我们需要以下详细信息:

  1. 客户端ID
  2. 客户端密钥
  3. 租户ID

使用上述凭据,我们可以生成访问令牌以访问Azure中的API。

以下是生成访问令牌的API:

https://login.microsoftonline.com/<your-tenant-id>/oauth2/token

  • 使用Postman访问API: *

How to retrieve managament groups in hierarchy (managment groups /subscription / resources in each group) using java

在下面的API中将生成的令牌用作标头以访问管理组:

https://management.azure.com/providers/Microsoft.Management/managementGroups?api-version=2020-05-01

How to retrieve managament groups in hierarchy (managment groups /subscription / resources in each group) using java

我已经使用Java和Spring Boot实现了上述场景,按照这个代码进行操作。

输出:

在我的情况下,我只有一个管理组。因此,我会得到一个管理组,如下所示。

How to retrieve managament groups in hierarchy (managment groups /subscription / resources in each group) using java

英文:

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:

  1. Client ID
  2. Client Secret
  3. 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/&lt;your-tenant-id&gt;/oauth2/token

  • Hit the api using postman: *

How to retrieve managament groups in hierarchy (managment groups /subscription / resources in each group) using java

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

How to retrieve managament groups in hierarchy (managment groups /subscription / resources in each group) using java

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.
How to retrieve managament groups in hierarchy (managment groups /subscription / resources in each group) using java

huangapple
  • 本文由 发表于 2023年2月14日 20:41:31
  • 转载请务必保留本文链接:https://go.coder-hub.com/75447993.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定