Hi Jana, Tapas,
Thanks for posting you query and using Microsoft Q&A Forum.
Based on your query, you can go with azure cli with commands to start and stop VM and use azure automation runbooks
Azure CLI
Starting a VM
To get a VM up and running use below command.
az vm start -g MyResourceGroup -n MyVm
Just replace -g
(or --resource-group
) with your resource group name and -n
(or --name
) with the name of your VM.
If you want to start all VMs in a specific resource group
az vm start --ids $(az vm list -g MyResourceGroup --query "[].id" -o tsv)
And if you don't want to wait for the operation to finish, you can add the --no-wait
parameter to your commands.
Stopping a VM is very similar to starting one. use below command.
az vm stop -g MyResourceGroup -n MyVm
And Restarting a VM if you need to restart a VM, you can use this command:
az vm restart -g MyResourceGroup -n MyVm
And also, you can use Azure Automation account and create a Runbook. In that Runbook, paste your custom script, and you can schedule it based on your requirements. Please refer to the documentation below on how to set up an Automation account and Runbook.
Quickstart: Create an Automation account using the Azure portal
Tutorial: Create a PowerShell Workflow runbook in Automation
Note: - Before making any changes or setting things up, please make sure backup and all configuration for testing do in testing environment
Please let us know if you have any further query, I will assist you as needed.!
If you found this information helpful, please click an accepting the answer and "Upvote" on my post for other community member's reference