Created
June 9, 2011 02:30
-
-
Save smarx/1015927 to your computer and use it in GitHub Desktop.
Making my first call to the Windows Azure Service Management API from Node.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* certificate generated via: | |
openssl req -x509 -nodes -days 365 -subj '/CN=test' -newkey rsa:1024 -keyout priv.pem -out pub.pem | |
openssl x509 -outform der -in pub.pem -out pub.cer | |
(pub.cer is what's uploaded to Windows Azure via the portal) | |
*/ | |
var crypto = require('crypto'), | |
https = require('https'), | |
fs = require('fs'); | |
var req = https.request({ | |
host: 'management.core.windows.net', | |
port: 443, | |
path: '/MY_SUBSCRIPTION_ID/operatingsystems', | |
method: 'GET', | |
key: fs.readFileSync('./priv.pem', 'ascii'), | |
cert: fs.readFileSync('./pub.pem', 'ascii'), | |
headers: {'x-ms-version': '2010-04-01' } | |
}, function (res) { | |
var body = ''; | |
res.on('data', function (chunk) { | |
body += chunk; | |
}); | |
res.on('end', function() { | |
console.log(body); | |
}); | |
}); | |
req.end(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment