Call the CreateScheduledTask operation to create a scheduled task that triggers a scaling rule on a recurring schedule.
Prerequisites
Before you call this operation, make sure that the following requirements are met:
You have an Alibaba Cloud account and a valid AccessKey pair for API authentication. For more information about common request parameters such as
AccessKeyIdandSignature, see Common parameters.You have created a scaling group. Record the scaling group ID, such as
asg-bp18p2yfxow2dloq****.You have created a scaling rule in the scaling group. Record the Alibaba Cloud Resource Identifier (ARN) of the scaling rule, such as
ari:acs:ess:cn-hangzhou:140692647****:scalingrule/asr-bp12tcnol686y1ik****.
Request parameters
The following table describes the key parameters for creating a scheduled task. For the full parameter list, see CreateScheduledTask.
| Parameter | Type | Required | Description |
|---|---|---|---|
Action | String | Yes | The API operation. Set the value to CreateScheduledTask. |
RegionId | String | Yes | The region ID of the scheduled task. Example: cn-qingdao. |
LaunchTime | String | Yes | The time at which the scheduled task is triggered. Specify the time in ISO 8601 format: YYYY-MM-DDThh:mmZ. The time must be in UTC. |
ScheduledAction | String | No | The unique identifier (ARN) of the scaling rule to execute when the scheduled task is triggered. Example: ari:acs:ess:cn-hangzhou:140692647****:scalingrule/asr-bp12tcnol686y1ik****. You cannot specify both ScheduledAction and ScalingGroupId. |
ScheduledTaskName | String | No | The name of the scheduled task. Example: scheduled****. |
ScalingGroupId | String | No | The ID of the scaling group for which you want to create the scheduled task. If you specify this parameter, you must also specify at least one of MinValue, MaxValue, or DesiredCapacity. You cannot specify both ScalingGroupId and ScheduledAction. |
RecurrenceType | String | No | The recurrence type. Valid values: Daily, Weekly, Monthly, Cron. Must be specified together with RecurrenceValue. |
RecurrenceValue | String | No | The recurrence value. The valid value depends on RecurrenceType. Must be specified together with RecurrenceType. |
RecurrenceEndTime | String | No | The end time of the recurrence. Specify the time in ISO 8601 format: YYYY-MM-DDThh:mmZ. The time must be in UTC. |
You must specify eitherScheduledActionorScalingGroupIdin the request. The two parameters are mutually exclusive.
TheRecurrenceTypeandRecurrenceValueparameters must be specified together. If you set one of these parameters, you must also set the other.
Sample request
The following example creates a scheduled task that triggers a scaling rule daily at 16:52 (UTC) and recurs until 2014-08-17T16:55Z.
http(s)://ess.aliyuncs.com/?Action=CreateScheduledTask
&RegionId=cn-qingdao
&ScheduledTaskName=scheduled****
&ScheduledAction=ari:acs:ess:cn-hangzhou:140692647****:scalingrule/asr-bp12tcnol686y1ik****
&RecurrenceEndTime=2014-08-17T16:55Z
&LaunchTime=2014-08-17T16:52Z
&RecurrenceType=Daily
&RecurrenceValue=1
&ScalingGroupId=asg-bp18p2yfxow2dloq****
&<Common request parameters>Sample success responses
A successful request returns the ScheduledTaskId of the created task and a RequestId for troubleshooting.
XML format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateScheduledTaskResponse>
<ScheduledTaskId>edRtShc57WGXdt8TlPbr****</ScheduledTaskId>
<RequestId>473469C7-AA6F-4DC5-B3DB-A3DC0DE3****</RequestId>
</CreateScheduledTaskResponse>JSON format
HTTP/1.1 200 OK
Content-Type:application/json
{
"ScheduledTaskId" : "edRtShc57WGXdt8TlPbr****",
"RequestId" : "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****"
}Related API operations
| API | Description |
|---|---|
| CreateScheduledTask | Creates a scheduled task. |
| DescribeScheduledTasks | Queries scheduled tasks. |
| ModifyScheduledTask | Modifies a scheduled task. |
| DeleteScheduledTask | Deletes a scheduled task. |