Container App Job to Retrieve the Replica Name

John Wong Yek Hon 100 Reputation points
2024-12-17T06:33:00.79+00:00

Here's what I wish to build:-

I will deploy my backend jobs as Azure Container App Job. Whenever new message published to Service Bus, new replica will be auto created to process the message accordingly.

So 1 message -> 1 replica -> 1 job. And my job access to Cosmos DB. Inside my job process, I wish to retrieve / extract the replica name and keep it into the DB. And I wish to build a web page for end user to destroy / terminate particular replica based on the replica name.

I know Azure portal do provide the page to list out all the replicas and run history, however my end user will not have access to this, moreover I need to present more details about each job.

So here's my questions:

  1. Is there a way for the job process to retrieve the replica name?
  2. Is there a way to terminate / destroy particular replica programmatically.

Thanks.

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

1 answer

Sort by: Most helpful
  1. VenkateshDodda-MSFT 23,141 Reputation points Microsoft Employee
    2024-12-19T05:37:04.92+00:00

    @John Wong Yek Hon Thanks for your patience on this. I have checked with Container Apps engineering team on this and sharing the below.

    • Is there a way for the job process to retrieve the replica name?

    You can use the environment variable CONTAINER_APP_JOB_EXECUTION_NAME to retrieve the job Name and to further save in Cosmos DB.

    • Is there a way to terminate / destroy particular replica programmatically. -->

    In your webapp you can call the ARM stop job execution API to stop the job execution by using the Job name. If there is a supported management SDK for your language used, they can use them as well.

    Example: ContainerAppJobExecutionResource.StopExecutionJobAsync Method (Azure.ResourceManager.AppContainers) - Azure for .NET Developers | Microsoft Learn 

    Hope this helps, let me know if you have any further questions on this.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.