我正在研究使用 Windows Azure REST API 在 Windows Azure 环境中创建虚拟机。查看 Windows Azure REST API 参考,我看到应该发出 POST 请求的 URL 是:
https://management.core.windows.net/<subscription-id>/services/hostedservices/<cloudservice-name>/deployments/<deployment-name>/roles
我在这里的困惑是关于<cloudservice-name>
and的需要<deployment-name>
。事实上,如果我直接登录我的 Windows Azure 订阅门户并通过菜单创建虚拟机,我不必指定云服务名称或部署名称。我所做的只是为 VM 选择一个映像(centos、ubuntu、windows 等),为 VM 选择一个风格(xsmall、small、large 等),然后单击“Create”,VM 会在几分钟内创建.
鉴于我可以通过这种方式创建 VM,我无法理解为什么我必须在 REST API curl 调用中传递 a<cloudservice-name>
和 a<deployment-name>
参数以及将哪些值传递给这些参数。事实上,我的订阅中没有部署,我也不打算拥有一个。我想要的只是创建一个我可以使用的虚拟机。
我是否可以跳过这些参数并仍然能够在我的 Azure 订阅中创建虚拟机?即仅通过传递<subscription-id>
?
以前使用过 Windows Azure REST API 的人或具有 Windows Azure 专业知识的人能否对此有所了解并帮助澄清?
2013 年 7 月 31 日星期三更新:再次感谢您对我的问题的反馈。我想更新一下,我能够使用 REST API 调用最终创建虚拟机。但奇怪的是,成功创建虚拟机只成功了一次。随后,当我尝试创建具有不同名称的 VM 时,它给出了一个错误,例如“暂存部署被阻止”。因此,出于理智的考虑,我继续删除了现有的 VM,并进行了一些帐户清理。我尝试了 POST 操作以再次创建 VM,现在发生的情况是 POST 响应返回正常并显示 202 Accepted 消息,但尽管如此,我没有看到在我的 Azure 帐户中创建 VM。我不知道从哪里以及如何开始解决这个问题,因为我没有收到错误,
我在为创建 VM 而发布的整个 XML 请求正文下方发布:
<Deployment xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Name>Staging</Name>
<DeploymentSlot>Staging</DeploymentSlot>
<Label>stk_curl_label_1</Label>
<RoleList>
<Role>
<RoleName>stk_curl_role_1</RoleName>
<RoleType>PersistentVMRole</RoleType>
<ConfigurationSets>
<ConfigurationSet>
<ConfigurationSetType>WindowsProvisioningConfiguration</ConfigurationSetType>
<ComputerName>stkVm1</ComputerName>
<AdminPassword>Password123</AdminPassword>
<EnableAutomaticUpdates>false</EnableAutomaticUpdates>
</ConfigurationSet>
</ConfigurationSets>
<OSVirtualHardDisk>
<HostCaching>ReadWrite</HostCaching>
<DiskLabel>Visual studio ultimate</DiskLabel>
<DiskName>stk_disk_1</DiskName>
<MediaLink>http://stk11.blob.core.windows.net/communityimages/visual_studio_ultimate.vhd</MediaLink>
<SourceImageName>03f55de797f546a1b29d1b8d66be687a__Visual-Studio-2013-Preview-Ultimate-12.0.20617.1</SourceImageName>
</OSVirtualHardDisk>
<RoleSize>ExtraSmall</RoleSize>
</Role>
</RoleList>
</Deployment>
我粘贴在我为 curl 调用获得的响应的尾部下方:
> User-Agent: curl/7.15.5 (x86_64-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5
> Host: management.core.windows.net
> Accept: */*
> x-ms-version: 2012-03-01
> Content-Type: application/xml
> Content-Length: 1236
> Expect: 100-continue
>
* SSLv3, TLS handshake, Hello request (0):
SSLv3, TLS handshake, Client hello (1):
SSLv3, TLS handshake, Server hello (2):
SSLv3, TLS handshake, CERT (11):
SSLv3, TLS handshake, Request CERT (13):
SSLv3, TLS handshake, Server finished (14):
SSLv3, TLS handshake, CERT (11):
SSLv3, TLS handshake, Client key exchange (16):
SSLv3, TLS handshake, CERT verify (15):
SSLv3, TLS change cipher, Client hello (1):
SSLv3, TLS handshake, Finished (20):
SSLv3, TLS change cipher, Client hello (1):
SSLv3, TLS handshake, Finished (20):
HTTP/1.1 100 Continue
HTTP/1.1 202 Accepted
< Cache-Control: no-cache
< Content-Length: 0
< Server: 33.0.6198.68 (rd_rdfe_stable.130710-0833) Microsoft-HTTPAPI/2.0
< x-ms-servedbyregion: ussouth
< x-ms-request-id: b2f3dd01319049a5a6728bbdbcde6c4a
< Date: Wed, 31 Jul 2013 17:26:54 GMT
* Connection #0 to host management.core.windows.net left intact
* Closing connection #0
* SSLv3, TLS alert, Client hello (1):
如您所见,这是一个“202 Accepted”响应。但正如我之前提到的,尽管如此,当我检查我的 Azure 帐户时,我没有看到正在创建 VM。
希望有任何专家的见解/想法,了解如何找出它为什么没有按预期工作的根本原因?