I am trying to create a storage account using Web API but it is giving me the exception that method not allowed as shown below
below are the code which I am using
string stAccName = "TCStorageAccount"+Guid.NewGuid().ToString().Substring(0, 8); stAccName = stAccName.ToLower();
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
using (var stream = new MemoryStream())
using (var writer = new StreamWriter(stream))
{
var payloadText = JsonConvert.SerializeObject(parameters);
writer.Write(payloadText);
writer.Flush();
stream.Flush();
stream.Position = 0;
using (var content = new StreamContent(stream))
{
content.Headers.Add("Content-Type", "application/json");
content.Headers.Add("x-ms-version", "2016-12-01");
Uri uri = new Uri(String.Format("http://ift.tt/2wIhXJo", "subid", "resource group name", stAccName));
var response = await client.PostAsync(uri, content);
if (!response.IsSuccessStatusCode)
{
throw new InvalidOperationException(response.ReasonPhrase);
}
}
}
}
I also tried with another way as discussed in this thread Unable to create Storage account on Azure C# but still unable to create a storage account.
Any help would be appreciated. Thanks
Aucun commentaire:
Enregistrer un commentaire