azure-cli icon indicating copy to clipboard operation
azure-cli copied to clipboard

`az containerapp job start` option to wait for job to finish

Open paulirwin opened this issue 7 months ago • 2 comments

Related command az containerapp job start

Is your feature request related to a problem? Please describe. No

Describe the solution you'd like I have a Container App job that I would like to invoke from an Azure DevOps pipeline, and need to know if it completed successfully or failed so that I can mark the pipeline as succeeded or failed. I would like an option on az containerapp job start that waits for the job to finish, and returns a 0 exit code if the job finished successfully, and non-zero exit code upon job execution failure.

Describe alternatives you've considered az containerapp job start returns the name of the execution instance. You can then loop and poll via az containerapp job execution show, however, this requires a fair amount of custom scripting for something that feels like it should be a capability of the CLI.

Additional context This is similar to the feature request for Azure PowerShell: https://github.com/Azure/azure-powershell/issues/27062

paulirwin avatar Apr 21 '25 22:04 paulirwin

Thank you for opening this issue, we will look into it.

yonzhan avatar Apr 21 '25 22:04 yonzhan

This is also related to terraform issue https://github.com/hashicorp/terraform-provider-azurerm/issues/26885

saliceti avatar Jun 12 '25 20:06 saliceti

I would like this feature as well. It would be extremely helpful because it would simplify a lot of the custom scripting required today.

I also have a question for @paulirwin (or anyone else who has implemented a similar loop): In your polling script using az containerapp job execution show, do you always get a valid status back in the loop?

In my case, if a job runs for more than an hour, the az containerapp job execution show command consistently returns null after about 60 minutes. The job itself completes successfully after ~70–75 minutes, but the CLI stops returning the status, which breaks the polling logic.

Have you experienced something similar? Or found a reliable workaround?

marcosolina avatar Nov 07 '25 09:11 marcosolina

@marcosolina The job I run via my polling script is expected to complete in under a minute or so; if it ran that long I'd be having a bad day. I haven't tested it in that scenario. Sorry!

paulirwin avatar Nov 07 '25 14:11 paulirwin

Thank @paulirwin I think I just found a possible reason. Pipeline task timeout. If run the same polling loop (i jsut made it as a template) in a new step it is able to retrieve the status after the 60 minutes issue. Posting here in case it can help somebody else with long running jobs until hopefully we get the suggested "wait" option in the start command

marcosolina avatar Nov 07 '25 14:11 marcosolina