Logic Apps using Visual Studio

In the earlier section, you have built a Logic App using the Azure portal. Now we will walk through developing Logic Apps using Visual Studio 2015. Logic Apps support a rich visual designer, and you can leverage the Visual Studio capability to build Logic App workflows. You can use Azure resource PowerShell scripts that ship with Logic Apps for automated deployment.

Visual Studio 2015 configuration steps for Logic App

To start working with Logic App using Visual Studio 2015, there are certain prerequisites that need to be installed and configured properly:

  • Visual Studio 2015
  • Latest Azure SDK (2.9.1 or greater)
  • Access to Internet and valid Azure subscription

Once you have Visual Studio 2015 and Azure SDK 2.9.1 or higher, you can follow the steps later to configure your Logic App template within Visual Studio.

Run Visual Studio 2015 as administrator

On the Visual Studio designer surface, navigate to Tools | Extensions and Updates | Azure Logic Apps Tools for Visual Studio, and Click on the Download button to install the Logic App extension.

You can also use direct link: https://visualstudiogallery.msdn.microsoft.com/e25ad307-46cf-412e-8ba5-5b555d53d2d9 for Logic App extension download.

Create Resource group template for Logic App

On Visual Studio, navigate to File | New Project | Cloud | Azure Resource Group. Type a name for the resource group and then click on OK.

Create Resource group template for Logic App

From the list of templates, select Logic App, and this will create an empty Logic App project.

Create Resource group template for Logic App

This will create an empty Logic App project in Visual Studio 2015; you will be able to see that the LogicApp.json and Deploy-AzureResourceGroup.ps1 files have been added to the solution. The LogicApp.json file will be using for workflow design, and Deploy-AzureResourceGroup.ps1 will be for the purposes of deployment.

Polling Twitter for #SunnyElectricals

The Logic App will poll twitter for new tweets with #SunnyElectricals and store all tweet information in the Azure SQL table. Here, twitter is acting as polling trigger and instantiates a runtime workflow with each single tweet message posted over tweeter. This is similar to what we have developed through Azure portal.

To open the Visual Studio designer for Logic App, right-click on the <template>.json file, and click on Open With Logic App Designer. You need to select the correct Azure subscription, resource group, and location for the deployment template.

Note

To populate Microsoft Managed Connector and API with Visual Studio, it is necessary to have Internet connectivity at the time of writing this book. You will be seeing more updates on Visual capability and tooling in coming time.

Polling Twitter for #SunnyElectricals

  • Use the Visual Studio designer to build the Logic App workflow. Here, we have created a similar Logic App that will be triggered whenever there is specific tweet for Sunny Electricals with the #SunnyElectricals hashtag.

Polling Twitter for #SunnyElectricals

We then store all the tweet information in an Azure SQL table for further analysis purposes:

Polling Twitter for #SunnyElectricals

The overall solution structure will look like the figure mentioned later. You can download the solution from a GitHub repository and source code attached with the book.

Polling Twitter for #SunnyElectricals

Code view

You can go through code behind by navigating code view tab at the bottom of Visual Studio designer. This way, you can see trigger and action code associated with Logic App. If you look at the code behind for the earlier solution, you can find a trigger and associated action within Logic App code behind:

  • Trigger is a condition that instantiate a new instance of workflow. Here, if we look at the code behind twitter API is acting as a trigger for the Logic App and is polling on condition "When_a_new_tweet_is_posted". You can also verify the method type and recurrence polling interval for the Microsoft managed twitter API.

    Code view

  • The action is the operation performed after a trigger. In current solution, we are using Insert operation against SQL. The code behind will show the actual workflow logic for your logic App:
    • Action Type = Insert_row
    • Method =post
    • "tweetBy": "@{triggerBody()['TweetedBy']}"
    • "tweetText": "@{triggerBody()['TweetText']}"

    Code view

Deployment

After creating Visual workflow associated with Logic App, you can right-click the solution and click on Deploy. This will prompt you to select proper Azure Resource Group and the plan.

Deployment

Once deployment of Logic App is succeeded, log in to the Azure portal and verify the Logic app activity log and summary by clicking on the Overview section and Activity log section. Logic App activity log gives you better insight into resource group monitoring.

Deployment

Logic App diagnostics will give overall analysis of workflow run. You can click on the Diagnostics section of Logic App blade to see the graphical representation of all the runs.

Deployment

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset