I am trying to create a pool using RESTful API. I know there is C# library for batch service, but in order to programmingly specify the subnet id, I have to use RESTful API to create it which I read about in this MSDN article.
My Post URI follow the format
https://{account-name}.{region-id}.batch.azure.com/pools?api-version={api-version}
Code
using (var client = new WebClient())
{
client.Headers[HttpRequestHeader.ContentType] = "application/json";
client.Headers[HttpRequestHeader.Authorization] = "SharedKey <AccountName>:<Signature>";
client.Headers[HttpRequestHeader.Date] = DateTime.UtcNow.ToString();
try
{
result = client.UploadString(baseURI, "POST", json);
}
catch(Exception ex)
{
Console.WriteLine(ex.StackTrace);
}
Console.WriteLine(result);
}
The json I sent: {"Id":"DotNetPool","vmSize":"small"}
at System.Net.WebClient.UploadDataInternal(Uri address, String method, Byte[] data, WebRequest& request) at System.Net.WebClient.UploadString(Uri address, String method, String data)
at System.Net.WebClient.UploadString(String address, String method, String data) at batchServer.Program.createPool(String poolId, String machineSize, String osFamily, String subnetId, String commandLine, Int32 numberOfMachine, List`1 resourceFiles) in C:\Users\fange\Downloads\ALMTest-master\batchServer\Program.cs:line 61
Can anyone help me out?