I'm trying to programmatically start a slot for an Azure website using a C# code sequence. I've tried to use the following code:
public async Task StartWebsiteSlot()
{
var subscriptionId = "{my Azure subscription id}";
var certPath = "{my full path to the Azure management certificate}";
var certificate = new X509Certificate2( certPath, {my password});
var httpHandler = new WebRequestHandler();
httpHandler.ClientCertificates.Add(certificate);
httpHandler.ClientCertificateOptions = ClientCertificateOption.Automatic;
var url = "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{groupname}/providers/Microsoft.Web/sites/{site name}/start?api-version=2015-08-01";
var postContent = new StringContent( String.Empty );
using (var client = new HttpClient(httpHandler))
{
var response = await client.PostAsync(url, postContent);
}
}
The call returns "Unathorized". I know the certificate is ok because I'm using it with the WebManagementClient to swap deployment slots.
How should I access that specific Azure management REST API?