What's the proper way to auto start a vm?

Alexander_redacted_ 0 Reputation points
2025-03-18T11:06:58.9366667+00:00

Hello all,
I was wondering, there are different ways to start a VM, what's the best (will not be deprecated in some time):

  1. Start/Stop VMs v2 (no further development): https://learn.microsoft.com/en-us/azure/azure-functions/start-stop-vms/overview#overview
  2. The Automation Account way with a Runbook: https://medium.com/@erwan.letort/automatically-stop-and-start-your-azure-vm-part-1-automation-and-runbook-8e15ec1116bf
  3. in the Azure/Virtual Machines/VM_Name/Automation/Task/Start Virtual Machine learn.microsoft.com/en-us/azure/logic-apps/create-automation-tasks-azure-resources
    Does it work with an Azure Automation account, or also without one. Currently Contributor for the subscription, but automated task fails:
{  "error": {    "code": "AuthenticationFailed",    "message": "Authentication failed. The 'Authorization' header is missing."  }}

What ways do you use to auto-start VMs?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,687 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Jose Benjamin Solis Nolasco 1,046 Reputation points
    2025-03-18T12:12:11.0766667+00:00

    Good morning Alexander_redacted_

    In my experience and based on current best practices, using an Automation Account (or Logic Apps if you want a low-code alternative) is the most future-proof method.

    Avoid: The “Start/Stop VMs v2” solution—as it is not under active development, its longevity is not guaranteed.

    Authentication: Runbooks running in an Automation Account generally use either a Run As account or a Managed Identity to authenticate with Azure Resource Manager (ARM). If your API calls are failing with an error like:

    {  "error": { "code": "AuthenticationFailed", "message": "Authentication failed. The 'Authorization' header is missing."  }}
    

    It means that your runbook (or task) isn’t injecting a valid token in the Authorization header. This usually happens if:

    • You aren’t using a managed identity or “Run As” account.
    • The code making the REST call isn’t properly requesting an access token from Azure AD.

    Source links

    1- https://learn.microsoft.com/en-us/azure/automation/

    2- https://learn.microsoft.com/en-us/azure/virtual-machines/infrastructure-automation you can learn here and play with automatization

    3- https://learn.microsoft.com/en-us/azure/logic-apps/create-automation-tasks-azure-resources

    I hope this help you out

    😊 If my answer helped you resolve your issue, please consider marking it as the correct answer. This helps others in the community find solutions more easily. Thanks!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.