fbpx
POSThttps://api.spotinst.io/azure/compute/task?accountId={ACCOUNT_ID}

Create a scheduling task

URL Parameters

Parameter Type Description
ACCOUNT_ID String

Your Spotinst accountid associated with your token

Example: act-123abc

Body Attributes


  • name * String
    Task Name
  • description String
    Describe your scheduling task
  • Policies Array
    The task policies
  • policies.cron * String
    The time (in UTC) in which the policy action will be executed. For example: 00 20 * * SAT = every Saturday at 20:00 UTC
  • policies.action * String
    The action to take on the task instances on the specified time. Valid values: STOP and START
  • instances Array
    The name of the virtual machine
  • instances.vmName * String
    The upper limit number of VMs that the group can scale up to
  • resourceGroupName String
    The virtual machine’s resource group name
Request

Headers
{  
   "Content-Type": "application/json",
   "Authorization": "Bearer ${token}" 
}
Body
Copied!
Downloaded!
{
  "name": "My first task",
  "description": "My first task",
  "state": "ENABLED",
  "policies": [
    {
      "cron": "00 20 * * FRI",
      "action": "STOP"
    },
    {
      "cron": "00 08 * * MON",
      "action": "START"
    }
  ],
  "instances": [
    {
      "vmName": "MyVm1",
      "resourceGroupName": "MyGroup1"
    },
    {
      "vmName": "MyVm2",
      "resourceGroupName": "MyGroup2"
    }
  ]
}
Response - 200

Headers
{  
  "Content-Type": "application/json" 
}
Body
Copied!
Downloaded!
{
    "request": {
    "id": "faab3520-fa30-40e8-8d17-0a6776147e11",
    "url": "/azure/compute/task",
    "method": "POST",
    "time": "2016-08-28T15:41:48.102Z"
  },
  "response": {
    "status": {
      "code": 200,
      "message": "OK"
    },
    "kind": "spotinst:azure:compute:task",
    "items": [
      {
        "id": "sat-3f174165",
        "name": "My first task",
        "description": "My first task",
        "state": "ENABLED",
        "policies": [
          {
            "cron": "00 20 * * FRI",
            "action": "STOP"
          },
          {
            "cron": "00 08 * * MON",
            "action": "START"
          }
        ],
        "instances": [
          {
            "vmName": "MyVm1",
            "resourceGroupName": "MyGroup1"
          },
          {
            "vmName": "MyVm2",
            "resourceGroupName": "MyGroup2"
          }
        ],
        "createdAt": "2016-08-28T15:41:48.102Z",
        "updatedAt": "2016-08-28T15:41:48.102Z",
        "deletedAt": null
      }
    ]
  }
}