Configure or find the executing azure container job name

Singh, Rahul 1 Reputation point
2024-05-23T19:40:34.1766667+00:00

I have a simple dotnet application, deployed as a container in Azure container app jobs. It is configured as event-driven job and is triggered by a message in azure service bus queue. Everything is working fine but I want to stop a particular job execution. Is there any way to find the executing job name (k8 pod)? We can simply stop it using REST api:-

az rest --method POST --url  https://management.azure.com/
                             subscriptions/$SUBSCRIPTION/
                             resourceGroups/$RESOURCE_GROUP/providers/
                             Microsoft.App/jobs/$JobName/
                             executions/$jobExecutionName/stop

But to run this, I need the $jobExecutionName. In my code, I tried to grab the HostName environment variable:-

var hostName = Environment.GetEnvironmentVariable("HOSTNAME");

But it's returning the Container Group Name instead of the actual instance name.

Azure Container Apps
Azure Container Apps
An Azure service that provides a general-purpose, serverless container platform.
307 questions
{count} votes

1 answer

Sort by: Most helpful
  1. LeelaRajeshSayana-MSFT 13,871 Reputation points
    2024-05-23T23:07:08.9666667+00:00

    Hi @Singh, Rahul Thank you for posting the question on this forum.

    You can use the following command az containerapp job execution list --name <jobname> --resource-group <ResourceGroupName> --output table to get a list of all the executions of a Container App Job including the running instances. Please refer the following image for reference.

    enter image description here

    You can use the Job Execution Name returned from the above list in the Job Stop API

    Just for your information, you can stop multiple instances of the job by using the Stop Multiple Executions. You would just need a job name to work with the end point.

    Hope this helps. Please let us know if you need any additional assistance.


    If the response helped, please do click Accept Answer and Yes for the answer provided. Doing so would help other community members with similar issue identify the solution. I highly appreciate your contribution to the community.