Create Virtual Machine Deployment Azure REST API
<pre><code>        String cloudServiceDeployment = "imagevmtest";
        url = String.format("https://management.core.windows.net/%s/services/hostedservices/%s/deployments", subscriptionId, cloudServiceDeployment);
        String requestBody2 = "&lt;?xml version=\"1.0\" encoding=\"utf-8\"?&gt;&lt;Deployment xmlns=\"http://schemas.microsoft.com/windowsazure\"&gt;&lt;Name&gt;190bed4a&lt;/Name&gt;&lt;DeploymentSlot&gt;Production&lt;/DeploymentSlot&gt;&lt;Label&gt;190bed4a&lt;/Label&gt;&lt;RoleList&gt;&lt;Role&gt;&lt;RoleName&gt;SuseOpenVm_rolec8fc&lt;/RoleName&gt;&lt;RoleType&gt;PersistentVMRole&lt;/RoleType&gt;&lt;ConfigurationSets&gt;&lt;ConfigurationSet&gt;&lt;ConfigurationSetType&gt;LinuxProvisioningConfiguration&lt;/ConfigurationSetType&gt;&lt;HostName&gt;SuseOpenVm_rolec8fc&lt;/HostName&gt;&lt;UserName&gt;anandsrinivasan&lt;/UserName&gt;&lt;UserPassword&gt;Cloud360&lt;/UserPassword&gt;&lt;DisableSshPasswordAuthentication&gt;false&lt;/DisableSshPasswordAuthentication&gt;&lt;/ConfigurationSet&gt;&lt;ConfigurationSet&gt;&lt;ConfigurationSetType&gt;NetworkConfiguration&lt;/ConfigurationSetType&gt;&lt;DisableSshPasswordAuthentication&gt;false&lt;/DisableSshPasswordAuthentication&gt;&lt;InputEndpoints&gt;&lt;InputEndpoint&gt;&lt;LocalPort&gt;22&lt;/LocalPort&gt;&lt;Name&gt;SSH&lt;/Name&gt;&lt;Port&gt;22&lt;/Port&gt;&lt;Protocol&gt;TCP&lt;/Protocol&gt;&lt;/InputEndpoint&gt;&lt;/InputEndpoints&gt;&lt;/ConfigurationSet&gt;&lt;/ConfigurationSets&gt;&lt;OSVirtualHardDisk&gt;&lt;MediaLink&gt;https://2xportalvhds7jsf9ncknn4s.blob.core.windows.net/vhds/imagevmtest-imagevmtest-2016-11-10.vhd&lt;/MediaLink&gt;&lt;SourceImageName&gt;imagevmtest-imagevmtest-2016-11-10.vhd&lt;/SourceImageName&gt;&lt;/OSVirtualHardDisk&gt;&lt;RoleSize&gt;Small&lt;/RoleSize&gt;&lt;/Role&gt;&lt;/RoleList&gt;&lt;VirtualNetworkName&gt;anand360NW&lt;/VirtualNetworkName&gt;&lt;/Deployment&gt;";

        int deployResponseCode = processPostRequest(new URL(url),requestBody2.getBytes(), "application/xml", keyStorePath, keyStorePassword);
        System.out.println(deployResponseCode);
</code></pre>

<p>I am using the above code and trying to create a virtual machine in my  Azure. But still getting error 400. Can you guys guide me how to create a vm in my Azure account via REST API?</p>