BadRequest使用Azure Service Management API创建虚拟机 [英] BadRequest using Azure Service Management API to create VM

查看:41
本文介绍了BadRequest使用Azure Service Management API创建虚拟机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个小型Java客户端,该客户端使用Azure服务管理API在Azure上创建新的VM部署.我不断收到这样的错误请求响应:

  2012年7月17日18:26:37 com.sun.jersey.api.client.filter.LoggingFilter日志INFO:1 *客户端出站请求1>开机自检https://management.core.windows.net/my-subscription-id/services/hostedservices/myservice/deployments1>x-ms-version:2012-03-011>内容类型:application/xml<部署xmlns ="http://schemas.microsoft.com/windowsazure"><名称> mynametest</名称>< DeploymentSlot>登台</DeploymentSlot><标签> mynamelabel</标签><角色列表><角色><角色名称> myname角色名称</角色名称>< RoleType> PersistentVMRole</RoleType>< ConfigurationSets>< ConfigurationSet>< ConfigurationSetType> LinuxProvisioningConfiguration</ConfigurationSetType>< HostName> myunamehost</HostName>< UserName> myname</UserName>< UserPassword>密码</UserPassword></ConfigurationSet></ConfigurationSets>< OSVirtualHardDisk>< SourceImageName> CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd</SourceImageName></OSVirtualHardDisk></角色></角色列表></部署>17/07/2012 18:26:38 com.sun.jersey.api.client.filter.LoggingFilter日志INFO:1 *客户端入站响应1<4001<x-ms-request-id:c622e270c5934cb493f76790b7d2c49d1<日期:2012年7月17日,星期二,格林尼治标准时间1<内容长度:2751<内容类型:application/xml;字符集= utf-81<服务器:6.0.6002.18488(rd_rdfe_stable.120710-1331)Microsoft-HTTPAPI/2.01<<错误xmlns ="http://schemas.microsoft.com/windowsazure" xmlns:i ="http://www.w3.org/2001/XMLSchema-instance">< Code> BadRequest</Code><消息>未为图像CANONICAL__Canonical-Ubuntu-12-04-amd64-server-20120528.1.3-en-us-30GB.vhd指定目标URI. 

azure的文档似乎有问题: http://msdn.microsoft.com/en-us/library/windowsazure/jj157194

有人曾经尝试过吗?我不明白目标URI"是什么意思...图片名称取自天蓝色的公共图片库.

任何帮助,任何帮助,我们将不胜感激.谢谢

解决方案

您的xml配置不正确,即DeploymentSlot等,我也认为错误即将到来,因为您的XML中没有所有必需的设置.以下是适用于Linux Gallery映像的工作映像:

 <部署xmlns ="http://schemas.microsoft.com/windowsazure" xmlns:i ="http://www.w3.org/2001/XMLSchema-instance"><名称> mydeploymentname</名称><标签> mydeploymentlabel</标签><角色列表><角色><角色名称> mylinuxvm2012</角色名称>< RoleType> PersistentVMRole</RoleType>< ConfigurationSets>< ConfigurationSet>< ConfigurationSetType> LinuxProvisioningConfiguration< ConfigurationSetType><主机名>虚拟机的主机名</HostName>< UserName>新用户名</UserName>< UserPassword>新用户密码</UserPassword>< DisableSshPasswordAuthentication> true | false</DisableSshPasswordAuthentication>< SSH><公共密钥>< PublicKey>< FingerPrint> ****** add_here ******</FingerPrint>< Path> **** SSH-public-key-storage-location ************</Path></PublicKey></PublicKeys>< KeyPairs>< KeyPair><指纹> ************证书指纹*************</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></角色></角色列表> 

i am writing a small java client that uses the Azure Service Management API to create a new VM Deployment on Azure. i keep getting bad requests responses like these:

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>

it looks like the docs from azure are buggy: http://msdn.microsoft.com/en-us/library/windowsazure/jj157194

anyone has tried this before? i dont understand what does 'target URI' mean... the image name is taken from the public gallery of images on azure.

any help, any help at all, will be highly appreciated. thanks

解决方案

Your xml have some bad configuration i.e. DeploymentSlot etc and I also believe the error is coming because you do not have all required settings in your XML. Following is the working one for Linux Gallery image:

<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>

这篇关于BadRequest使用Azure Service Management API创建虚拟机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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