Adventures with Logic Apps: Determine the State of a Logic App

In a previous article, Adventures with Logic Apps: Enabling/Disabling a Logic App from Another Logic App, I created a Logic App that would disable a Logic App and then re-enable it after a specific time frame had elapsed.

One of my peers pointed out that the Logic App should NOT disable the Logic App if it was already disabled.

Good point … makes sense.

I added an Azure Resource Manager action to Read a resource. I update the properties to point to the Logic App that I want to check state for.

That action gets me all the information for the resource, in this case my Logic App.

The state of the Logic App is in the Properties, so we will need to parse it. To do this, I add a Parse JSON action, select the Properties properties and paste in the following schema:

{
    "properties": {
        "accessEndpoint": {
            "type": "string"
        },
        "changedTime": {
            "type": "string"
        },
        "createdTime": {
            "type": "string"
        },
        "parameters": {
            "properties": {},
            "type": "object"
        },
        "provisioningState": {
            "type": "string"
        },
        "state": {
            "type": "string"
        },
        "version": {
            "type": "string"
        }
    },
    "type": "object"
}

I now add a Control action and add the supporting condition to check to see if State is Enabled.

Lastly, I drag and drop my steps for disabling and enabling the Logic App into the if true condition.

That’s it! Works great!

Leave a Reply

Your email address will not be published.