LetsGrabSomeBooty
LetsGrabSomeBooty

Reputation: 3

Logicapp standard workflows deployment with ARM template

I have a standard logic-app ARM template and I can run and deploy it successfully. Also, I have some Workflows to be deployed alongside that Standard logic-app. Problem is - the logic-app deploys empty (With no workflows in it).

How can I attach my workflow JSON files to the arm template, so that when deploying, the workflows are included? Some ARM-template code snippets or pictures would be much appreciated

Upvotes: 0

Views: 2462

Answers (3)

Utkarsh Malviya
Utkarsh Malviya

Reputation: 73

Standard LogicApps are deployed on AppServicePlan, when you create a serverfarm(App Service Plan) and then deploy your Microsoft.Web/sites(LogicApp) on top of it, workflows, parameters and connections will not be deployed by default.

You will have to use MSDeploy extension for Microsoft.Web for deploying Standard LogicApp workflows after deploying your Microsoft.Web/sites.

Documentation: https://learn.microsoft.com/en-us/azure/templates/microsoft.web/2021-03-01/sites/extensions-msdeploy?pivots=deployment-language-arm-template

You can use PackageUri option and pass the local path of ZIP file (Or Azure Blob Storage Link) which contains the Workflow folders and parameters.json, connections.json, host.json file at the root. The structure inside the Zip file should look like below (Names enclosed in {{}} are customizable):

- {{WorkflowName1}}  
  -- workflow.json 
- {{WorkflowName2}}    
  -- workflow.json 
- parameter.json
- connections.json
- host.json

Also, if you are trying to deploy the Zip from Local Path, you will have to add ParameterReference in ARM deploymentParameter template.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "paths": [
    {
      "ParameterReference": "local_zip_path"
    }
  ],
  "parameters": {
    "local_zip_path": {
      "value": "bin\\LogicApps.zip"
    }
  }
}

Upvotes: 0

Tyler
Tyler

Reputation: 21

I am trying to accomplish the same thing and cannot find any resources online referencing this. I found the differentiating factor between what we want to deploy in my case is multiple workflows in the "Logic App Standard" which is technically an App Service behind the scenes - requiring an app service plan and storage account to deploy:

  • "type": "Microsoft.Web/sites",
  • "kind": "functionapp,workflowapp"

While all resources and Microsoft templates / examples refer to "Logic App" which is:

  • "type": "Microsoft.Logic/workflows"

I can define the workflow definitions in the resources property of the logic app standard arm template but it only deploys the logic app, and no workflows (even if they are defined) just like you outlined above.

Upvotes: 1

vijaya
vijaya

Reputation: 1721

You can add workflow definition in resources section.

  • Follow this MS document for more details.
  • Below is sample template code you can refer and upload json code of your workflow.
{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
   "parameters": {
      "LogicAppName": {
         "type": "string",
         "minLength": 1,
         "maxLength": 80,
         "defaultValue": "MyLogicApp",
         "metadata": {
            "description": "The resource name to use for the logic app"
         }
      },
      "LogicAppLocation": {
         "type": "string",
         "minLength": 1,
         "defaultValue": "[resourceGroup().location]",
         "metadata": {
            "description": "The resource location to use for the logic app"
         }
      },
      "office365_1_Connection_Name": {
         "type": "string",
         "defaultValue": "office365",
         "metadata": {
            "description": "The resource name to use for the Office 365 Outlook connection"
         }
      },
      "office365_1_Connection_DisplayName": {
         "type": "string",
         "defaultValue": "",
         "metadata": {
            "description": "The display name to use for the Office 365 Outlook connection"
         }
      },
      "azureblob_1_Connection_Name": {
         "type": "string",
         "defaultValue": "azureblob",
         "metadata": {
            "description": "The resource name to use for the Azure Blob storage account connection"
         }
      },
      "azureblob_1_Connection_DisplayName": {
         "type": "string",
         "defaultValue": "",
         "metadata": {
            "description": "Name of the storage account the connector should use."
         }

      },
      "azureblob_1_accountName": {
         "type": "string",
         "defaultValue": "",
         "metadata": {
            "description": "Name of the storage account the connector should use."
         }
      },
      "azureblob_1_accessKey": {
         "type": "securestring",
         "metadata": {
            "description": "Specify a valid primary/secondary storage account access key."
         }
      },
      "LogicAppIntegrationAccount": {
         "type":"string",
         "minLength": 1,
         "defaultValue": "/subscriptions/<Azure-subscription-ID>/resourceGroups/fabrikam-integration-account-rg/providers/Microsoft.Logic/integrationAccounts/fabrikam-integration-account",
         "metadata": {
            "description": "The ID to use for the integration account"
         }
      }
   },
   "variables": {},
   "resources": [
      {
         "properties": {
            "state": "Disabled",
            "integrationAccount": {
              "id": "[parameters('LogicAppIntegrationAccount')]"
            },
            "definition": {
               "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
               "actions": {
                  "Create_blob": {
                     "type": "ApiConnection",
                     "inputs": {
                        "host": {
                           "connection": {
                              "name": "@parameters('$connections')['azureblob']['connectionId']"
                           }
                        }
                     },
                     "method": "post",
                     "body": "@triggerBody()?['Body']",
                     "path": "/datasets/default/files",
                     "queries": {
                        "folderPath": "/emails",
                        "name": "@triggerBody()?['Subject']",
                        "queryParametersSingleEncoded": true
                     },
                     "runAfter": {},
                     "runtimeConfiguration": {
                        "contentTransfer": {
                           "transferMode": "Chunked"
                        }
                     }
                  }
               },
               "parameters": {
                  "$connections": {
                     "defaultValue": {},
                     "type": "Object"
                  }
               },
               "triggers": {
                  "When_a_new_email_arrives": {
                     "type": "ApiConnection",
                     "inputs": {
                        "host": {
                           "connection": {
                              "name": "@parameters('$connections')['office365']['connectionId']"
                           }
                        },
                        "method": "get",
                        "path": "/Mail/OnNewEmail",
                        "queries": {
                           "folderPath": "Inbox",
                           "importance": "Any",
                           "fetchOnlyWithAttachment": false,
                           "includeAttachments": false
                        }
                     },
                     "recurrence": {
                        "frequency": "Day",
                        "interval": 1
                     },
                     "splitOn": "@triggerBody()?['value']"
                  }
               },
               "contentVersion": "1.0.0.0",
               "outputs": {}
            },
            "parameters": {
               "$connections": {
                  "value": {
                     "azureblob": {
                        "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('LogicAppLocation'), '/managedApis/', 'azureblob')]",
                        "connectionId": "[resourceId('Microsoft.Web/connections', parameters('azureblob_1_Connection_Name'))]",
                        "connectionName": "[parameters('azureblob_1_Connection_Name')]"
                     },
                     "office365": {
                        "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('LogicAppLocation'), '/managedApis/', 'office365')]",
                        "connectionId": "[resourceId('Microsoft.Web/connections', parameters('office365_1_Connection_Name'))]",
                        "connectionName": "[parameters('office365_1_Connection_Name')]"
                     }
                  }
               }
            },
            "accessControl": {}
         },
         "name": "[parameters('LogicAppName')]",
         "type": "Microsoft.Logic/workflows",
         "location": "[parameters('LogicAppLocation')]",
         "tags": {
            "displayName": "LogicApp"
         },
         "apiVersion": "2019-05-01",
         "dependsOn": [
            "[resourceId('Microsoft.Web/connections', parameters('azureblob_1_Connection_Name'))]",
            "[resourceId('Microsoft.Web/connections', parameters('office365_1_Connection_Name'))]"
         ]
      },
      {
         "type": "Microsoft.Web/connections",
         "apiVersion": "2016-06-01",
         "name": "[parameters('office365_1_Connection_Name')]",
         "location": "[parameters('LogicAppLocation')]",
         "properties": {
            "api": {
                "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('LogicAppLocation'), '/managedApis/', 'office365')]"
            },
            "displayName": "[parameters('office365_1_Connection_DisplayName')]"
         }
      },
      {
         "type": "Microsoft.Web/connections",
         "apiVersion": "2016-06-01",
         "name": "[parameters('azureblob_1_Connection_Name')]",
         "location": "[parameters('LogicAppLocation')]",
         "properties": {
            "api": {
               "id": "[concat(subscription().id, '/providers/Microsoft.Web/locations/', parameters('LogicAppLocation'), '/managedApis/', 'azureblob')]"
            },
            "displayName": "[parameters('azureblob_1_Connection_DisplayName')]",
            "parameterValues": {
               "accountName": "[parameters('azureblob_1_accountName')]",
               "accessKey": "[parameters('azureblob_1_accessKey')]"
            }
         }
      }
   ],
   "outputs": {}
}
  • Workflow definition need to be included in Microsoft.Logic/workflows`resource type.
  • Using custom deployment in azure portal, I have uploaded above template file and it is created logic app, blob api connection and office 365 connection. enter image description here

Upvotes: 1

Related Questions