2012-07-17 36 views
1

我正在编写一个使用Azure Service Management API在Azure上创建新VM部署的小型Java客户端。 我不断收到坏的请求的响应这样的:使用Azure Service Management API创建VM的BadRequest

17/07/2012 18:26:37 com.sun.jersey.api.client.filter.LoggingFilter log 
INFO: 1 * Client out-bound request 
1 > POST https://management.core.windows.net/my-subscription-id/services/hostedservices/myservice/deployments 
1 > x-ms-version: 2012-03-01 
1 > Content-Type: application/xml 
<Deployment xmlns="http://schemas.microsoft.com/windowsazure"> 
    <Name>mynametest</Name> 
    <DeploymentSlot>Staging</DeploymentSlot> 
    <Label>mynamelabel</Label> 
    <RoleList> 
    <Role> 
     <RoleName>mynamerolename</RoleName> 
     <RoleType>PersistentVMRole</RoleType> 
     <ConfigurationSets> 
     <ConfigurationSet> 
      <ConfigurationSetType>LinuxProvisioningConfiguration</ConfigurationSetType> 
      <HostName>myunamehost</HostName> 
      <UserName>myname</UserName> 
      <UserPassword>password</UserPassword> 
     </ConfigurationSet> 
     </ConfigurationSets> 
     <OSVirtualHardDisk> 
     <SourceImageName>CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd</SourceImageName> 
     </OSVirtualHardDisk> 
    </Role> 
    </RoleList> 
</Deployment> 

17/07/2012 18:26:38 com.sun.jersey.api.client.filter.LoggingFilter log 
INFO: 1 * Client in-bound response 
1 < 400 
1 < x-ms-request-id: c622e270c5934cb493f76790b7d2c49d 
1 < Date: Tue, 17 Jul 2012 15:27:26 GMT 
1 < Content-Length: 275 
1 < Content-Type: application/xml; charset=utf-8 
1 < Server: 6.0.6002.18488 (rd_rdfe_stable.120710-1331) Microsoft-HTTPAPI/2.0 
1 < 
<Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Code>BadRequest</Code><Message>No target URI is specified for the image CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd.</Message></Error> 

它看起来像从蔚蓝的文档是马车:http://msdn.microsoft.com/en-us/library/windowsazure/jj157194

有人已经尝试过这个?我不明白'target URI'是什么意思... 图像名称取自天蓝色图像的公共图库。

任何帮助,任何帮助,将不胜感激。 谢谢

回答

1

你的XML有一些不好的配置,即DeploymentSlot等,我也相信错误的到来,因为你没有在你的XML中所有必需的设置。以下是工作一个用于Linux展厅形象:

<Deployment xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> 
<Name>mydeploymentname</Name> 
<Label>mydeploymentlabel</Label>  
<RoleList> 
    <Role> 
    <RoleName>mylinuxvm2012</RoleName> 
    <RoleType>PersistentVMRole</RoleType>  
    <ConfigurationSets> 
     <ConfigurationSet> 
      <ConfigurationSetType>LinuxProvisioningConfiguration<ConfigurationSetType> 
      <HostName>host-name-for-the-vm</HostName> 
      <UserName>new-user-name</UserName> 
      <UserPassword>password-for-the-new-user</UserPassword> 
      <DisableSshPasswordAuthentication>true|false</DisableSshPasswordAuthentication>   
      <SSH> 
       <PublicKeys> 
        <PublicKey> 
         <FingerPrint>******add_here******</FingerPrint> 
         <Path>****SSH-public-key-storage-location**********</Path>  
        </PublicKey> 
       </PublicKeys> 
       <KeyPairs> 
        <KeyPair> 
         <FingerPrint>************certificate-fingerprint*************</FinguerPrint> 
         <Path>*************SSH-public-key-storage-location*************</Path> 
        </KeyPair> 
       </KeyPairs> 
      </SSH> 
     </ConfigurationSet> 
    <OSVirtualHardDisk> 
     <HostCaching>ReadWrite</HostCaching>  
     <DiskLabel>myosdisklabel</DiskLabel> 
     <DiskName>myazurelinuxvm</DiskName>      
     <MediaLink>https://_yourstoragename_.blob.core.windows.net/vhds/_your_VHD_NAME_.vhd</MediaLink> 
     <SourceImageName>CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd</SourceImageName> 
    </OSVirtualHardDisk>  
    <RoleSize>_ExtraSmall|Small|Medium|Large|ExtraLarge_</RoleSize>  
    </Role> 
</RoleList> 

+0

谢谢!我缺少的元素是元素。这实际上是这个目标URI我得到的错误。奇怪的是,天蓝色的文档说,这个元素是不需要的... – 2012-07-18 07:16:56

+0

我很高兴你的问题得到解决。感谢您将其标记为答案。 – AvkashChauhan 2012-07-19 22:59:49

+0

实际上'当SourceImageName'出现时'MediaLink'是必需的。 http://msdn.microsoft.com/en-us/library/windowsazure/jj157194.aspx#OSVirtualHardDisk查看'SourceImageName'的文档。 – 2013-10-31 00:13:25

相关问题