# How to use the VS Code Logic Apps extension to create stateless workflows

# Orchestrate workflows with Azure Logic Apps

Azure Logic Apps (opens new window) provide the central integration solution for your applications and services. Logic Apps enable you to create workflow orchestrations that are triggered by events like a timer or a new message on a queue and can call various APIs (opens new window) in sequence or in parallel to accomplish tasks. Logic Apps run your workflows serverless, without managing infrastructure.

Azure Logic Apps can pass information from one step to subsequent steps. For instance, if one step in a Logic App receives JSON data from an API, you can use that data in a next step to create a file with. This "dynamic content" is retained by Azure Logic Apps. In stateful (opens new window) Logic Apps, this data is retained in external storage, which makes it easy to re-run the workflow and restart it if it is interrupted by downtime. You can also create a stateless Logic App. A stateless app retains its dynamic content only in memory, which makes it faster and less expensive to run, although it won't be able to restart its workflow after an interruption.

In this post, we'll create and run a stateless Azure Logic App, locally, with VS Code.

# Prerequisites

If you want to follow along, you'll need the following:

# Create a stateless Logic App workflow with VS Code

Let's create a new Azure Logic App from VS Code.

  1. Open VS Code
  2. Go to the Extensions menu
  3. To create stateless Logic Apps, we need the newest Azure Logic Apps Extension. Search for Logic Apps and install the newest Logic Apps extension (opens new window)

(Newest Azure Logic Apps extension for VS Code)

  1. When the extension is installed, select the Azure menu in VS Code
    1. You'll see a section for Logic Apps. Sign into Azure if it asks you to
  2. In the Logic Apps section, click Create New Project
  3. Select a folder to store the new Logic App project in
  4. Select Stateless workflow
  5. Type in a name for the workflow and press Enter
  6. Choose to open the project in the current window to open the Logic App project

(Azure Logic Apps in VS Code)

  1. In the Logic App code, you'll see a file called workflow.json. Right-click on the file and select Open in Designer
  2. When asked, choose Use connectors from Azure
  3. Also, select a Resource Group in Azure to store new resources in
  4. In the workflow designer, select the trigger "When a HTTP request is received". This will trigger the workflow when a HTTP request is received on a certain URL
  5. Next, click on New step
  6. In the Add and action tab on the right, select the Azure tab
  7. Search for "queue" and select Azure Queues
  8. Next, select the action "Put a message on a queue"
  9. Now we need to create a connection to Azure Storage. Select the Azure Storage account that contains the queue that you want to use
  10. In the next screen, select the name of the Azure Storage Queue that you want to send a message to
  11. Select the Message input box. This makes the dynamic content window appear. Click on See more in the dynamic content window to see all the data fields that you can use from the previous step. Select Queries, to fill the message with whatever is in the querystring of the request that triggers the workflow

(Dynamic content window)

  1. That's it! Click Save to save the workflow. You'll see that saving creates a connections.json file which contains the connection information for Azure Storage
  2. Let's test the workflow by pressing F5 in VS Code. This will start the workflow on the local Azure Functions Runtime and will expose an HTTP endpoint for it that we can call to trigger it
  3. When the workflow is running, right-click on the workflow.json file and select Overview. This will show the trigger URL to call. Copy the complete URL

(Overview tab with HTTP trigger URL)

  1. Open a browser and paste in the URL and append it with &thistextwillbequeued
  2. Check the Azure Storage Queue. This should have a new message in it with the text thistextwillbequeued, which is what we appended as a querystring to the HTTP request that triggered the workflow

(Message in Azure Storage Queue)

# Conclusion

Azure Logic Apps (opens new window) is great for easily creating comprehensive workflows. It is made even easier with the VS Code extension for Azure Logic Apps (opens new window) and is made faster and less expensive by using stateless workflows (opens new window). Go and check it out!