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?
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.
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.
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.
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:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With