Quickly provision Logic App environment to start developing the flow
Tags: bicep, logicapps, azure
Published: 2022-12-19 15:02:57

This is the Dec 20th article of 
[Power Automate advent calendar 2022](https://qiita.com/advent-calendar/2022/powerautomate), and I decided to explain how to provision Logic App environment by using bicep.

Main audience for this article is citizen developers who are familiar with Power Automate (and Power Platform solutions). 

## Difference between Power Automate and Logic App

The most important difference, at least for me, is that Power Automate is owned by user, whereas Logic App belongs to Azure resource. If the flow you are developing is part of backend system, then the owner of the flow obviously shouldn't be user(s).

The good news is that if you can develop Power Automate, you can do so with Logic App, as there are quite similar. 

## Environment difference

Power Automate is run in Power Platform, whereas Logic App runs in Azure subscription. Therefore, you need to have Azure subscription and appropriate access to the subscription.

You can start using Azure for free if don't have any yet. See [Build in the cloud with an Azure free account](https://azure.microsoft.com/en-us/free/) for more detail.

## How to provision Logic App

There are several ways to create Logic App.

- Azure Portal
- Azure CLI/Azure PowerShell Module 
- ARM/bicep template

Interesting part of Logic App deployment is that we can include workflow definition itself. However, I want to provision new environment to start development, I explain how to provision environment without any definition.

### Azure CLI

Firstly, I explain how to use az command only to create a Logic App.

1\. Install logic az cli extension.

```shell
az extension add --name logic
```

2\. Create resource group where you provision Logic App. Change name and location as you need.

```shell
az group create --name <your resource group name> --location eastus
```

3\. Create definition json as definition.json.

```json
{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json",
        "contentVersion": "1.0.0.0",
        "parameters": {},
        "triggers": {},
        "actions": {}
    }
}
```

4\. Run the command to create Logic App.

```shell
az logic workflow create -g "<your resource group name>" -l "eastus" --name "testLogicApp" --definition ".\definition.json"
```

### Bicep

Secondly, using bicep.

1\. Create logicapp.bicep as below.

```ini
@description('The name of the logic app to create.')
param logicAppName string

@description('Location for all resources.')
param location string = resourceGroup().location

var workflowSchema = 'https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#'

resource stg 'Microsoft.Logic/workflows@2019-05-01' = {
  name: logicAppName
  location: location
  tags: {
    displayName: logicAppName
  }
  properties: {
    definition: {
      '$schema': workflowSchema
      contentVersion: '1.0.0.0'
      parameters: {
      }
      triggers: {
      }
      actions: {
      }
    }
  }
}
```

2\. Run the command.

```shell
az deployment group create -g "<your resource group name>" --template-file .\logicapp.bicep --parameters logicAppName=testLogicApp2
```

## Result

In both cases, you can find created Logic Apps in Portal.

![Azure Portal Logic Apps](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7jlyyomi65reo2rbiqw3.png)

When you open either one, you can see Logic App Designer page.

![Logic App Designer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hy16oatl9f538fr3lx20.png)

## What's next?

As you can see, the definition body is blank. If you want to recreate same or similar workflow, try to convert your flow into definition, then you can easily deploy to different environment.