Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to create an instance specific init script and pass it to a virtual machine that is created via the API of Microsoft Azure? I know this from AWS, but could not find a way to do this on MS Azure.

The only workaround I can think of it to create a generic script for my own image that then somehow downloads a custom script based on the hostname.

share|improve this question
up vote 2 down vote accepted

I posted the answer to this on StackOverflow (link). Reposting here (with a few tweaks) as well, for completeness...

Take a look at the REST API call for creating a Virtual Machine deployment, specifically the <CustomData> element. This lets you inject up to 64K of binary data to your VM during provisioning, which results in a CustomData.bin file being generated inside your VM. This should help you with first-time init, and works with both Linux and Windows Virtual Machines.

Note that this isn't yet implemented in the command-line tools - you'll need to call the API directly. There's now a pull request posted implementing the proper CLI wrapper code for CustomData but it hasn't yet been accepted.

share|improve this answer
Thanks, not as easy as hoped, but definitely something to work on. – Elmar Weber Nov 19 '13 at 22:50
Hopefully it will be easier once the CLI is updated. If you look at the proposed change to the CLI, there will be a new parameter to azure vm create (-d or --custom-data) that takes a filename, which gets encoded automagically for you. – David Makogon Nov 19 '13 at 22:56

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.