none
The remote server returned an error: (403) Forbidden When trying to make a web request in Windows Azure

    Question

  • I have a situation similar to the thread

     http://social.msdn.microsoft.com/Forums/en/windowsazure/thread/4ec04c00-e476-49b0-860d-6ada6e88f4a2

    I already verified the certificate is in management certificates, but the problem persists, I don't know what else I can do to resolve the issue

    This is my code:

     ----------------------------------------------------------

    const string x_ms_version = "2009-10-01";
    const string deploymentSlot = "Production";
    var requestUrl = "https://management.core.windows.net/" + SubscriptionId + "/services/hostedservices/"+ ServiceName + "/deploymentslots/" + deploymentSlot;
    var restRequest = (HttpWebRequest)WebRequest.Create(requestUrl);
    restRequest.Method = "GET";
    restRequest.ContentType = "text/xml";
    restRequest.Headers.Add("x-ms-version", x_ms_version);
    var cert = LookupCertificate(CertificateThumbprintName);
    restRequest.ClientCertificates.Add(cert);
    var restResponse = restRequest.GetResponse();
    var receiveStream = restResponse.GetResponseStream();
    var restResponseStream = new StreamReader(receiveStream, true);

    var responseBody = restResponseStream.ReadToEnd();
    restResponseStream.Close();

     ----------------------------------------------------------

    Thanks

    Wednesday, December 22, 2010 9:42 PM

Answers

  • Now is working,

    Something was wrong with the certificate, I recreated it, exported the .cer and then reuploaded to azure (.pfx to the hosted service and .cer to management certificates)

     

    • Marked as answer by Mog Liang Thursday, December 30, 2010 5:24 AM
    Wednesday, December 22, 2010 11:29 PM