Azure Service Management REST API HTTP status codes

I am currently working on scripting a complex Azure deployment.

Azure provides a REST API that you can call to perform many tasks. To make this api a bit easier to work with Microsoft released the Azure cmdlets that provide a wrapper for some of this functionality.

It is worth noting that the service api doesn’t allow you to do everything you will want to do. For example a weird omission is that you cannot currently script the creation of storage services.

Anyway I digress!

Whilst creating a wrapper for some of the API calls I ran into a number of issues that I wouldnt want anyone else to waste their time with. The Azure service management API isnt the most descriptive of things when you screw up and most of the time will give you an HTTP status code to indicate what happened.

I love the purist nature of this and it does make sense but surely Microsoft could have included some more info given you have to be authenticated anyway?

Anyway if you are working with the API and having problems here are a few things to check:

401 (unauthorized) – check you haven’t exceeded service deployment allowance, if you are deleting a service slot you will also need to suspend any running roles
403 (forbidden) – check API certificate and that it is uploaded. Note the .net certificate APIs have an additional overload that allows you to only retrieve valid certificates – if you have issues the certificate yourself it wont be valid!
409 (conflict) – service names must be globally unique – check yours is!
500 – check your request is valid

I also noticed that Fiddler seems to interfere with requests and results in 403 Forbidden errors.