6

We are creating a multi-tenant application and hosting it on Window Azure IaaS platform. We want to provision and configure all our virtual machines remotely using PowerShell. We don't want to RDP into VMs for any configuration.

Does Azure VMs support start up tasks to execute power shell scripts similar to Web-Role and Worker-Role?

If no, then are there any alternatives available (tools like PsExec) which can help in executing start-up scripts?

Gaurav
  • 895
  • 3
  • 14
  • 31

1 Answers1

12

Your VM's are just virtualized Windows/Linux machines and this support start-up tasks as per usual.

For Windows VM's, you'll need to:

  1. Download the base Azure Windows Server guest VM.
  2. Customize the machine's startup process to execute a startup script.
  3. Push your customized VM back up into Azure.
  4. Configure Azure to start your customized VM.

Note: You can also access PowerShell on a remote VM using PowerShell remoting in a similar manner to how one uses SSH to access the console of a remote [LI|U]N[U|I]X box/VM.

FWIW, Git is a great tool to use to pull down and execute a VM config script: Your on-VM startup script can use Chocolatey to install the latest version of GIT (if it's not already installed) and then use Git to pull down the latest version of your startup script from GitHub/similar and execute it. This way you don't need to continually rebuild VM images every time your scripts change.

Rich Turner
  • 10,800
  • 1
  • 51
  • 68
  • Steps 1 and 3 aren't needed, as that was for the old VM Role. For Virtual Machines, just create a new one from gallery and choose Windows Server or one of the Linux variants as the startup image. Your new VHD will be created and your Virtual Machine will start up in a few minutes. Every change you make at that point is persistent and durable (all changes written to vhd stored in Blob Storage). Further: You can sysprep a vhd you create, and add it to your own set of starter images. These all reside in Azure, with no need to download them locally or push them back to Azure. – David Makogon Apr 01 '13 at 17:25
  • @David: Fair points. However, Sometimes, getting things working locally is easier, cheaper and faster than doing so in the cloud. – Rich Turner Apr 01 '13 at 17:27
  • 2
    Thanks for your response. Would be great if Microsoft can add support for executing PowerShell scripts as VMs are provisioned and started. Just up-voted similar item in [Azure wishlist](http://www.mygreatwindowsazureidea.com/forums/34192-windows-azure-feature-voting/suggestions/3026972-startup-tasks-for-azure-iaas-vms) – Gaurav Apr 02 '13 at 14:31
  • 1
    Agreed - it kind of sucks you can't do something similar to AWS UserData http://www.diaryofaninja.com/blog/2013/07/24/scorched-earth-deployments-on-amazon-ec2-teamcity-amp-web-deploy-ndash-part-1-amazon-config – Doug May 29 '14 at 05:53