Goblet Cloud Run Jobs on cloud function

Good day,

I have been reading the goblet documentation because I would like to create a function to create a cloud run job and execute it (in cloud function) but I am not clear how to create a Cloud Run Job from scratch with the resources I my image from container registry, does anyone have any example code or could you help me to figure out this? pleas

thanks in advance

In this scenario, you would need to use the Cloud Run client for Python. Even though it’s a preview release of the client, it supports programmatically managing Cloud Run Jobs. There are code samples available in the repository, for example, on how to create a Job:

from google.cloud import run_v2

def sample_create_job():
    # Create a client
    client = run_v2.JobsClient()

    # Initialize request argument(s)
    job = run_v2.Job()
    job.template.template.max_retries = 1187

    request = run_v2.CreateJobRequest(
        parent="parent_value",
        job=job,
        job_id="job_id_value",
    )

    # Make the request
    operation = client.create_job(request=request)

    print("Waiting for operation to complete...")
    response = operation.result()

    print(response)

There is also a Job reference with details about the required configuration of a Job.