このリンク ( Create azure Automation account using REST api from Java ) で、Runbook を作成するために Automation アカウントを作成する方法について質問しました。自動化アカウントと公開されている Runbook を作成したので、Runbook を実行 (開始) したいと思います。そうするために、私はこのリンク ( https://msdn.microsoft.com/en-us/library/azure/mt163849.aspx ) をたどっていますが、エラーが発生しています:
Server Error</h1></div>
<div id="content">
 <div class="content-container"><fieldset>
 <h2>404 - File or directory not found.</h2>
 <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable
これは Java 関数です。
private static int processPutRequest(URL url, byte[] data, String contentType, String keyStore, String keyStorePassword)
throws UnrecoverableKeyException, KeyManagementException, KeyStoreException, NoSuchAlgorithmException, IOException {
SSLSocketFactory sslFactory = getSSLSocketFactory(keyStore, keyStorePassword);
HttpsURLConnection con = null;
con = (HttpsURLConnection) url.openConnection();
con.setSSLSocketFactory(sslFactory);
con.setDoOutput(true);
con.setRequestMethod("PUT");
con.addRequestProperty("x-ms-version", "2013-08-01");
con.setRequestProperty("Content-Length", String.valueOf(data.length));
con.setRequestProperty("Content-Type", contentType);
DataOutputStream requestStream = new DataOutputStream (con.getOutputStream());
requestStream.write(data);
requestStream.flush();
requestStream.close();
System.out.println(con.getResponseMessage());
InputStream error = ((HttpURLConnection) con).getErrorStream();
BufferedReader br = null;
if (error == null) {
InputStream inputstream = con.getInputStream();
br = new BufferedReader(new InputStreamReader(inputstream));
} else {
br = new BufferedReader(new InputStreamReader(error));
}
String response = "";
String nachricht;
while ((nachricht = br.readLine()) != null){
response += nachricht;
}
System.out.println(response);
return con.getResponseCode();
}
public static void createJobId(String keyStorePath, String keyStorePassword, String subscriptionId)
throws UnrecoverableKeyException, KeyManagementException, KeyStoreException, NoSuchAlgorithmException, IOException
{
String url = String.format("https://management.core.windows.net/%s/cloudServices/OaaSCSI6EGAZU6F6QTCK5XRVT45FKJC6RC7IQIQW3OPR7SVLE4ZPD4IQQQ-East-US/resources/automation/~/automationAccounts/xdtauto/jobs/8c3e715-9b27?api-version=2014-12-08", subscriptionId);
String requestBody = "{ \"properties\":{ \"runbook\":{ \"name\":\"createVM\" } } }";
int createResponseCode = processPutRequest(new URL(url), requestBody.getBytes(), "application/json", keyStorePath, keyStorePassword);
System.out.println("JOB created :: " + createResponseCode);
}