1

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.

Elmar Weber
  • 482
  • 1
  • 7
  • 17

1 Answers1

2

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.

David Makogon
  • 2,767
  • 1
  • 19
  • 29
  • 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](https://github.com/szarkos/azure-sdk-tools-xplat/commit/8f5ec9c649ea5570d5345010ff78748721a8e489) 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