Manage Services within Azure VM from Automation Runbook
I'm looking to use Azure Runbooks (powershell) to automate the shutdown/startup process of a few Azure virtual machines. The VM's are running 3rd party reporting tools, some of which take a few minutes to start and stop services.
I was wondering if there's a way to control the services running on Azure VM's using runbooks, i.e the stopping/starting the 3rd party reporting tools I mentioned above. Ideally I'd be able to stop the VM's one at a time but include some powershell code to not proceed to the next VM until service 'xyz' is stopped or started. I'd appreciate any help or suggestions.
Thanks!
You can use PowerShell remoting to connect to a VM and run PowerShell commands on that VM. However, if you want to do this from Azure Automation runbooks then you would need to create a Hybrid Worker VM in the same network as your VM's to run these tasks on.
PowerShell remoting uses WINRM to talk to the VM, and you don't want to expose this to the internet for Azure Automation to talk to. By running a Hybrid worker you can have this be the one that runs your automation tasks and talks to WINRM over the network.
Alternatively, if you just want to shut down the VM, you can use the Azure PowerShell libraries in Automation to do that, no need for Hybrid worker.