>> Learn how to run a Logic App in a Docker Container.
In this episode of Azure Tips and Tricks,
you can run Azure Logic Apps anywhere.
You can run them on your local machine, in another Cloud,
and also in a Docker Container. Let's do that.
To follow along, you'll need to create
a Logic App with the newest VS Code extension.
You can follow another tip that explains how to create that,
and you can find the link to
that in the description of this video.
You also need to have Docker installed on your machine,
and Postman or another mechanism to send HTTP post requests.
Here in Visual Studio Code,
is my Logic App project,
and I've already added a Dockerfile to it.
We can use this Dockerfile to
create a Container image and run it.
Here in the file,
I've added to the connection string to
my Azure Storage Account that the Logic App will use.
Let's create and run the image.
First, I need to compile the code with this command.
Now, I need to publish it. There it goes.
Next, I use this command to create the Container image,
which includes the Logic App. Okay.
Now with this command,
I'll run the Container.
This also exposes the Logic App to
local host port 8080. That's it.
The Logic App is now running in a Container.
This Logic App is triggered by an HTTP request,
and then write a message on a queue in Azure Storage.
But how do I trigger it?
I need to first find the URL of the trigger.
To do that, we need to go to Azure Storage.
In here, in Blob Containers,
there's a Container called webjobs-secrets,
which is created by the Logic App,
and here in the latest version is a host.json file.
That is what we need. Let's take a look.
This contains a master key which will grant us access
to talk with the Logic App in the Container.
Let's copy it. We'll need this in the next step.
Now, I'll use Postman to post a request.
Let's create a new one,
and it needs to be a post request.
This is the URL that I'll use to discover the HTTP trigger URL.
In the URL, I have my Logic App workflow name,
stateless1 in my case,
and also the trigger name,
which is manual, as this is a manual HTTP trigger.
Also, I've added the master key value
here as the code. Let's "Send" it.
Here it is, the URL to the HTTP trigger,
and I need to use these values here as
query parameters that I send to the HTTP trigger.
Let's open a browser to trigger the Logic App, with this URL.
Again, this contains my workflow name and also the trigger name,
and the values that we've got from
the previous post request, like sp,
sv, and sig, and at the end here,
I added another query string parameter,
which the Logic App will use
to write a message in the Azure Storage queue.
Let's try it. That should be it.
Let's take a look in Visual Studio Code,
and here it is.
The logs of the Containers say that the workflow was
just triggered and that it run successfully.
Now, switch to the Azure Portal,
and look at the Azure Storage queue.
That should be this one, and yeah,
there is a message with the text,
myqueuetext, so it worked.
We've just deployed an Azure Logic App to
a Docker Container and run it successfully.
This makes it easy to run Logic Apps anywhere.
Go and check it out.