I'm using azure service management REST API in my application. I uploaded the management certificate on azure and have a copy in local. I keep the certification in a separate folder (AzureCertificate) in the application itself and referring to that location. e.g:
string certificatePath = Server.MapPath("~/AzureCertificate/") + certificateName;
X509Certificate2 certificate = new X509Certificate2(certificatePath);
AzureCertificate -- Folder name certificateName - MyCertificatieName.cer
it works fine when I run the application my local development environment. But I'm getting the below error when I deploy the same in azure website.
The remote server returned an error: (403) Forbidden
This is how I make the request
string uri = apiURL + subscriptionId + "/services/hostedservices";
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(uri);
X509Certificate2 certificate = new X509Certificate2(certificatePath);
req.ClientCertificates.Add(certificate);
req.Headers.Add("x-ms-version", "2009-10-01"); HttpWebResponse res =
(HttpWebResponse)req.GetResponse();
But it throws the above said exception at the last line (req.GetResponse()).
Can we use the management certificate in this way?.
My requirement is to develop an application which uses the azure REST API and deploy in azure.