none
Management API - Create VM - InvalidXmlRequest - The request body XML was invalid or not correctly specified RRS feed

  • Question

  • Hi,

    I am getting error while creating virtual machine from Azure REST management API. Could someone please point me what wrong I am POSTing in below XML

    ERROR ---

    <Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><Code>InvalidXmlRequest</Code><Message>The request body's XML was invalid or not correctly specified.</Message></Error>

    "  <Deployment xmlns=\"http://schemas.microsoft.com/windowsazure\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">" + 
    "    <Name>SomeName</Name>" + 
    "    <DeploymentSlot>Production</DeploymentSlot>" + 
    "    <Label>SomeLabel</Label>" + 
    "    <RoleList>" + 
    "      <Role>" + 
    "        <RoleName>SomeRoleName</RoleName>" + 
    "        <RoleType>PersistentVMRole</RoleType>" + 
    "        <ConfigurationSets>" + 
    "          <ConfigurationSet i:type=\"WindowsProvisioningConfigurationSet\">" + 
    "            <ConfigurationSetType>WindowsProvisioningConfiguration</ConfigurationSetType>" + 
    "            <ComputerName>SomeCompName</ComputerName>" + 
    "            <AdminPassword>Admin098</AdminPassword>" + 
    "            <EnableAutomaticUpdates>true</EnableAutomaticUpdates>" + 
    "            <ResetPasswordOnFirstLogon>false</ResetPasswordOnFirstLogon>" + 
    "          </ConfigurationSet>" + 
    "          <ConfigurationSet i:type=\"NetworkConfigurationSet\">" + 
    "            <ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>" + 
    "            <InputEndpoints>" + 
    "              <InputEndpoint>" + 
    "                <LocalPort>3389</LocalPort>" + 
    "                <Name>RemoteDesktop</Name>" + 
    "                <Protocol>tcp</Protocol>" + 
    "              </InputEndpoint>" + 
    "            </InputEndpoints>" + 
    "          </ConfigurationSet>" + 
    "        </ConfigurationSets>" + 
    "        <OSVirtualHardDisk>" + 
    "          <DiskName>SomeDiskName-0-20121007173943</DiskName>" + 
    "          <MediaLink>http://portalvhdsrx7q659n2n5j2.blob.core.windows.net/public/myvhd0008980.vhd</MediaLink>" + 
    "          <SourceImageName>MSFT__Win2K8R2SP1-Datacenter-201208.01-en.us-30GB.vhd</SourceImageName>" + 
    "        </OSVirtualHardDisk>" + 
    "        <RoleSize>Small</RoleSize>" + 
    "      </Role>" + 
    "    </RoleList>" + 
    "  </Deployment>"

    I have tried adding admin user name as well to the xml but still get same error.

    Please suggest

    Saturday, April 12, 2014 8:42 AM

Answers

  • Personally, I much prefer to create VMs in Azure using the Azure PowerShell Commands (available through Web Platform installer). They are trivial to use - http://mythoughtsonit.com/2013/01/how-to-create-an-azure-vm-with-powershell-part-14-of-31-31-days-of-servers-in-the-cloud-series/

    HTH - Matt S


    R. Matt Sampson

    Thursday, April 24, 2014 8:29 PM

All replies

  • the format of the request body is:

    <Deployment xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
      <Name>name-of-deployment</Name>
      <DeploymentSlot>deployment-environment</DeploymentSlot>
      <Label>identifier-of-deployment</Label>      
      <RoleList>
        <Role>
          <RoleName>name-of-the-virtual-machine</RoleName>
          <RoleType>PersistentVMRole</RoleType>
          <VMImageName>name-of-vm-image</VMImageName>
          <ConfigurationSets>
            <ConfigurationSet i:type="WindowsProvisioningConfigurationSet">
              <ConfigurationSetType>WindowsProvisioningConfiguration</ConfigurationSetType>
              <ComputerName>name-of-computer</ComputerName>
              <AdminPassword>administrator-password</AdminPassword>
              <EnableAutomaticUpdates>enable-updates</EnableAutomaticUpdates>  
              <TimeZone>time-zone</TimeZone>
              <DomainJoin>
                <Credentials>
                  <Domain>domain-to-join</Domain>
                  <Username>user-name-in-the-domain</Username>
                  <Password>password-for-the-user-name</Password>
                </Credentials>
                <JoinDomain>domain-to-join</JoinDomain>
                <MachineObjectOU>distinguished-name-of-the-ou</MachineObjectOU>
              </DomainJoin>
              <StoredCertificateSettings>
                <CertificateSetting>
                  <StoreLocation>LocalMachine</StoreLocation>
                  <StoreName>name-of-store-on-the-machine</StoreName>
                  <Thumbprint>certificate-thumbprint</Thumbprint>
                </CertificateSetting>
              </StoredCertificateSettings>
              <WinRM>
                <Listeners>
                  <Listener>
                    <Protocol>listener-protocol</Protocol>
                  </Listener>
                  <Listener>
                    <CertificateThumbprint>certificate-thumbprint</CertificateThumbprint>
                    <Protocol>listener-protocol</Protocol>
                  </Listener>
                </Listeners>
              </WinRM>
              <AdminUsername>name-of-administrator-account</AdminUsername>
              <CustomData>base-64-encoded-data</CustomData>
            </ConfigurationSet>
            <ConfigurationSet i:type="LinuxProvisioningConfigurationSet">
              <ConfigurationSetType>LinuxProvisioningConfiguration</ConfigurationSetType>
              <HostName>host-name-for-the-virtual-machine</HostName>
              <UserName>new-user-name</UserName> 
              <UserPassword>password-for-the-new-user</UserPassword> 
              <DisableSshPasswordAuthentication>password-authentication</DisableSshPasswordAuthentication>           
              <SSH>
                <PublicKeys>
                  <PublicKey>
                    <FingerPrint>certificate-fingerprint</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>
              <CustomData>base-64-encoded-data</CustomData>
            </ConfigurationSet>        
            <ConfigurationSet> 
              <ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>
              <InputEndpoints>
                <InputEndpoint>
                  <LoadBalancedEndpointSetName>name-of-load-balanced-set</LoadBalancedEndpointSetName>
                  <LocalPort>local-port-number</LocalPort>
                  <Name>name-of-endpoint</Name>
                  <Port>external-port-number</Port>
                  <LoadBalancerProbe>
                    <Path>path-of-probe</Path>
                    <Port>port-assigned-to-probe</Port>
                    <Protocol>probe-protocol</Protocol>
                    <IntervalInSeconds>interval-of-probe</IntervalInSeconds>
                    <TimeoutInSeconds>timeout-for-probe</TimeoutInSeconds>
                  </LoadBalancerProbe>
                  <Protocol>endpoint-protocol</Protocol>
                  <EnableDirectServerReturn>enable-direct-server-return</EnableDirectServerReturn>
                  <EndpointACL>
                    <Rules>
                      <Rule>
                        <Order>priority-of-the-rule</Order>
                        <Action>permit-rule</Action>
                        <RemoteSubnet>subnet-of-the-rule</RemoteSubnet>
                        <Description>description-of-the-rule</Description>
                      </Rule>
                    </Rules>
                  </EndpointACL>
                </InputEndpoint>
              </InputEndpoints>
              <SubnetNames>
                <SubnetName>name-of-subnet</SubnetName>
              </SubnetNames> 
              <StaticVirtualNetworkIPAddress>ip-address</StaticVirtualNetworkIPAddress>        
            </ConfigurationSet>
          </ConfigurationSets>
          <ResourceExtensionReferences>
            <ResourceExtensionReference>
              <ReferenceName>name-of-reference</ReferenceName>
              <Publisher>name-of-publisher</Publisher>
              <Name>name-of-extension</Name>
              <Version>version-of-extension</Version>
              <ResourceExtensionParameterValues>
                <ResourceExtensionParameterValue>
                  <Key>name-of-parameter-key</Key>
                  <Value>parameter-value</Value>
                  <Type>type-of-parameter</Type>
                </ResourceExtensionParameterValue>
              </ResourceExtensionParameterValues>
              <State>state-of-resource</State>
            </ResourceExtensionReference>
          </ResourceExtensionReferences>
          <AvailabilitySetName>name-of-availability-set</AvailabilitySetName>
          <DataVirtualHardDisks>
            <DataVirtualHardDisk>
              <HostCaching>caching-mode</HostCaching> 
              <DiskLabel>label-of-data-disk</DiskLabel>            
              <DiskName>name-of-disk</DiskName>
              <Lun>logical-unit-number</Lun>
              <LogicalDiskSizeInGB>size-in-gb-of-data-disk</LogicalDiskSizeInGB>            
              <MediaLink>path-to-vhd</MediaLink>
            </DataVirtualHardDisk>
          </DataVirtualHardDisks>
          <OSVirtualHardDisk>
            <HostCaching>caching-mode</HostCaching>    
            <DiskLabel>label-of-operating-system-disk</DiskLabel>
            <DiskName>name-of-disk</DiskName>                    
            <MediaLink>path-to-vhd</MediaLink>
            <SourceImageName>name-of-source-image</SourceImageName>
          </OSVirtualHardDisk>      
          <RoleSize>size-of-virtual-machine</RoleSize>
          <ProvisionGuestAgent>install-an-agent</ProvisionGuestAgent>
        </Role>
      </RoleList>
      <VirtualNetworkName>name-of-virtual-network</VirtualNetworkName>
      <Dns>
        <DnsServers>
          <DnsServer>
            <Name>dns-name</Name>
            <Address>dns-ip-address</Address>
          </DnsServer>
        </DnsServers>
      </Dns>
    </Deployment>

    for more details please see this link.

    hope this helps!

    Saturday, April 12, 2014 8:57 AM
  • Hi,

    I am referring to same link. Can you observe any discrepancy in the xml I have created?

    Saturday, April 12, 2014 9:12 AM
  • Personally, I much prefer to create VMs in Azure using the Azure PowerShell Commands (available through Web Platform installer). They are trivial to use - http://mythoughtsonit.com/2013/01/how-to-create-an-azure-vm-with-powershell-part-14-of-31-31-days-of-servers-in-the-cloud-series/

    HTH - Matt S


    R. Matt Sampson

    Thursday, April 24, 2014 8:29 PM