CreateScheduledTask

Updated at:

Creates a scheduled task.

Operation description

Operation description

  • If a scheduled task fails to trigger a scaling rule because a scaling activity is in progress or the scaling group is disabled, the scheduled task automatically retries within the period specified by LaunchExpirationTime. Otherwise, the trigger is abandoned.

  • If multiple scheduled tasks trigger scaling rules of the same scaling group at approximately the same time, the triggered scaling activities behave as follows:
    • Scaling groups with the expected number of instances configured: Scaling activities triggered by multiple scheduled tasks are parallel scaling activities. For example, if multiple scheduled tasks are executed at approximately the same time, the scaling group can trigger multiple parallel scaling activities simultaneously.

    • Scaling groups without the expected number of instances configured: The earliest triggered scheduled task executes the scaling activity first. Because a scaling group can have only one scaling activity at a time, subsequent scheduled tasks automatically retry within the period specified by LaunchExpirationTime. If a subsequent scheduled task is still retrying within the LaunchExpirationTime period after the previous scaling activity is completed, the scaling rule of the scheduled task is executed and the corresponding scaling activity is triggered.

  • Scheduled tasks support the following two scaling methods:
    • Specify the scaling rule to execute by using the ScheduledAction parameter.

    • Specify the number of instances in the scaling group by using the ScalingGroupId parameter.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

ess:CreateScheduledTask

create

*ScalingGroup

acs:ess:{#regionId}:{#accountId}:scalinggroup/{#ScalingGroupId}

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

Yes

The ID of the region to which the scheduled task belongs.

cn-qingdao

ScheduledTaskName

string

No

The name of the scheduled task. The name must be 2 to 64 characters in length and can contain digits, letters, underscores (_), hyphens (-), and periods (.). It must start with a digit, letter, or Chinese character. The name must be unique within the same region and Alibaba Cloud account.

Default value: the value of ScheduledTaskId.

scheduled****

Description

string

No

The description of the scheduled task. The description must be 2 to 200 characters in length.

Test scheduled task.

ScheduledAction

string

No

The unique identifier of the scaling rule to execute when the scheduled task is triggered.

After you specify this parameter, the scaling method of the scheduled task is set to selecting an existing scaling rule.

Note

You cannot specify both ScheduledAction and ScalingGroupId at the same time.

ari:acs:ess:cn-hangzhou:140692647****:scalingrule/asr-bp12tcnol686y1ik****

RecurrenceEndTime

string

No

The end time of the scheduled task recurrence.

Specify the time in the ISO 8601 standard in the YYYY-MM-DDThh:mmZ format. The time must be in UTC. You cannot specify a time that is later than 365 days from the creation date.

2014-08-17T16:55Z

LaunchTime

string

Yes

The time when the scheduled task is triggered.

Specify the time in the ISO 8601 standard in the YYYY-MM-DDThh:mmZ format. The time must be in UTC. You cannot specify a time that is later than 90 days from the creation date.

  • If RecurrenceType is specified, the time specified by this parameter defaults to the time when the task is executed periodically.

  • If RecurrenceType is not specified, the task is executed only once at the specified date and time.

2014-08-17T16:52Z

RecurrenceType

string

No

The recurrence type of the scheduled task. Valid values:

  • Daily: The scheduled task is executed once every specified number of days.

  • Weekly: The scheduled task is executed once a week on specified days.

  • Monthly: The scheduled task is executed once a month on specified days.

  • Cron: The scheduled task is executed based on the specified cron expression.

You must specify both RecurrenceType and RecurrenceValue.

Daily

RecurrenceValue

string

No

The recurrence value of the scheduled task.

  • If RecurrenceType is set to Daily, you can specify only one value. Valid values: 1 to 31.

  • If RecurrenceType is set to Weekly, you can specify multiple values separated by commas (,). For example, the values for Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, and Saturday are 0,1,2,3,4,5,6.

  • If RecurrenceType is set to Monthly, the format is A-B. Valid values of A and B: 1 to 31. B must be greater than or equal to A.

  • If RecurrenceType is set to Cron, the value represents UTC time. It supports a five-field expression for minutes, hours, days, months, and days of the week. It supports wildcards such as commas (,), question marks (?), hyphens (-), asterisks (*), number signs (#), forward slashes (/), L, and W.

You must specify both RecurrenceType and RecurrenceValue.

1

TaskEnabled

boolean

No

Specifies whether to start the scheduled task. Valid values:

  • true: starts the task.

  • false: stops the task.

Default value: true.

true

LaunchExpirationTime

integer

No

The period within which the scheduled task retries after a trigger failure. Unit: seconds. Valid values: 0 to 1800.

Default value: 600.

600

MinValue

integer

No

The minimum number of instances in the scaling group when the scaling method of the scheduled task is set to specifying the number of instances in the scaling group.

0

MaxValue

integer

No

The maximum number of instances in the scaling group when the scaling method of the scheduled task is set to specifying the number of instances in the scaling group.

10

DesiredCapacity

integer

No

The expected number of instances in the scaling group when the scaling method of the scheduled task is set to specifying the number of instances in the scaling group.

Note

The scaling group must support setting the expected number of instances. This means that DesiredCapacity must be specified when the scaling group is created.

10

ScalingGroupId

string

No

The ID of the scaling group for which you want to modify the number of instances or adjust the warm pool capacity when the scheduled task is triggered.

After you specify ScalingGroupId, the scaling method of the scheduled task is set to specifying the number of instances in the scaling group or adjusting the warm pool capacity.

  • Specify the number of instances in the scaling group: You must specify a value for at least one of the MinValue, MaxValue, and DesiredCapacity parameters.

  • Specify the warm pool capacity: You must configure WarmPoolCapacityOptions.

Note

You cannot specify both ScheduledAction and ScalingGroupId at the same time.

asg-bp18p2yfxow2dloq****

WarmPoolCapacityOptions

object

No

The warm pool capacity configuration for the scaling group. This parameter takes effect only when a warm pool is configured for the scaling group.

Note

When you specify this parameter, you must also specify ScalingGroupId.

DesiredGroupPreparedCapacity

integer

No

The expected number of instances covered by warming. The system maintains the sum of the current number of instances in the scaling group and the number of instances in the warm pool at this value. Default value: the maximum number of instances in the scaling group, which is specified by MaxSize.

5

MinCapacity

integer

No

The minimum number of instances in the warm pool. The system always retains at least this number of warmed instances in the warm pool to ensure rapid scale-out from the warm pool at any time. Default value: 0.

0

Response elements

Element

Type

Description

Example

object

RequestId

string

The request ID.

473469C7-AA6F-4DC5-B3DB-A3DC0DE3****

ScheduledTaskId

string

The ID of the scheduled task. The ID is generated by the system and is globally unique.

edRtShc57WGXdt8TlPbr****

Examples

Success response

JSON format

{
  "RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
  "ScheduledTaskId": "edRtShc57WGXdt8TlPbr****"
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.