Soumya Mishra
Soumya Mishra

Reputation: 39

Can I change virtual machine auto shut down time after azure virtual machine created using Rest Api?

This Api on this URL can be helpfull ? https://learn.microsoft.com/en-us/rest/api/dtl/virtualmachineschedules/get

Please Help !

Upvotes: 0

Views: 802

Answers (1)

Joy Wang
Joy Wang

Reputation: 42123

No, the API you provided is for the VM in Azure DevTest Labs, if you want to change the auto shut downtime for a normal azure VM, use the one below.

To acquire an access token, see this link.

Request URL:

PUT https://management.azure.com/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/microsoft.devtestlab/schedules/shutdown-computevm-<VMname>?api-version=2018-09-15

Request header:

Content-Type: application/json; charset=utf-8
Authorization: Bearer eyJ0exxxxx6dyJ9

Request body(1900 means 19:00 i.e. 7:00:00 PM):

{
  "properties": {
    "taskType": "ComputeVmShutdownTask",
    "timeZoneId": "China Standard Time",
    "dailyRecurrence": {
      "time": "1900"
    },
    "targetResourceId": "/subscriptions/<subscription-id>/resourceGroups/<resource-group-name>/providers/Microsoft.Compute/virtualMachines/<VMname>",
    "status": "Enabled",
    "notificationSettings": {
      "timeInMinutes": 30,
      "status": "Disabled"
    }
  },
  "location": "eastus"
}

enter image description here

enter image description here

Upvotes: 3

Related Questions