如何使用Java API获取Azure VM列表(非经典/资源托管) [英] How to get list of Azure VMs (non-classic/Resource Managed) using Java API

查看:166
本文介绍了如何使用Java API获取Azure VM列表(非经典/资源托管)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用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.

推荐答案

为什么我们需要租户ID,客户ID和客户密钥来创建 'com.microsoft.azure.management.compute.ComputeManagementClient' 对象?

Why we need tenant id, client id and client key to create 'com.microsoft.azure.management.compute.ComputeManagementClient' object?

在后台,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 IdClient 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.

可以使用订阅ID和Azure门户凭据来完成此操作吗? azure-mgmt-compute项目随附的样本需要这些租户ID, 客户ID,因为我们在创建VM时不需要这些详细信息 (选择资源管理器)在Azure Portal上.

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.

如果您注意到,则首先需要使用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列表(非经典/资源托管)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆