CreateJob
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 digits, letters, and hyphens (-). It must start with a letter and can be up to 36 characters in length. |
test |
| NamespaceId |
string |
No |
The ID of the Serverless App Engine (SAE) namespace. Only namespaces whose names contain lowercase letters and hyphens (-) and start with a letter are supported. |
cn-beijing:test |
| AppDescription |
string |
No |
The description of the job template. The description can be up to 1,024 characters in length. |
This is a test description. |
| VpcId |
string |
No |
The ID of the virtual private cloud (VPC) that is associated with the SAE namespace. In SAE, a namespace can be associated with only one VPC, and the association cannot be modified. The association is established when you create the first SAE job template in the namespace. Multiple namespaces can be associated with the same VPC. If you do not specify this parameter, the ID of the VPC that is associated with the namespace is used by default. |
vpc-bp1aevy8sofi8mh1q**** |
| VSwitchId |
string |
No |
The vSwitch to which the elastic network interface controller (NIC) of the job instance belongs. The vSwitch must reside in the specified VPC. The vSwitch is also associated with the SAE namespace. If you do not specify this parameter, the ID of the vSwitch associated with the namespace is used by default. |
vsw-bp12mw1f8k3jgygk9**** |
| PackageType |
string |
Yes |
The type of the job 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 Java Development Kit (JDK) version on which the deployment package depends. Valid values:
This parameter is not supported when PackageType is set to Image. |
Open JDK 8 |
| WebContainer |
string |
No |
The Tomcat version on which the deployment package depends. Valid values:
This parameter is not supported when PackageType is set to Image. |
apache-tomcat-7.0.91 |
| Cpu |
integer |
No |
The number of CPU cores required for each instance. Unit: millicores. The value cannot be 0. Only the following defined specifications are supported:
|
1000 |
| Memory |
integer |
No |
The memory size required for each instance. Unit: MB. The value cannot be 0. The memory size has a one-to-one mapping with the number of CPU cores. Only the following defined specifications are supported:
|
1024 |
| Replicas |
integer |
Yes |
The number of concurrent instances for the job. |
3 |
| Command |
string |
No |
The startup command of the image. The command must be an executable object that exists in the container. Example:
Based on the preceding example, set Command to "echo" and CommandArgs to ["abc", ">", "file0"]. |
echo |
| CommandArgs |
string |
No |
The arguments for the image startup command. These are the arguments required by the startup command Command. The format is as follows:
In the preceding example, |
["a","b"] |
| Envs |
string |
No |
The environment variables for the container. You can specify custom environment variables or reference ConfigMaps. To reference a ConfigMap, create a ConfigMap instance first. For more information, see CreateConfigMap. Valid values:
|
[{"name":"envtmp","value":"0"}] |
| CustomHostAlias |
string |
No |
The custom host mappings in the container. Valid values:
|
[{"hostName":"samplehost","ip":"127.0.0.1"}] |
| JarStartOptions |
string |
No |
The startup options for the JAR package. Default job startup command: |
custom-option |
| JarStartArgs |
string |
No |
The startup arguments for the JAR package. Default job startup command: |
-Xms4G -Xmx4G |
| EdasContainerVersion |
string |
No |
The runtime environment version for the job in the High-Speed Service Framework (HSF), such as the Ali-Tomcat container version. |
3.5.3 |
| Timezone |
string |
No |
The time zone. Default value: Asia/Shanghai. |
Asia/Shanghai |
| SlsConfigs |
string |
No |
The configurations for collecting logs to Simple Log Service (SLS).
Parameter descriptions:
If the SLS collection configurations remain unchanged during subsequent deployments, you do not need to specify this parameter (that is, you do not need to include the SlsConfigs field in the request). If you no longer need the SLS collection feature, set this field to an empty character string (that is, set SlsConfigs to "" in the request). Note
The project automatically created with the job template is deleted when the job template is deleted. Therefore, when selecting an existing project, you cannot select a project automatically created by SAE. |
[{"logDir":"","logType":"stdout"},{"logDir":"/tmp/a.log"}] |
| NasId |
string |
No |
The ID of the Apsara File Storage NAS file system. If the configurations remain unchanged during deployment, you do not need to set this parameter (that is, you do not need to include the NasId field in the request). To clear the NAS configurations, set this field to an empty string (that is, set NasId to "" in the request). |
10d3b4**** |
| MountHost |
string |
No |
The mount target of the NAS file system in the VPC of the job template. If the configurations remain unchanged during deployment, you do not need to set this parameter (that is, you do not need to include the MountHost field in the request). To clear the NAS configurations, set this field to an empty string (that is, set MountHost to "" in the request). |
10d3b4bc9****.com |
| MountDesc |
string |
No |
The description of the NAS mount. If the configurations remain unchanged during deployment, you do not need to set this parameter (that is, you do not need to include the MountDesc field in the request). To clear the NAS configurations, set this field to an empty string (that is, set MountDesc to "" in the request). |
[{mountPath: "/tmp", nasPath: "/"}] |
| PreStop |
string |
No |
The script to execute before the container stops. A script is triggered and executed before the container is deleted. Format: |
{"exec":{"command":["sh","-c","echo hello"]}} |
| PostStart |
string |
No |
The script to execute after the container starts. A script is triggered and executed immediately after the container is created. Format: |
{"exec":{"command":["sh","-c","echo hello"]}} |
| WarStartOptions |
string |
No |
The startup command for the WAR package deployment job. The procedure is the same as that for configuring the startup command for image deployment. For more information, see Configure a startup command. |
CATALINA_OPTS=\"$CATALINA_OPTS $Options\" catalina.sh run |
| ConfigMapMountDesc |
string |
No |
The mount description of the ConfigMap. Uses the configuration items created on the configuration item page of the namespace to inject configuration information into the container. Parameter descriptions:
Note
You can pass the
|
[{"configMapId":16,"key":"test","mountPath":"/tmp"}] |
| SecurityGroupId |
string |
No |
The ID of the security group. |
sg-wz969ngg2e49q5i4**** |
| AutoConfig |
boolean |
No |
Specifies whether to automatically configure the network environment. Valid values:
|
false |
| TerminationGracePeriodSeconds |
integer |
No |
The timeout period for graceful shutdown. Default value: 30. Unit: seconds. Valid values: 1 to 300. |
10 |
| PhpConfigLocation |
string |
No |
The mount path for the PHP job startup configuration. You must ensure that the PHP server uses this configuration file to start. |
/usr/local/etc/php/php.ini |
| PhpConfig |
string |
No |
The content of the PHP configuration file. |
k1=v1 |
| TomcatConfig |
string |
No |
The Tomcat configuration. Set this parameter to "" or "{}" to delete the configuration. Valid values:
|
{"port":8080,"contextPath":"/","maxThreads":400,"uriEncoding":"ISO-8859-1","useBodyEncodingForUri":true} |
| OssMountDescs |
string |
No |
The description of the Object Storage Service (OSS) mount. Parameter descriptions:
|
[{"bucketName": "oss-bucket", "bucketPath": "data/user.data", "mountPath": "/usr/data/user.data", "readOnly": true}] |
| OssAkId |
string |
No |
The AccessKey ID used to read and write OSS data. |
DemoAK****cdefgh |
| OssAkSecret |
string |
No |
The AccessKey Secret used to read and write OSS data. |
DemoSecretabc****hijklmnopqrst |
| AcrInstanceId |
string |
No |
The instance ID of the Container Registry (ACR) Enterprise instance. This parameter is required when ImageUrl is set to an ACR Enterprise instance image. |
cri-xxxxxx |
| AcrAssumeRoleArn |
string |
No |
The Alibaba Cloud Resource Name (ARN) of the Resource Access Management (RAM) role required to pull images across accounts. For more information, see Use a RAM role to authorize access across Alibaba Cloud accounts. |
acs:ram::123456789012****:role/adminrole |
| ImagePullSecrets |
string |
No |
The ID of the secret. |
10 |
| EnableImageAccl |
boolean |
No |
Specifies whether to enable image acceleration. Valid values:
|
false |
| Workload |
string |
Yes |
The workload type. Set the value to |
job |
| TriggerConfig |
string |
No |
The trigger configuration of the job. Configure this parameter based on the job type.
|
{"type":"time","config":"0 1 */1 * ?","timezone":"GMT+8:00"} |
| ConcurrencyPolicy |
string |
No |
The concurrency policy of the job. Valid values:
|
Allow |
| Timeout |
integer |
No |
The timeout period of the job. Unit: seconds. |
3600 |
| BackoffLimit |
integer |
No |
The number of retries for the job. |
3 |
| Slice |
boolean |
No |
Specifies whether to enable job sharding. |
true |
| SliceEnvs |
string |
No |
The sharding parameters of the job. |
[0,1,2] |
| RefAppId |
string |
No |
The ID of the referenced job target. |
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. Valid value: PYTHON 3.9.15. |
PYTHON 3.9.15 |
| PythonModules |
string |
No |
The custom installation module dependencies. By default, the dependencies defined in the requirements.txt file in the root folder are installed. If no dependencies are configured or custom packages are used, you can specify the dependencies to install. |
Flask==2.0 |
| NasConfigs |
string |
No |
The configurations for mounting the NAS file system. |
[{"mountPath":"/test1","readOnly":false,"nasId":"nasId1","mountDomain":"nasId1.cn-shenzhen.nas.aliyuncs.com","nasPath":"/test1"},{"nasId":"nasId2","mountDomain":"nasId2.cn-shenzhen.nas.aliyuncs.com","readOnly":false,"nasPath":"/test2","mountPath":"/test2"}] |
| BestEffortType |
string |
No |
The BestEffort policy. |
besteffort |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The information about the created job template. |
||
| RequestId |
string |
The request ID. |
01CF26C7-00A3-4AA6-BA76-7E95F2A3*** |
| Message |
string |
The additional information. Valid values:
|
success |
| TraceId |
string |
The trace ID used to accurately query the call information. |
ac1a0b2215622246421415014e**** |
| Data |
object |
The returned result. |
|
| ChangeOrderId |
string |
The ID of the returned change order, which is used to query the job execution status. |
01db03d3-3ee9-48b3-b3d0-dfce2d88**** |
| AppId |
string |
The ID of the job template. |
7171a6ca-d1cd-4928-8642-7d5cfe69**** |
| ErrorCode |
string |
The error code. Valid values:
|
Application.MissingJdk |
| Code |
string |
The HTTP status code or POP error code. Valid values:
|
200 |
| Success |
boolean |
Indicates whether the job template was created. 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": "Application.MissingJdk",
"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. | The application must contain at least a JDK component. |
| 400 | InvalidPackageType.NotFound | The package type must be War, FatJar, or Image. | 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. | Invalid parameter: %s cannot be empty. |
| 400 | InvalidParameter.Obviously | The specified parameter is invalid {%s}. | Invalid parameter {%s}. |
| 400 | JarApplication.MissingJdk | A FatJar application must contain JDK. | FatJar applications must include a JDK. |
| 400 | NoAvailableCluster.NotFound | No clusters are available for the current region. | No available clusters exist in 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. | The Pandora application is missing the JDK component. |
| 400 | PandoraApplication.OnlyJdk | A Pandora application only requires JDK component. | The Pandora application requires only the JDK component. |
| 400 | InvalidParameter.WithMessage | The parameter is invalid {%s}: %s | Invalid parameter {%s}: %s. |
| 400 | InvalidComponent.NotFound | The current component (such as JDK, Tomcat, or EDASWebContainer) does not exist. | The specified component (JDK, Tomcat, EDASWebContainer, etc.) cannot be found. |
| 400 | InvalidHostnameIp.Invalid | The hostname and/or IP is invalid: Hostname [%s], IP [%s]. | The hostname or IP address is invalid: hostname [%s], IP [%s]. |
| 400 | InvalidInstanceSpecification.Unsupported | The instance specification is not supported: CPU [%s], memory [%s]. | The instance type is not supported. CPU [%s], Memory [%s]. |
| 400 | InvalidServerlessRegion.Unsupported | The current region is not supported: %s | The specified region is not supported: %s. |
| 400 | WarApplication.MissingJdkWebcontainer | A War application must contain JDK and Tomcat. | WAR-type applications must include JDK and Tomcat. |
| 400 | InvalidNamespace.WithUppercase | This namespace does not support creating SAE apps because it contains uppercase letters. | The namespace does not support creating Serverless App Engine (SAE) applications 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. | The current user has an overdue 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. | The system is being upgraded. 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. | The ConfigMap mount path %s conflicts with an existing path. |
| 400 | NotFound.ConfigMap | The ConfigMap object (ID: %s) does not exist. | The ConfigMap object (ID=%s) was not found. |
| 400 | NotFound.ConfigMapKey | The key %s of ConfigMap object (ID: %s) does not exist. | The key %s of the ConfigMap object (ID=%s) was not found. |
| 400 | Sls.Config.Mixed.Multi.Project | The specified Config contains multiple projects. | The SLS configuration that you specified contains multiple projects. |
| 400 | Sls.Config.User.Defined.Missing.Logstore.Info | The specified Config is invalid. Both Project and Logstore must be specified. | The SLS configuration that you specified is a custom SLS configuration, but it contains only the Project configuration. The Logstore configuration is missing. |
| 400 | Sls.Config.User.Defined.Missing.Project.Info | The specified Config is invalid. Both Project and Logstore must be specified. | The SLS configuration that you specified is a custom SLS configuration, but it contains only the Logstore configuration. The Project configuration is missing. |
| 400 | Sls.Logstore.Name.Invalid | The specified name of Logstore is invalid. The Logstore name must not contain the prefix "sae-". | The SLS Logstore name that you specified is invalid. The name contains the prefix "sae-", which causes obfuscation with Logstores that are subject to automatic creation by SAE. |
| 400 | Sls.Logstore.User.Defined.Not.Exist | The user defined Logstore does not exist. | The custom Logstore that you specified does not exist. |
| 400 | Sls.Project.Name.Invalid | The specified project name is invalid. The project name must not contain the prefix "sae-". | The SLS Project name that you specified is invalid. The name contains the prefix "sae-", which causes obfuscation with projects that are subject to automatic creation by SAE. |
| 400 | Sls.Project.User.Defined.Not.Exist | The user defined project does not exist. | The custom project that you specified does not exist. |
| 400 | InvalidImageUrl.AcrInstanceId.Domain.NotMatch | The specified domain of ImageUrl does not match AcrInstanceId domains. | The domain name of the specified ImageUrl does not match the domain name of the AcrInstanceId. |
| 400 | PhpApplication.MissingPhpRuntime | A PHP application must contain PHP Runtime. | A PHP application must include the PHP runtime. |
| 404 | Associate.Eip.Not.Enough | No sufficient EIPs are available. | Insufficient elastic IP addresses (EIPs) are available for binding. Purchase EIPs first. |
| 404 | InvalidNamespaceId.NotFound | The specified NamespaceId does not exist. | The specified NamespaceId does not exist. |
| 404 | InvalidVpcId.NotFound | The specified VpcId does not exist. | The specified VpcId does not exist. |
| 404 | InvalidAcrInstanceId.NotFound | The specified AcrInstanceId does not exist. | The specified AcrInstanceId does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.