Deploying a logic app using azure devops yaml pipeline

In this blog post, I will walk through how to create a logic app in Visual Studio 2019 and deploy it through Azure DevOps using YAML pipelines:

Prerequisite – You need to install “Azure Logic Apps Tools for Visual Studio 2019” extension in Visual Studio 2019:

Step 1: Create a new repo in your Azure DevOps Organization and clone it in your local work system. Open Visual Studio 2019 and click on Create a new project:

Step 2: Choose the Azure Resource Group template and click Next:

Step 3: Give a project name, select the location where you have cloned the repository, and click Create:

Step 4: Select Logic App template and click OK:

Step 5: Right click your LogicApp.json and click on “Open with Logic App Designer”:

Step-6: Select your Azure Subscription and the resource group where you would like to deploy your Azure Logic app later, keep the location of your logic app same as the resource group and click OK:

Step 7: For this example, I will use “When a HTTP request is received” trigger, but you can use any trigger and action to implement your workflow:

Step 8: Click on New Step:

Step 9: Choose “Response” Action:

Step 10: Once the action is added, click save. For this example, I will just return Status 200 OK. You can also view the code for your logic app by double clicking on LogicApp.json:

Step 11: Check in the logic app in your repository. Once checked in, the files will show up in Azure DevOps repo:

Step 12: The logic app is now ready for deployment. Go back to your Azure DevOps project which hosts the repository, and go to pipelines. Click on “Create Pipeline”:

Step 13: Choose Azure Repos Git:

Step 14: Choose your repository:

Step 15: Click on Starter Pipeline:

Step 16: Your starter YAML pipeline will show up. Click on Show assistant:

Step 17: Remove these two sample scripts from the yaml:

Step 18: Choose Visual Studio Build task from the assistant:

Step 19: Leave the default options as-is and click on Add:

Step 20: Search for Publish build artifacts task in the assistant:

Step 21: Choose default options and click on Add:

Step 22: Look for ARM template deployment task in the assistant:

Step 23: Select the appropriate service connection, and click on Authorize, if you are using a service connection for the first time. If you don’t see an authorize button, move to the next step:

Step 24: Choose the subscription, the resource group name and the location for your logic app:

Step 25: Provide the template and the parameter file paths, the logic app name and click on Add:

Step 26: Your YAML file will look like this:

Step 27: Update the template file and parameter file path to include the artifact location:

Step 28: Change the vmImage to “windows-latest“:

Step 29: Click on Save

Step 30: Enter a commit message and click Save:

Step 31: Go back to your repository to verify if you see azure-pipelines.yml in your repository.

Step 32: Go the pipelines and run the pipeline (This is only for the first time. From the second time onwards, whenever there is a new commit in the master branch, the pipeline will run automatically as we have chosen the branch trigger for the pipeline):

Step 33: The pipeline will be triggered. Go to the run, and allow the pipeline to access the service connection to the Azure subscription by clicking view:

Step 34: Click on Permit:

Step 35: Click on Permit:

Step 36: The pipeline will run and will deploy the logic app to Azure:

Step 37: Go to the Azure portal and verify your logic app in your resource group:

Step 38: Click on the logic app and go to the Logic app designer blade. Expand the Trigger box and copy the http post url:

Step 39: Use your tool of choice for making a post call to the copied URL. I have used Postman for the POST call and as expected it returns 200 OK:

Step 40: Go back to the Azure portal and go to the overview blade for the logic app. There is succeeded run of the logic app which has returned 200 OK:

In this blog post, I have shown how to deploy a simple Azure Logic App using Visual Studio 2019 and Azure DevOps YAML Pipelines. I hope you will find it useful.

In my next blog posts, I will show how we can pass parameters from our Azure DevOps YAML pipeline and how to secure parameters using the key vault.