Greymeister.net

No REST for the Wicked

I recently noticed something that if you know up front will save you some time. The Azure REST documentation for creating a Virtual Machine image is off a bit. Here is the example from their documentation:

1
2
3
4
5
6
7
8
9
10
11
12
13
<PublicKeys>
   <PublicKey>
       <FingerPrint>certificate-fingerprint</FingerPrint>
       <Path>SSH-public-key-storage-location</Path>
   </PublicKey>
</PublicKeys>
<KeyPairs>
   <KeyPair>
       <FingerPrint>certificate-fingerprint</FinguerPrint>
       <Path>SSH-public-key-storage-location</Path>
   </KeyPair>
</KeyPairs>
</SSH>

First, this is obviously not valid XML because of the incorrect spelling, but even if you fix that you’ll get this lovely response back from the server:

1
2
3
4
 <Error xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <Code>BadRequest</Code>
    <Message>Fingerprint and Path in SSHKeyPair should not be null or empty.</Message>
</Error>

Whuh? At first this doesn’t leave you with much to work with, especially after checking your XML tags over and over and seeing that the tags that are missing are present in your request body. However, there is a hint in the error message, and that is the capitalization of Fingerprint. If you switch to this for both the PublicKey and KeyPair elements the request will succeed with a 202 HTTP response. I have reported the documentation defect to Microsoft already, so hopefully it will be corrected soon.

So far, the new Azure Management Portal and its REST API are less awful than what was available last year.