Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Virtual Machine Start-Up task

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?

like image 972
Gaurav Avatar asked Apr 01 '13 16:04

Gaurav


People also ask

How do I autostart my Azure VM?

Add VMs to the auto-start scheduleOn your lab Overview page, select the VM under My virtual machines. On the VM's Overview page, select Auto-start under Operations in the left navigation. On the Auto-start page, select Yes for Allow this virtual machine to be scheduled for automatic start, and then select Save.

How do I schedule a VM start and stop in Azure?

On the Start/Stop VM page, select Manage the solution under Manage Start/Stop VM Solutions. Navigate to the Log Analytics workspace linked to your Automation account. After after selecting the workspace, choose Solutions from the left pane. On the Solutions page, select Start-Stop-VM[workspace] from the list.

Why is Azure VM not starting?

A common issue could be that you have DHCP disabled on your network interface controller (NIC). You're probably aware Azure works by handing out infinite-lease IP addresses from a subnet in your virtual network (VNet) to your VMs, but if your VM restarts, the platform may give it a different IP address.


1 Answers

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.

like image 194
Rich Turner Avatar answered Sep 30 '22 15:09

Rich Turner