Azure Logic Apps Anywhere — Develop & Run Locally in VS Code

Vinnarason James
7 min readJun 6, 2021

Azure Logic Apps Anywhere: Host your workflows on your own infrastructure or any cloud service providers.

As organizations expand their cloud footprint, there is an increased interest in the ability to use on-premises and multi-cloud vendors to deploy their workloads. The requirement for seamless portability across multiple environments is essential part of achieving increased flexibility, reduce the time to market and increased operational efficiency.

Let’s talk about the two key concepts that enables achieving the hybrid and multi-cloud scenario.

Portability enable the move and adapt applications and data between on premises systems and across multiple cloud service providers. It helps to minimize the human efforts in redesign and redeployment of application, data and services when moving from one cloud to another or when moving from on prem to cloud.

Containerization enables an application to be run in a virtual environment by storing all the files, libraries and more together as one package: a container. Containerization is the backbone for portability and has enabled portability, flexibility, and scalability with its ability to plug directly into the operating system kernel. It makes it possible for applications to run on any vendor agnostic container platform.

Azure’s workflow automation service Logic Apps Standard now supports multi-cloud and hybrid cloud deployments and improves portability. I liked the term “Logic Apps Anywhere” better as it reflected the services potential well.

I was curious to test it out and wanted to deploy a logic app workflow in google cloud platform and AWS to see if it is working as the same as working in Azure platform.

On the path to make it work, the following activities had to be done to learn and understand it better.

1. Develop and Run locally in Visual Studio Code

· Install the pre-requisites

· Create a stateless workflow locally in Visual studio Code

· Debug and run locally in visual studio code

· Enable run history in stateless workflow

2. Run in a local docker environment

· build a docker container for logic apps workflow

· deploy to docker

· Run and test

3. Run in Google Cloud Platform

· Create GKE Cluster

· Create GCR and upload the image

· Deploy workload to GKE

· Discover, run, and test the workflow

4. Run in AWS

· Create Fargate Cluster

· Create Container registry and upload the image

· Deploy workload to Fargate

· Discover, run, and test the workflow

I am looking to write this blog as a four-part series to demonstrate the above four stages in detail.

Part 1: Develop and run your logic apps locally in Visual Studio Code

Install the pre-requisites

There is an improved experience developing Logic Apps on Visual Studio code now. Visual studio code needs the following pre-requisites to be installed before the development can start:

An active azure subscription or Create your Azure free account today | Microsoft Azure

Visual Studio code Extensions:

· Azure Logic Apps (Preview) — Visual Studio Marketplace — Logic apps development tools

· Azure Account — Visual Studio Marketplace — Azure sign in experience

· C# — Visual Studio Marketplace — enables debugging functionality for logic apps

Search from the VS Code extensions tab or follow the links to complete the installation.

Other tools:

· Install Azure Function core tools — Work with Azure Functions Core Tools | Microsoft Docs

· Install Azure Storage Emulator — Use the Azure Storage Emulator for development and testing | Microsoft Docs

Sandro Pereira has a three-part blog series walking through step by step to make sure the installation of all the extensions and the tools are done correctly.

What do I need to do to start developing stateful or stateless workflows — Azure Logic Apps (Preview)? (Part I) — SANDRO PEREIRA BIZTALK BLOG (sandro-pereira.com)

Create a stateless workflow locally in Visual studio Code

Pre-requisites are installed, and it is time to create a logic apps workflow in visual studio code.

· A new logic apps workflow project can be created in two ways.

1. Start by creating a new project either by creating a new folder in your local file system and File->New Folder from VS Code. Then Click on Azure Account icon (1) from VS Code, Options on the Logic apps (Preview) panel, Create Workflow icon (2)

2. Another method is, Click on Azure Account icon (1) from VS Code, Options on the Logic apps (Preview) panel, Create New Project icon (2), browse and find a directory for the project.

· A wizard will appear at the central command blade, for this sample, we can create a stateless workflow

· Provide a name for the workflow

· Once the wizard is completed, it creates the skeleton of the workflow as below

1 — Each workflow is created with a folder with the same as the workflow name and a workflow.json file with the definition of the workflow in json

2 — host.json file provides the azure function extensibility configurations

3 — local.settings.json basic application level configuration can be added to this file

UseDevelopmentStorage=true property lets us run logic apps locally using Azure Storage Emulator. Alternatively, Connection string for an azure storage account can be configured here to use as the storage. There is been work happening to improve this experience using Azure SQL and Azurite.

4 — An empty json definition of a logic apps workflow

· Right click on the workflow.json file and select Open in Designer to view the workflow designer

When the designer opens, it adds a folder and a set of files to the solution

· Select Skip for now when prompted to use Connectors from Azure. Logic apps designer lets you define the workflow. Add a trigger “When a HTTP request is received” and configure the request with schema. Or use a sample json request message to generate the schema

· Add a http action to make a call to weather api

Note that we can read the app settings by using @appsetting(‘paramname’).

weatherAPISubscriptionId is added to the local.settings.json file as a key value pair.

· Add a response to the workflow to send the weather data back to the user

· Now the logic app is ready to build and run locally. Before running the logic app, start the Azure Storage Emulator and make sure it is running as we have marked “UseDevelopmentStorage=true” in local.settings.json

· Select Run->Start Debugging or F5 to start the logic apps locally, finally the execution displays the following to show the logic apps is up and running.

· To get the full callback url of the logic apps, go to workflow.json and select overview

· Copy the URL and open postman to send a post request

Body:

{

“city”: ”Wellington”

}

· By default, stateless workflow execution does not create run history. For testing purposes, it can be enabled by adding the following to the local.settings.json file.

“Workflows.helloWorld.OperationOptions”: “WithStatelessRunHistory”

· Rerun the workflow by using F5 or Run->Start Debugging

Congrats, now we have finished developing a simple logic apps workflow and tested it by running locally. There is a story for debugging the workflow in there, more on that later.

Next part will focus on running the same workflow in a local docker container.

--

--

Vinnarason James

An Azure Enthusiast, looking to share my learning about Azure Services I use as part of my job