Sunday, November 3, 2024

Azure auto start virtual machine

 

Azure Automation Account with a Runbook

Azure Automation allows you to create Runbooks to start and stop VMs based on a schedule. Here’s how:

  • Go to Azure Portal and create an Automation Account if you don’t have one.

  • In the Automation Account, go to Runbooks and create a new Runbook.

  • Choose the PowerShell or Python option, then add the following code to start your VM:

    powershell
    # PowerShell example $subscriptionId = '8f3bc3a8-26f0-437c-b384-5388fc90d75d' $resourceGroupName = '<Your Resource Group Name>' $vmName = '<Your VM Name>' # Login and set the subscription Connect-AzAccount -Identity # if using managed identity Set-AzContext -SubscriptionId $subscriptionId # Start the VM Start-AzVM -ResourceGroupName $resourceGroupName -Name $vmName
  • Save and publish the Runbook.

  • Go to Schedules in the Runbook settings and set up a schedule to start the VM at your desired time.

This approach is powerful, flexible, and fully managed by Azure.


Azure disable auto shutdown from Nov 5, 1:20 PM 2024

Credits remaining

CA$271.20

No comments:

Post a Comment