This post was originally published here

In the last post we talked about building a Logic App from scratch and gave a few hints on what we would change to prepare for CI/CD.

In this post, we will show you how to prepare your Logic App and template files, how to set and rename your parameters and will hint on how it will correlate with the Azure Pipeline.

So lets recap. We saw that the needed requirements are having VS installed, Azure SDK, Logic Apps for Visual Studio tools extension and an active Azure subscription. We built a new Azure Resource Group project with the Logic Apps template and added a few actions to our LA, nothing too fancy, just enough to show what’s needed.

Now, let’s look at how we will change the code to get it ready.

Changing the JSON code to prepare it for CI/CD is simple but requires attention, because if not done properly, you won’t be able to deploy your template and it might take you a while to find where the problem is. Even though VS gives you a few hints, because Intellisense helps, it might still not explain why it’s failing.

The first thing I like to do is to rename the connection parameters, having “servicebus_1_connectionString” is just horrible and does not help you understand what kind of connection you have. For this case, because we only have one connection, I’ll rename it to “arm_serviceBus_connectionString”, because we’re using an ARM (Azure Resource Manager) template and because this is the type of parameter. I will also add a template variable, named “SingleQuote”, which will be, as you’ve might have guessed, a single quote mark.

So, we end up with this:

Notice that I’ve also added the initial state control, as you may remember from a previous post about this. You can check it here: https://blog.sandro-pereira.com/2020/12/29/controlling-the-initial-state-of-a-logic-app/

If you have other connectors, I suggest you continue changing names to match the same naming convention. It will help you and others to know what that is supposed to be.

After the Logic App file is taken care of, you will also need to apply these changes in the Parameters file.

By default, it will be almost empty, just having the logicAppName parameter with a Null value. This will make your deployment fail, because the template isn’t valid.

In fact, you won’t even be able to deploy it, because VS is smart enough to prompt you for the missing values, taking the default ones from the LogicApp.

At this point, we’re no longer dealing with the definition, we’re dealing with the values we want the Logic App parameters to have. So, “type” and “defaultValue” no longer apply, you should use “value” directly or, if you’re dealing with KeyVault secrets, you can just reference KV and the secret name.

In this example, I’m setting the SB connection string both ways, to show how it can be done.

If you’ve done everything right, you’re Logic App should be deployed without any fuss.

Now comes the fun part, that is dealing with the Parameters Template file. It is incredibly difficult to do this and it’s going to take several hours. So grab that coffee and get confortable.

You will need to change your values to a token and an identifier, to later use in the Pipeline and releases.

Wow, that took us… 30 seconds, maybe. I’m exhausted and I need a break. You can even get that KV value with the token, you just need to change the identifier to the KV secret name.

We’re sweating over here with all this work.

In the next blog post, we will build the Pipeline and give the hints for the Release as well.

Happy coding!

The post Logic Apps: CI/CD Part 2- Preparing for CI/CD appeared first on SANDRO PEREIRA BIZTALK BLOG.