问题描述
如何使用Java API获取使用资源管理器创建的VM(非经典)VM列表?为什么我们需要租户ID,客户端ID和客户端密钥来创建"com.microsoft.azure.management.compute.ComputeManagementClient"对象?
How to get list of VMs (non-classic) using Java API, which are created using resource Manager? Why we need tenant id, client id and client key to create 'com.microsoft.azure.management.compute.ComputeManagementClient' object?
可以使用订阅ID和Azure门户凭据来完成此操作吗?与azure-mgmt-compute项目一起提供的示例需要这些租户ID,客户端ID,因为在Azure门户上创建VM(选择资源管理器)时我们不需要这些详细信息.
Can it be done using subscription id and Azure Portal credentials?Sample provided with azure-mgmt-compute project needs these tenant id, client id where as we don't need these details when we create VM (selecting Resource Manager) on Azure Portal.
推荐答案
在后台,com.microsoft.azure.management.compute.ComputeManagementClient
使用Azure Resource Manager (ARM) REST API
来执行与虚拟机相关的操作. ARM API
使用Azure Active Directory (AD)
进行身份验证和授权.为了将Azure AD
用于此目的,您需要在Azure AD
中创建一个应用程序,并授予该应用程序执行Azure Service Management API
的权限.您只需要Tenant Id
,Client Id
等即可.因此,用户通过允许将应用程序安装在其Azure AD
中来使用您的应用程序. Tenant Id
是应用程序在用户的Azure AD中的唯一ID. Client Id
是您的应用程序的唯一ID.
Behind the scenes, com.microsoft.azure.management.compute.ComputeManagementClient
consumes Azure Resource Manager (ARM) REST API
for performing Virtual Machines related operations. ARM API
makes use of Azure Active Directory (AD)
for authentication and authorization. In order to use Azure AD
for this purpose, you would need to create an application in your Azure AD
and grant that application permission to execute Azure Service Management API
. You would need Tenant Id
, Client Id
and other things for that purpose only. So a user uses your application by allowing the application to be installed in their Azure AD
. Tenant Id
is the unique id of your application in your user's Azure AD. Client Id
is the unique id of your application.
一旦一切都正确设置,就可以使用库用户根据其Azure AD进行身份验证.作为身份验证/授权流程的一部分,用户获得一个令牌,并且该库利用此令牌对ARM API进行身份验证的请求,以管理虚拟机.
Once everything's been setup properly, in order to use the library user is authenticated against their Azure AD. As a part of authentication/authorization flow, user gets a token and this library makes use of this token to make authenticated request against ARM API to manage Virtual Machines.
如果您注意到,则首先需要使用Microsoft帐户或Work/School帐户登录Azure门户.门户软件会在登录过程中获取令牌.之后,它利用租户ID,客户端ID和此令牌执行所有操作.因此,从本质上讲,它在做相同的事情,但是对您不可见.
If you notice, you would first need to login into Azure Portal using your Microsoft account or Work/School account. Portal software fetches the token as a part of the login process. After that it makes use of tenant id, client id and this token to perform all operations. So essentially it is doing the same thing however it is not visible to you.
这篇关于如何使用Java API获取Azure VM列表(非经典/资源托管)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!