Adventures with Logic Apps: Enabling/Disabling a Logic App from Another Logic App

Recently I was asked to create an HTTP Endpoint that could a user could call to disable a Logic App.

At first I thought about doing this as an Azure Function, but thought first I’d try it using a Logic App.

Albert Hovingh’s article, Disabling Logic Apps from Other Logic Apps, pointed me in the right direction.

To get started I created a resource group, XXX-001-rg.

I then created the Logic App that I wanted to enable and disable, I called it XXX-001-001-logapp.

I used the Request + Response template.

In order to enable/disable the Logic App I was going to need to create a Service Principal.

I created a Service Principal with Azure CLI using the command shell in the Azure Portal. You could also do it locally or at https://shell.azure.com.

Copy the outputted values, you will need them for our Logic App that will disable/enable the other Logic App.

If you fail to copy the outputted values, you will need to get them from the Azure Active Directory blade, under App Registrations.

I then gave the Service Principal Contributor access to the Logic App, XXX-001-logapp.

Finally, I created the logic app that would be responsible for enabling/disabling the previous logic app I created, I called this logic app XXX-001-002-logapp.

I started with a Blank Logic App.

I added a Request trigger for When a HTTP request is received.

I added an Azure Resource Manager action, per Albert Hovingh’s article, Disabling Logic Apps from Other Logic Apps, and set the Action to disable.

I change the connection to Connect with Service Principal and enter the values from the service principal I just created.

For Client ID use the appId and for the Client Secret use the password.

Originally I made it so the action could be passed via the body of the HTTP Request, this way you could use a single Logic App to enable and disable the Logic App, but there was one more additional requirement, that caused me to the remove that functionality, the Logic App would need to be enabled again after 15 minutes.

It was easy not difficult to accomplish this right in the Logic App that was handling the disabling.

I simply added a Schedule action, set the Count to 15 and the Units to Minutes.

I then added another Azure Resource Manager action, using all the settings from the previous action, except this time, I set Action to enable.

This worked great! And I did it without any code, keep in mind that I have a bias towards writing code! 😊 

Leave a Reply

Your email address will not be published.