This operation creates a job template.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
sae:CreateJob |
create |
*All Resource
|
None | None |
Request syntax
POST /pop/v1/sam/job/createJob HTTP/1.1
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| AppName |
string |
Yes |
The name of the job template. The name can contain letters, digits, and hyphens (-). It must start with a letter and be no longer than 36 characters. |
test |
| NamespaceId |
string |
No |
The ID of the SAE namespace. The namespace name can contain only lowercase letters and hyphens (-), and must start with a letter. |
cn-beijing:test |
| AppDescription |
string |
No |
The description of the job template. It cannot exceed 1,024 characters. |
This is a test description. |
| VpcId |
string |
No |
The ID of the VPC for the SAE namespace. In SAE, a namespace can be bound to only one VPC, and this binding cannot be changed. The binding is established when you create the first SAE job template in the namespace. A single VPC can be associated with multiple namespaces. If you do not specify this parameter, the ID of the VPC that is bound to the namespace is used by default. |
vpc-bp1aevy8sofi8mh1q**** |
| VSwitchId |
string |
No |
The ID of the vSwitch for the elastic network interface of the task instance. The vSwitch must be located in the specified VPC. The vSwitch is also bound to the SAE namespace. If you do not specify this parameter, the ID of the vSwitch that is bound to the namespace is used by default. |
vsw-bp12mw1f8k3jgygk9**** |
| PackageType |
string |
Yes |
The type of the deployment package. Valid values:
|
FatJar |
| PackageVersion |
string |
No |
The version of the deployment package. This parameter is required when PackageType is set to FatJar, War, or PythonZip. |
1.0.1 |
| PackageUrl |
string |
No |
The URL of the deployment package. This parameter is required when PackageType is set to FatJar, War, or PythonZip. |
http://myoss.oss-cn-hangzhou.aliyuncs.com/my-buc/2019-06-30/****.jar |
| ImageUrl |
string |
No |
The URL of the image. This parameter is required when PackageType is set to Image. |
registry.cn-hangzhou.aliyuncs.com/sae_test/ali_sae_test:0.0.1 |
| Jdk |
string |
No |
The JDK version that the deployment package requires. The following versions are supported:
This parameter is not supported when PackageType is set to Image. |
Open JDK 8 |
| WebContainer |
string |
No |
The Tomcat version that the deployment package requires. The following versions are supported:
This parameter is not supported when PackageType is set to Image. |
apache-tomcat-7.0.91 |
| Cpu |
integer |
No |
The CPU required for each instance, in millicores. This value cannot be 0. Only the following fixed specifications are currently supported:
|
1000 |
| Memory |
integer |
No |
The memory required for each instance, in MB. This value cannot be 0. CPU and memory specifications are coupled. The following specifications are currently supported:
|
1024 |
| Replicas |
integer |
Yes |
The number of concurrent task instances. |
3 |
| Command |
string |
No |
The entrypoint command for the container. The command must be an executable inside the container. Example:
For the preceding example, |
echo |
| CommandArgs |
string |
No |
Arguments for the entrypoint command (Command). The format is as follows:
In the example for the |
["a","b"] |
| Envs |
string |
No |
Environment variables to set in the container. To reference variables, the ConfigMap must already exist. For more information, see CreateConfigMap. The value can be configured in one of the following ways:
|
[{"name":"envtmp","value":"0"}] |
| CustomHostAlias |
string |
No |
The host alias that maps a hostname to an IP address in the container. The parameters are described as follows:
|
[{"hostName":"samplehost","ip":"127.0.0.1"}] |
| JarStartOptions |
string |
No |
The startup options for the JAR package. The default startup command is: |
custom-option |
| JarStartArgs |
string |
No |
The startup arguments for the JAR package. The default startup command is: |
-Xms4G -Xmx4G |
| EdasContainerVersion |
string |
No |
The version of the HSF runtime environment for the task, such as an Ali-Tomcat container. |
3.5.3 |
| Timezone |
string |
No |
The time zone. Default value: Asia/Shanghai. |
Asia/Shanghai |
| SlsConfigs |
string |
No |
The configuration for collecting logs to Simple Log Service (SLS).
The parameters are described as follows:
If the log collection configuration does not change during subsequent deployments, you do not need to set this parameter (the request does not need to include the SlsConfigs field). If you no longer need to use the log collection feature, set the value of this parameter to an empty string ("") in your request. Note
SAE deletes a project that it automatically created when you delete the corresponding job template. Therefore, if you specify an existing project, do not use one that was automatically created by SAE. |
[{"logDir":"","logType":"stdout"},{"logDir":"/tmp/a.log"}] |
| NasId |
string |
No |
The ID of the NAS file system. If this configuration does not change in subsequent deployments, you can omit this parameter. To clear the NAS configuration, set this parameter to an empty string (""). |
10d3b4**** |
| MountHost |
string |
No |
The NAS mount target in the VPC of the job template. If this configuration does not change in subsequent deployments, you can omit this parameter. To clear the NAS configuration, set this parameter to an empty string (""). |
10d3b4bc9****.com |
| MountDesc |
string |
No |
The NAS mount description. If this configuration does not change in subsequent deployments, you can omit this parameter. To clear the NAS configuration, set this parameter to an empty string (""). |
[{mountPath: "/tmp", nasPath: "/"}] |
| PreStop |
string |
No |
A PreStop hook. This script runs immediately before the container is stopped. The value must be a JSON string, for example: |
{"exec":{"command":["sh","-c","echo hello"]}} |
| PostStart |
string |
No |
A PostStart hook. This script runs immediately after the container is created. The value must be a JSON string, for example: |
{"exec":{"command":["sh","-c","echo hello"]}} |
| WarStartOptions |
string |
No |
The startup command for a WAR package deployment. The configuration steps are the same as for an image-based deployment. For more information, see Set a startup command. |
CATALINA_OPTS=\"$CATALINA_OPTS $Options\" catalina.sh run |
| ConfigMapMountDesc |
string |
No |
The ConfigMap mount description. Use a ConfigMap created in the namespace to inject configurations into the container. The parameters are described as follows:
Note
You can pass the
|
[{"configMapId":16,"key":"test","mountPath":"/tmp"}] |
| SecurityGroupId |
string |
No |
The security group ID. |
sg-wz969ngg2e49q5i4**** |
| AutoConfig |
boolean |
No |
Specifies whether to automatically configure the network environment. Valid values:
|
false |
| TerminationGracePeriodSeconds |
integer |
No |
The graceful shutdown timeout, in seconds. The value must be an integer from 1 to 300. Default: 30. |
10 |
| PhpConfigLocation |
string |
No |
The mount path of the startup configuration file for a PHP task. You must make sure that the PHP server uses this configuration file on startup. |
/usr/local/etc/php/php.ini |
| PhpConfig |
string |
No |
The content of the PHP configuration file. |
k1=v1 |
| TomcatConfig |
string |
No |
The Tomcat configuration. To delete the configuration, set this parameter to
|
{"port":8080,"contextPath":"/","maxThreads":400,"uriEncoding":"ISO-8859-1","useBodyEncodingForUri":true} |
| OssMountDescs |
string |
No |
The description of the Object Storage Service (OSS) mount. The parameters are described as follows:
|
[{"bucketName": "oss-bucket", "bucketPath": "data/user.data", "mountPath": "/usr/data/user.data", "readOnly": true}] |
| OssAkId |
string |
No |
The AccessKey ID for reading from and writing to OSS. |
xxxxxx |
| OssAkSecret |
string |
No |
The AccessKey secret for reading from and writing to OSS. |
xxxxxx |
| AcrInstanceId |
string |
No |
The ID of the Container Registry (ACR) Enterprise Edition instance. This parameter is required when ImageUrl points to an image in an ACR Enterprise Edition instance. |
cri-xxxxxx |
| AcrAssumeRoleArn |
string |
No |
The Alibaba Cloud Resource Name (ARN) of the RAM role that is required to pull images across accounts. For more information, see Grant permissions to pull images across Alibaba Cloud accounts by using a RAM role. |
acs:ram::123456789012****:role/adminrole |
| ImagePullSecrets |
string |
No |
The ID of the secret used to pull the image. |
10 |
| EnableImageAccl |
boolean |
No |
Specifies whether to enable image acceleration. Valid values:
|
false |
| Workload |
string |
Yes |
The workload. Set the value to |
job |
| TriggerConfig |
string |
No |
The task trigger configuration, which varies based on the task type.
|
{"type":"time","config":"0 1 */1 * ?","timezone":"GMT+8:00"} |
| ConcurrencyPolicy |
string |
No |
The concurrency policy for the task. Valid values:
|
Allow |
| Timeout |
integer |
No |
The task timeout, in seconds. |
3600 |
| BackoffLimit |
integer |
No |
The maximum number of retries for a task before it is marked as failed. |
3 |
| Slice |
boolean |
No |
Specifies whether to enable task sharding. |
true |
| SliceEnvs |
string |
No |
The parameters for task sharding. |
[0,1,2] |
| RefAppId |
string |
No |
The ID of the referenced job. |
7171a6ca-d1cd-4928-8642-7d5cfe69**** |
| ProgrammingLanguage |
string |
No |
The programming language. Valid values: java, php, python, and shell. |
java |
| Python |
string |
No |
The Python environment. PYTHON 3.9.15 is supported. |
PYTHON 3.9.15 |
| PythonModules |
string |
No |
Python dependencies to install by using pip. If you do not set this parameter, SAE installs dependencies from the 'requirements.txt' file in the root directory of your project. |
Flask==2.0 |
| NasConfigs |
string |
No |
The configurations for mounting a NAS file system. |
|
| BestEffortType |
string |
No |
The BestEffort policy. |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
Details of the created job template. |
||
| RequestId |
string |
The request ID. |
01CF26C7-00A3-4AA6-BA76-7E95F2A3*** |
| Message |
string |
Additional information. Valid values:
|
success |
| TraceId |
string |
The call trace ID. You can use this ID to query detailed information about the call. |
ac1a0b2215622246421415014e**** |
| Data |
object |
The returned data. |
|
| ChangeOrderId |
string |
The change order ID. You can use this ID to check the execution status of the task. |
01db03d3-3ee9-48b3-b3d0-dfce2d88**** |
| AppId |
string |
The job template ID. |
7171a6ca-d1cd-4928-8642-7d5cfe69**** |
| ErrorCode |
string |
The error code.
|
|
| Code |
string |
The HTTP status code or a POP error code. Valid values:
|
200 |
| Success |
boolean |
Indicates whether the job template was created successfully. Valid values:
|
true |
Examples
Success response
JSON format
{
"RequestId": "01CF26C7-00A3-4AA6-BA76-7E95F2A3***",
"Message": "success",
"TraceId": "ac1a0b2215622246421415014e****",
"Data": {
"ChangeOrderId": "01db03d3-3ee9-48b3-b3d0-dfce2d88****",
"AppId": "7171a6ca-d1cd-4928-8642-7d5cfe69****"
},
"ErrorCode": "",
"Code": "200",
"Success": true
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | Application.MissingJdk | Your application must at least contain a JDK component. | |
| 400 | InvalidPackageType.NotFound | The package type must be War, FatJar, or Image. | |
| 400 | InvalidParameter.FileName | The application deployment package name is invalid. This name can contain only alphanumeric characters, hyphens (-), and underscores (_). In addition, you can upload JAR files only if the selected deployment version supports JAR file. Otherwise, upload WAR files only. | |
| 400 | InvalidParameter.NotEmpty | You must specify the parameter %s. | |
| 400 | InvalidParameter.Obviously | The specified parameter is invalid {%s}. | |
| 400 | JarApplication.MissingJdk | A FatJar application must contain JDK. | |
| 400 | NoAvailableCluster.NotFound | No clusters are available for the current region. | |
| 400 | NoComputeResourceQuota.Exceed | Your compute resource is insufficient. Please contact us to raise the quota. | |
| 400 | PandoraApplication.MissingJdk | The Pandora application is missing a JDK component. | |
| 400 | PandoraApplication.OnlyJdk | A Pandora application only requires JDK component. | |
| 400 | InvalidParameter.WithMessage | The parameter is invalid {%s}: %s | |
| 400 | InvalidComponent.NotFound | The current component (such as JDK, Tomcat, or EDASWebContainer) does not exist. | |
| 400 | InvalidHostnameIp.Invalid | The hostname and/or IP is invalid: Hostname [%s], IP [%s]. | |
| 400 | InvalidInstanceSpecification.Unsupported | The instance specification is not supported: CPU [%s], memory [%s]. | |
| 400 | InvalidServerlessRegion.Unsupported | The current region is not supported: %s | |
| 400 | WarApplication.MissingJdkWebcontainer | A War application must contain JDK and Tomcat. | |
| 400 | InvalidNamespace.WithUppercase | This namespace does not support creating SAE apps because it contains uppercase letters. | |
| 400 | LogService.ConfigQuotaExceed | The maximum number of Log Service configs is exceeded. | The maximum number of Log Service configs is exceeded, please join the DingTalk group 32874633 for technical support. |
| 400 | LogService.InternalError | An exception occurred while calling Log Service. Please submit a ticket to solve the problem. | An exception occurred while calling log service. please join the DingTalk group 32874633 for technical support. |
| 400 | LogService.LogDirInvalid | The log collection path is invalid. | The log collection path is invalid. |
| 400 | LogService.NotAvailable | Log Service is unavailable. Please activate Log Service first. | The log service is not available. Please open the log service first. |
| 400 | LogService.ProjectNumQuotaExceed | The maximum number of Log Service projects is exceeded. | The maximum number of Log Service projects is exceeded, please join the DingTalk group 32874633 for technical support. |
| 400 | vswitch.not.exist | The specified VSwitch does not exist. | |
| 400 | user.indebt | The user has an outstanding payment. | |
| 400 | NoComputeResourceQuota.App.Exceed | You can create %s instances for each application. Please submit a ticket to raise the quota. | You can create %s instances for each application. please join the DingTalk group 32874633 for technical support. |
| 400 | NoComputeResourceQuota.User.Exceed | Your account is limited to create %s instances. Please submit a ticket to raise the quota. | Your account is limited to create %s instances. please join the DingTalk group 32874633 for technical support. |
| 400 | System.Upgrading | The system is being upgraded. Please try again later. | |
| 400 | VolumnPath.Conflict | Conflict between log collection directory and persistent storage directory. | Conflict between log collection directory and persistent storage directory. |
| 400 | MountConflict.ConfigMap | Conflict detected for ConfigMap path %s. | |
| 400 | NotFound.ConfigMap | The ConfigMap object (ID: %s) does not exist. | |
| 400 | NotFound.ConfigMapKey | The key %s of ConfigMap object (ID: %s) does not exist. | |
| 400 | Sls.Config.Mixed.Multi.Project | The specified Config contains multiple projects. | |
| 400 | Sls.Config.User.Defined.Missing.Logstore.Info | The specified Config is invalid. Both Project and Logstore must be specified. | |
| 400 | Sls.Config.User.Defined.Missing.Project.Info | The specified Config is invalid. Both Project and Logstore must be specified. | |
| 400 | Sls.Logstore.Name.Invalid | The specified name of Logstore is invalid. The Logstore name must not contain the prefix "sae-". | |
| 400 | Sls.Logstore.User.Defined.Not.Exist | The user defined Logstore does not exist. | |
| 400 | Sls.Project.Name.Invalid | The specified project name is invalid. The project name must not contain the prefix "sae-". | |
| 400 | Sls.Project.User.Defined.Not.Exist | The user defined project does not exist. | |
| 400 | InvalidImageUrl.AcrInstanceId.Domain.NotMatch | The specified domain of ImageUrl does not match AcrInstanceId domains. | |
| 400 | PhpApplication.MissingPhpRuntime | A PHP application must contain PHP Runtime. | |
| 404 | Associate.Eip.Not.Enough | No sufficient EIPs are available. | |
| 404 | InvalidNamespaceId.NotFound | The specified NamespaceId does not exist. | |
| 404 | InvalidVpcId.NotFound | The specified VpcId does not exist. | |
| 404 | InvalidAcrInstanceId.NotFound | The specified AcrInstanceId does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.