How to Auto start/stop of Azure Virtual Machines

Introduction

Managing costs in cloud environments is crucial for optimizing resource usage. Auto start and stop of Azure Virtual Machines (VMs) during non-business hours is an effective way to save costs by ensuring that resources are only active when needed. In this article, we’ll explore how to auto start and stop azure vm.


Prerequisites

Before starting the setup, ensure the following prerequisites are met:

  1. Azure Virtual Machine(s):
    At least one Azure VM needs to be provisioned.
  2. Log Analytics Workspace:
    Used for collecting and analyzing logs and metrics.
  3. Automation Account:
    This will hold the automation runbooks and configurations required to manage tasks for Azure resources.

How to Auto start/stop of Azure Virtual Machines

Follow these steps to set up automatic startup and shutdown of Azure VMs:

Step 1: Log in to the Azure Portal

  1. Open the Azure Portal.
  2. Log in with your credentials.

Step 2: Create an Automation Account

  1. In the search bar, type Automation Accounts and select it.
  2. Click on + Create.
  3. Fill in the required details:
    • Subscription: Select your subscription.
    • Resource Group: Choose an existing resource group or create a new one.
    • Automation Account Name: Provide a unique name.
    • Region: Choose the region for your Automation Account.
    • Leave the remaining fields with default values.
  4. Click Review + Create, then Create to deploy the Automation Account.

Step 3: Add the Start/Stop VM Solution

  1. After the Automation Account is created, click Go to Resource.
  2. Under Related Resources, locate Start/Stop VM and click Manage the Solution.

Step 4: Search for the VM Solution in the Marketplace

  1. Click + Create Solution.
  2. In the Search the VM Solution Marketplace field, search for Start/Stop VMs during off-hours.
  3. Select the solution and click Create.

Step 5: Configure the VM Solution

  1. In the Add Solution window:
    • Select your Log Analytics Workspace. This workspace will store logs for the VM operations.
    • Choose the Target Resource Group for the VMs you want to manage.
      • Use * to include all resource groups in your subscription.
    • Azure VM Exclude List: If there are VMs you don’t want to include in this automation, specify them here (e.g., VMs required to run 24/7). Leave it blank if none.
    • Schedule Start Time and Stop Time: Specify the desired times for starting and stopping the VMs. Use UTC for the time zone.
    • Email Notifications: Enable email functionality to receive notifications about the automation actions.
      • Set Receive Email Functionality to Yes.
      • Add the email addresses to be notified (e.g., [email protected]).
  2. Click OK to save the configuration.

Step 6: Provision the Solution

  1. Review the configuration and click Create to apply the solution.
  2. Wait for the deployment to complete, which may take a few minutes.

Verification

To ensure the setup is working:

  1. Wait for the configured start or stop time to trigger.
  2. Verify that the VMs are starting and shutting down as per the schedule.
  3. Check the Log Analytics Workspace for logs related to the automation tasks.
  4. Review email notifications for task updates.

Best Practices

  1. Set Exclude Lists Carefully:
    Ensure critical VMs that must run 24/7 are excluded from the automation.
  2. Use UTC Time Zone:
    When scheduling the start and stop times, always use Coordinated Universal Time (UTC) to avoid discrepancies.
  3. Monitor Logs Regularly:
    Use the Log Analytics Workspace to verify that automation tasks are running smoothly.
  4. Test Automation in Non-Production:
    Before applying the automation to production workloads, test it on non-critical VMs.
  5. Enable Notifications:
    Set up email notifications to stay informed about task execution and potential issues.

Benefits of Auto Startup and Shutdown for Azure VMs

  1. Cost Savings:
    Reduces costs by stopping VMs during non-business hours.
  2. Automation:
    Removes the need for manual intervention to start or stop VMs.
  3. Flexibility:
    Allows scheduling based on business needs.
  4. Efficient Resource Management:
    Ensures resources are only used when required.

Troubleshooting Tips

  1. VMs Not Starting/Stopping as Scheduled:
    • Check the Log Analytics Workspace for error logs.
    • Verify that the Automation Account has the necessary permissions to manage the VMs.
  2. Email Notifications Not Received:
    • Ensure email functionality is enabled and the correct email addresses are configured.
    • Check spam or junk folders.
  3. Automation Solution Deployment Fails:
    • Verify that the selected Log Analytics Workspace is active.
    • Ensure there are no conflicting configurations in your Azure subscription.
  4. Timezone Discrepancies:
    • Confirm that the schedule times are set in UTC.

Conclusion

Setting up auto start and shutdown for Azure VMs is a cost-effective way to optimize resource usage during non-business hours. By leveraging tools like Automation Accounts and Log Analytics Workspace, organizations can efficiently manage VM operations while minimizing manual intervention.

This solution not only reduces costs but also ensures better resource allocation, making it an essential practice for organizations using Azure Virtual Machines.

For more information, visit the official Azure Automation documentation.

For your information setup Start and Stop an AKS Cluster

Related articles

How to use AWS Elastic Beanstalk for Application Deployment

🚀 How to use AWS Elastic Beanstalk for Application Deployment AWS Elastic Beanstalk is one of the easiest and...

What is Server Virtualization

What is Server Virtualization Introduction Server virtualization is a cornerstone of cloud computing that enables efficient resource utilization by dividing...

Centralized Logging Architecture Multi Cloud : The 2026 Engineering Blueprint

Centralized Logging Architecture Multi Cloud Mastering The 2026 Engineering Blueprint The digital landscape of late 2026 has been defined by...

Rollback Kubernetes deployments

Rollback Kubernetes deployments Rollback functionality in Kubernetes allows you to revert a deployment to a previous version if something...