Manage and use jobs in the Azure Spring Apps Enterprise plan

Note

Azure Spring Apps is the new name for the Azure Spring Cloud service. Although the service has a new name, you'll see the old name in some places for a while as we work to update assets such as screenshots, videos, and diagrams.

This article applies to: ❌ Basic/Standard ✔️ Enterprise

This article shows you how to manage the lifecycle of a job and run it in the Azure Spring Apps Enterprise plan.

Prerequisites

Create and deploy a job

Use the following commands to create and deploy a job:

az spring job create --name <job-name>
az spring job deploy \
    --name <job-name> \
    --artifact-path <artifact-path>

For the public preview, you can create a maximum of 10 jobs per service instance.

Start and cancel a job execution

Use the following command to start a job execution:

az spring job start --name <job-name>

If the command runs successfully, it returns the name of the job execution. With the --wait-until-finished true parameter, the command doesn't return until the job execution finishes.

To query the status of the job execution, use the following command. Replace the <execution-name> with the name returned from the start command.

az spring job execution show \
    --job <job-name> \
    --name <execution-name>

To cancel the job executions that are running, use the following command:

az spring job execution cancel \
    --job <job-name> \
    --name <execution-name>

Query job execution history

To show the execution history, use the following command:

az spring job execution list --job <job-name>

For the public preview, the latest 10 completed or failed job execution records per job are retained in history.

Query job execution logs

To get the history of job executions in the Azure portal, use the following Log Analytics query:

AppPlatformLogsforSpring
| where AppName == '<job-name>' and InstanceName startswith '<execution-name>'
| order by TimeGenerated asc

For more information, see Quickstart: Set up a Log Analytics workspace.

For real time logs, use the following command on the command line:

az spring job logs \
    --name <job-name> \
    --execution <execution-name>

If there are multiple instances for the job execution, specify --instance <instance-name> to view the logs for one instance only.

Rerun job execution

Use the following command to trigger a new job execution:

az spring job start \
    --name <job-name> \
    --args <argument-value> \
    --envs <key=value>

Integrate with managed components

For the public preview, jobs can integrate seamlessly with Spring Cloud Config Server for efficient configuration management and Tanzu Service Registry for service discovery.

Integrate with Spring Cloud Config Server

With Spring Cloud Config Server, you can manage the configurations or properties required by a job in Git repositories, and then load them into the job. After setting up Git repo configurations for Spring Cloud Config Server, you need to bind the jobs to the server.

Use the following command to bind the job to Spring Cloud Config Server during job creation:

az spring job create \
    --name <job-name> \
    --bind-config-server true

For existing jobs, use the following command to bind them to Spring Cloud Config Server:

az spring config-server bind --job <job-name>

If you no longer need Spring Cloud Config Server for your jobs, you can unbind them from it. This change takes effect on new job executions.

Use the following command to unbind a job:

az spring config-server unbind --job <job-name>

Integrate with Tanzu Service registry

It's common for a job to call an API from a long-running app in collaboration to query for information, notifications, and so forth. To enable the job to discover apps running in the same Azure Spring Apps service, you can bind both your apps and jobs to a managed service registry. The following section describes how to bind a job to Tanzu Service Registry.

Use the following command to bind a job to Tanzu Service Registry during job creation:

az spring job create --bind-service-registry true

For existing jobs, use the following command to bind them to Tanzu Service Registry:

az spring service-registry bind --job <job-name>

When you run the job execution, it can access endpoints of registered apps through the service registry.

If you no longer need the service registry for your jobs, you can unbind them from it. This change takes effect on new job executions.

Use the following command to unbind the job:

az spring service-registry unbind --job <job-name>

See also

Job in Azure Spring Apps