Category: Azure VM (1)

Use PowerShell script to monitor and start a deallocated Azure VM

My Azure VM sometimes gets deallocated for some reason, so I created a PowerShell script and configure it as a scheduled task to monitor the VM status and start the VM once it is deallocated. The script uses a precreated Azure service principal to automatically authenticate Azure and Azure PowerShell cmdlets to detect the VM status, if the status is deallocated then it calls Start-AzVm to start the VM, the script execution result is recorded to a log file.


Jan 25, 2021
Read More