[英]List Azure Virtual Machines via REST API
I am currently attempting to get a list of all of the Virtual Machines that I have running under a Windows Azure subscription programmatically. 我目前正在尝试以编程方式获取我在Windows Azure订阅下运行的所有虚拟机的列表。 For this, I am attempting to use the Azure REST API ( https://management.core.windows.net ), and not use the power-shell cmdlets.
为此,我尝试使用Azure REST API( https://management.core.windows.net ),而不是使用power-shell cmdlet。
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. 使用cmdlet,我可以运行“Get-AzureVM”并获取所有具有ServiceName,Name和Status的VM的列表,而无需任何修改。 The problem is that I cannot find anywhere in the documentation of how to list out the VMs via the API.
问题是我在文档中找不到如何通过API列出VM。
I have looked through the various Azure REST API's but have not been able to find anything. 我查看了各种Azure REST API,但一直无法找到任何内容。 The documentation for VM REST API does not show or provide a list function.
VM REST API的文档未显示或提供列表功能。
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.
我可以获得托管服务的列表,但不能获得虚拟机。
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".
然后检查角色类型“PersistentVMRole”。
VMs are really just a type of Cloud Service, along with Web and Worker roles. 虚拟机实际上只是一种云服务,还有Web和辅助角色。 The Windows Azure management portal and PowerShell cmdlets abstracts this away to make things a little easier to understand and view.
Windows Azure管理门户和PowerShell cmdlet将其抽象化,使事情更容易理解和查看。
Follow these steps for listing VMs: 按照以下步骤列出VM:
You can use Azure node SDK to list out all VMs in your subscription 您可以使用Azure节点SDK列出订阅中的所有VM
computeClient.virtualMachines.listAll(function (err, result)) computeClient.virtualMachines.listAll(function(err,result))
More details on Azure Node SDK here: https://github.com/Azure-Samples/compute-node-manage-vm 有关Azure Node SDK的更多详细信息,请访问: https : //github.com/Azure-Samples/compute-node-manage-vm
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.