String cloudServiceDeployment = "imagevmtest";
url = String.format("https://management.core.windows.net/%s/services/hostedservices/%s/deployments", subscriptionId, cloudServiceDeployment);
String requestBody2 = "<?xml version=\"1.0\" encoding=\"utf-8\"?><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://2xportalvhds7jsf9ncknn4s.blob.core.windows.net/vhds/imagevmtest-imagevmtest-2016-11-10.vhd</MediaLink><SourceImageName>imagevmtest-imagevmtest-2016-11-10.vhd</SourceImageName></OSVirtualHardDisk><RoleSize>Small</RoleSize></Role></RoleList><VirtualNetworkName>anand360NW</VirtualNetworkName></Deployment>";
int deployResponseCode = processPostRequest(new URL(url),requestBody2.getBytes(), "application/xml", keyStorePath, keyStorePassword);
System.out.println(deployResponseCode);
Ich verwende den obigen Code und versuche, eine virtuelle Maschine in meinem Azure zu erstellen. Aber immer noch Fehler 400. Können Sie mir helfen, eine VM in meinem Azure-Konto über REST API zu erstellen?Erstellen der VM-Bereitstellung Azure-REST-API
Ich möchte Sie fragen, was ist der Zweck der Verwendung der Raw-REST-API zum Erstellen von Azure-Ressourcen? Hast du einige Alternativen ausprobiert? –
@MilanNankov Ich plane etwas, mit dem Benutzer vm auf dem Azure automatisch erstellen können, sobald sie ein Konto unter meiner Website erstellt haben. Was sind die Alternativen? Können Sie einige Schritte bereitstellen? Danke –