通过REST API列表的Azure虚拟机 [英] List Azure Virtual Machines via REST API

查看:210
本文介绍了通过REST API列表的Azure虚拟机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前我正在试图让所有的我有一个Windows Azure订阅编程方式下运行的虚拟机的列表。对于这一点,我试图使用Azure的REST API( https://management.core.windows.net ),而不是使用电源外壳的cmdlet。

I am currently attempting to get a list of all of the Virtual Machines that I have running under a Windows Azure subscription programmatically. For this, I am attempting to use the Azure REST API (https://management.core.windows.net), and not use the power-shell cmdlets.

使用的cmdlet我可以运行'GET-AzureVM,并得到所有的虚拟机与服务名称,名称和状态的列表没有任何修改。问题是,我不能如何通过API列出VM的文档中找到任何地方。

Using the cmdlets I can run 'Get-AzureVM' and get a listing of all of the VM's with ServiceName, Name, and Status without any modifications. The problem is that I cannot find anywhere in the documentation of how to list out the VMs via the API.

我已经通过各个Azure的REST API的看了,但一直没能找到任何东西。对于 VM REST API 文档不显示或提供一个列表功能。

I have looked through the various Azure REST API's but have not been able to find anything. The documentation for VM REST API does not show or provide a list function.

我缺少基本面的地方?

Am I missing the fundamentals somewhere?

// Create the request.
            // https://management.core.windows.net/<subscription-id>/services/hostedservices
            requestUri = new Uri("https://management.core.windows.net/"
                                 + subscriptionId 
                                 + "/services/" 
                                 + operation);

这是我使用什么请求的基础。我能得到的托管服务列表,而不是虚拟机。

This is what I am using for the base of the request. I can get a list of hosted services but not the Virtual Machines.

推荐答案

您需要得到一个列表中的所有云服务(托管服务),然后为每个部署属性。寻找在生产环境中/插槽的部署。然后检查的PersistentVMRole角色类型。

You would need to get a list all the Cloud Services (Hosted Services), and then the deployment properties for each. Look for the deployment in the Production environment/slot. Then check for a role type of "PersistentVMRole".

虚拟机实际上只是一种云服务,具有Web和辅助角色一起。 Windows Azure管理门户网站和PowerShell命令这个抽象客场让事情变得更容易理解和看法。

VMs are really just a type of Cloud Service, along with Web and Worker roles. The Windows Azure management portal and PowerShell cmdlets abstracts this away to make things a little easier to understand and view.

这篇关于通过REST API列表的Azure虚拟机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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