Create a job template in Serverless App Engine (SAE) to run tasks on a schedule or trigger them with an HTTP/HTTPS request. SAE releases compute resources as soon as the job finishes.
Use cases
Job tasks suit asynchronous, offline scenarios that are not latency-sensitive. They can run once or on a recurring schedule—for example, generating batch data reports or sending promotional coupons at a scheduled time.
Before you begin
Ensure that you have activated Serverless App Engine (SAE) and EventBridge and granted the necessary permissions.
Run a periodic job task
-
Go to the SAE Job Templates page. At the top, select the target region and namespace, then click Create Job Template. Configure the following parameters.
-
Enter a custom Job Template Name.
-
For the deployment method, select Select Image Deployment. You can use the default demo image for this tutorial. In a real-world scenario, you can click Specify Image to specify a different image for your job.
-
Leave the other parameters at their default settings and click Next.
-
-
In the Job Settings section, configure the following parameters.
-
For Job Type, select Periodic Job.
-
Set the Cron Expression to
*/1 * * * ?. This expression runs the job once per minute. -
Leave the other parameters at their default settings and click Create. Wait for the job template to be created.
-
-
In the left-side navigation pane, click Job Records to view the records of the automatically executed jobs. Click the refresh icon in the upper-right corner of the page to see the latest results.
-
In the left-side navigation pane, click to view the results of the latest job execution. For this example, the program prints a sequence of numbers to the console.
Trigger a one-time job via HTTP/HTTPS
-
Go to the SAE Job Templates page. At the top, select the target region and namespace, then click Create Job Template. Configure the following parameters.
-
Enter a custom Job Template Name.
-
For the deployment method, select Select Image Deployment. You can use the default demo image for this tutorial. In a real-world scenario, you can click Specify Image to specify a different image for your job.
-
Leave the other parameters at their default settings and click Next.
-
-
In the Job Settings section, configure the following parameters.
-
For Job Type, select One-time Job.
-
For Request Type, select HTTP&HTTPS. This allows both HTTP and HTTPS requests to trigger the job.
-
For Request Method, select GET and POST. This allows both GET and POST requests to trigger the job.
-
Leave the other parameters at their default settings and click Create. Wait for the job template to be created.
-
-
On the Job Template Details page, find the Job Settings section. Copy the public request URL, paste it into your browser's address bar, and press Enter to trigger the job.
-
In the left-side navigation pane, click Job Records to view the record of this single job execution. Click the refresh icon in the upper-right corner of the page to see the latest results.
-
In the left-side navigation pane, click to view the results of the latest job execution. For this example, the program prints a sequence of numbers to the console.
Clean up resources
After completing this tutorial, delete the resources you created if you no longer need them. Otherwise, charges continue to accrue.
Go to the SAE Job Templates page. At the top, select the target region and namespace, and find the job template you created. In the Actions column, click Delete and follow the on-screen instructions.
Next steps
You can also create a job template from an application image, a code package, or a Shell script. For more information, see Manage job templates.