我们正在尝试使用 Azure 公开的 REST API 通过 Java 中的 HTTPClient 创建虚拟机。我们正在使用以下请求 URL 和 XML,但我们收到“错误请求”响应。
https://management.core.windows.net/ {subscription-id}/services/hostedservices/{existing hoster service name}/deployments
<Deployment xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Name>TestVMAnandP</Name>
<Label>bXl2bQ==</Label>
<RoleList>
<Role>
<RoleName>TestVMAnandP</RoleName>
<RoleType>PersistentVMRole</RoleType>
<ConfigurationSets>
<ConfigurationSet>
<ConfigurationSetType>LinuxProvisioningConfiguration</ConfigurationSetType>
<HostName>TestVMAnandP</HostName>
<UserName>root</UserName>
<UserPassword>test</UserPassword>
</ConfigurationSet>
</ConfigurationSets>
<DataVirtualHardDisks>
<DataVirtualHardDisk>
<Lun>10</Lun>
<LogicalDiskSizeInGB>50</LogicalDiskSizeInGB>
</DataVirtualHardDisk>
</DataVirtualHardDisks>
<OSVirtualHardDisk>
<SourceImageName>srini2-srini2-2012-08-23.vhd</SourceImageName>
<MediaLink>http://sriniteststore.blob.core.windows.net/vhds/srini2-srini2-2012-08-23.vhd</MediaLink>
</OSVirtualHardDisk>
<RoleSize>ExtraSmall</RoleSize>
</Role>
</RoleList>
<VirtualNetworkName>MyNetwork</VirtualNetworkName>
</Deployment>
如果我们尝试在 URL 中提供与 vm 名称相同的服务名称,则会收到 404 错误。我们已经尝试了网络中给出的大多数示例,并替换了值,但一切都给了我们 400 错误。如果我们能得到一些帮助,那就太好了。
错误:
我得到两种不同的错误:
Error 1 : When i use new <service-name> inside the below URL .management.core.windows.net/<subscription-id>/services/hostedservices/<service-name>/deployments/ ------------------------------------------------------------------- Response message--->Not Found---404
java.io.FileNotFoundException: management.core.windows.net/84cc18f5-5bdd-4c95-9d69-862c12c53507/services/hostedservices/anand/deployments
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
Caused by: java.io.FileNotFoundException: management.core.windows.net/84cc18f5-5bdd-4c95-9d69-862c12c53507/services/hostedservices/anand/deployments
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
Error 2 : when i use an existing available <service-name> in the below URL management.core.windows.net/<subscription-id>/services/hostedservices/<service-name>/deployments/
Response message--->Bad Request---400
java.io.IOException: Server returned HTTP response code: 400 for URL: management.core.windows.net/84cc18f5-5bdd-4c95-9d69-862c12c53507/services/hostedservices/azurecogservice/deployments
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: management.core.windows.net/84cc18f5-5bdd-4c95-9d69-862c12c53507/services/hostedservices/azurecogservice/deployments
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
---------------------有效的 XML--------------- ----------------------------------
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Deployment xmlns="http://schemas.microsoft.com/windowsazure">
<Name>190bed4a</Name>
<DeploymentSlot>Production</DeploymentSlot>
<Label>190bed4a</Label>
<RoleList>
<Role>
<RoleName>SuseOpenVm_rolec8fc</RoleName>
<RoleType>PersistentVMRole</RoleType>
<ConfigurationSets>
<ConfigurationSet>
<ConfigurationSetType>LinuxProvisioningConfiguration
</ConfigurationSetType>
<HostName>SuseOpenVm_rolec8fc</HostName>
<UserName>anandsrinivasan</UserName>
<UserPassword>Cloud360</UserPassword>
<DisableSshPasswordAuthentication>false</DisableSshPasswordAuthentication>
</ConfigurationSet>
<ConfigurationSet>
<ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>
<DisableSshPasswordAuthentication>false</DisableSshPasswordAuthentication>
<InputEndpoints>
<InputEndpoint>
<LocalPort>22</LocalPort>
<Name>SSH</Name>
<Port>22</Port>
<Protocol>TCP</Protocol>
</InputEndpoint>
</InputEndpoints>
</ConfigurationSet>
</ConfigurationSets>
<OSVirtualHardDisk>
<MediaLink>https://portalvhdsvf842yxvkhbg4.blob.core.windows.net/vhds/190bed4a.vhd</MediaLink>
<SourceImageName>SUSE__openSUSE-12-1-20120603-en-us-30GB.vhd</SourceImageName>
</OSVirtualHardDisk>
<RoleSize>Small</RoleSize>
</Role>
</RoleList>
<VirtualNetworkName>anand360NW</VirtualNetworkName>
</Deployment>