How to use REST API to start Azure VM

Forrest Wu 41 Reputation points
2025-05-23T19:06:39.28+00:00

I am looking for a solution to start my Azure VM by using REST API

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

Accepted answer
  1. TP 124.7K Reputation points Volunteer Moderator
    2025-05-23T19:16:42.3+00:00

    Hi,

    You may use below Start REST API call to start Azure VM. There are code samples on the below page for several different languages. Which language do you plan to use?

    Virtual Machines - Start

    https://learn.microsoft.com/en-us/rest/api/compute/virtual-machines/start?view=rest-compute-2025-02-01&tabs=HTTP

    Please click Accept Answer and upvote if the above was helpful.

    Thanks.

    -TP

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Pramidha Yathipathi 1,135 Reputation points Microsoft External Staff Moderator
    2025-05-23T19:54:36.2633333+00:00

    Hi Forrest Wu,

    Prerequisites: Azure subscription, VM resource(Details: SubscriptionID, resourceGroupName, vmName), Service Principal or Managed Identity with the required permissions, Access Token (Via Azure Active Directory).

    Get an Access Token ensure that you include the correct authentication header in your request. You can use Azure AD to get the necessary bearer token.

    Request:

    POST https://login.microsoftonline.com/{tenantId}/oauth2/token
    Content-Type: application/x-www-form-urlencoded
    
    grant_type=client_credentials
    &client_id={clientId}
    &client_secret={clientSecret}
    &resource=https://management.azure.com/
    

    You'll receive a token in the access_token field.

    Request to start a VM

    POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start?api-version=2024-03-01
    Headers:
    Authorization: Bearer {access_token}
    Content-Type: application/json
    

    Body:

    Empty (none required for this operation).

    Example with curl:

    curl -X POST \
    "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start?api-version=2024-03-01" \
      -H "Authorization: Bearer {access_token}" \
      -H "Content-Type: application/json"
    

    Response you will get a 202 Accepted response indicating the start operation was initiated.

    https://learn.microsoft.com/en-us/rest/api/compute/virtual-machines/start?view=rest-compute-2025-02-01&tabs=HTTP

    https://learn.microsoft.com/en-us/entra/identity-platform/v2-oauth2-client-creds-grant-flow

    If you found information helpful, please click "Upvote" on the post to let us know.

    If you have any further queries, feel free to reach out — we’re always happy to assist you.

    Thank You.

    1 person found this answer helpful.
    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.