0

I have a curious issue getting a docker container set up to run and exit properly in an Azure logic app.

I have a python script that prints hello world, then sleeps for 30 minutes. The reason for sleeping is to make the script run longer so that I can test if the container in the logic app exits at the right moment, when the script is done running and not when the loop times out.

First, I confirm that the container is running properly and exiting properly in powershell:

    PS C:\Users\cgiltner> docker run helloworld
    Running 'Hello World' at 2019-11-26 17:53:48
    Hello, World!
    Sleeping for 30 minutes...
    Awake after 30 minutes
    PS C:\Users\cgiltner>

I have the container set up in a logic app as follows, there is an “Until” loop that is configured to run until “State” = “succeeded”

But when I run it, the “until” loop continues for 1 hour, which is the default timeout period for an until loop (PT1H)

Looking at the properties of the container, I can see that the state of the container never changed from “Running”

Just to clarify, the container IS running and executing the script/docker container successfully. The problem is that it is not exiting when the script is actually done, rather it is waiting until the timeout period is done. There is not an error message or any failure indicating that it times out, it just simply moves to the next step. This has big implications in a complex logic app where multiple steps need to happen after containers run, it causes things to take hours in the app.

1 Answers1

0

For your issue, what you need to know first is that your first action of the Logic App is creating the Azure Container Instance, but when the Logic App action has done, the creation of the Azure Container Instance still be not finished. It only returns a pending state and will not update. In your second action, you expect the succeeded state in the Until action. So the result is that the action will delay until timeout.

The solution is that you need to add a pure delay action behind the creation of the Azure Container Instance. Then add the action to get the properties and logs of the containers in the container group.

Charles Xu
  • 29,862
  • 2
  • 22
  • 39
  • So you're saying: Create container --> delay --> get properties --> get logs? Without an Until loop? – cgiltner-pk Dec 02 '19 at 17:52
  • @cgiltner-pk Correct. – Charles Xu Dec 03 '19 at 01:18
  • Thanks, that's a little disheartening that logic apps doesn't have functionality to tell when a docker container is done running. If it runs for 10 minutes one day, and another day it runs for 4 hours, I would have to put a 4 hour delay in no matter what in order for it to finish properly. Bummer. – cgiltner-pk Dec 04 '19 at 02:25
  • @cgiltner-pk You cannot judge by the previous action of the logic, but you can try to get the container group state first and then judge according to it. – Charles Xu Dec 04 '19 at 02:30