Recently I ran into a problem with using Certificates to upload my project to Windows Azure. I was doing something wrong over and over again, so I thought I’d post the correct way of doing it. It’s something I’ve done many times, but on setting up a new computer I had to do it again for the first time in a while and ran into a brick wall. If you get the same error it will read like:

The HTTP request was forbidden with client authentication scheme ‘Anonymous’.
The remote server returned an error: (403) Forbidden.


When you want to upload to Azure, for security Visual Studio Tools for Windows Azure require the use of a certificate. You must enter a certificate before you can upload your project with the Visual Studio Tools.

Visual Studio Prompt for Credentials

Visual Studio Prompt for Credentials

Select from the Credentials drop down the option to <Add> a new Credential:

Add Credentials

Add Credentials

Now you can select or create a certificate for use with these credentials:

Select a Certificate

Select a Certificate

You will see any existing certificates in this list, mine has a few – yours may be empty. However for this example we will create a new Certificate, so select <Create> and enter a friendly name:

Select Create a Certificate

Select Create a Certificate

Enter a friendly name

Enter a friendly name

Now you will be taken back to the Windows Azure Project Management Authentication screen with the certificate selected. Now you must open up the Management Portal at http://windows.azure.com and upload the newly created certificate to the Portal. The shortcut to doing this is to click the first and then second link at point 2 of the below dialog:

Prepare to upload your certificate

Prepare to upload your certificate

In the portal, make sure you go to the Management Certificates section. This was where I was going wrong! I was adding a certificate to a Hosted Service rather than the overall Management Portal.

Go to the Management Certificates area

Go to the Management Certificates area

Click the Add Certificate button at the top left of the screen, select the subscription to use and browse to the certificate in this location:

Update Certificate

Update Certificate

Clicking “Done” will create the certificate, and then you will be able to upload your project to Windows Azure.

Done indeed!

How not to do it!

Just to be clear, I was adding my certificate to the wrong place:

Don't upload a certificate here for uploading - the wrong place!

Don't upload a certificate here for uploading - the wrong place!

This Certificates Node is used to manage a particular instance set, for things such as Remote Desktop.

It’s pretty easy to go wrong, but easy to notice that you have once you know what to look for – make sure your certificate upload dialog doesn’t contain a Password field! This is because the certificate for upload and a certificate for remote desktop are different (the remote desktop contains the private key):

The wrong dialog!

The wrong dialog!

Had I been a little more awake, I probably would have thought in more depth about why I didn’t know what the password was! However, if you specify a .cer file in here, the portal doesn’t need to use it, and so won’t mind that you just made it up! Trying to use this will result in the error message:

Error Message

Error Message

If you run into this issue, just delete the certificate from within your Hosted Services subscription and instead add it to the Management Certificates part of the Portal.

Also, it’s probably time to get another coffee :-) It certainly was for me!

Stop Press!

As I was writing this, there was an update by David Hardin on a very similar subject: http://blogs.msdn.com/b/davidhardin/archive/2011/01/18/azure-ssl-verses-management-api-certificates.aspx

Andy

About these ads