Logic Apps deployment template extractor trigger updates

Updates to the Logic App Template Extractor has come out, read more about in the earlier post Logic Apps Deployment Template Extractor

Reccurence properties on trigger automatically ARM template properties

So whit a reccurence trigger we are setting an interval and frequency and often we want to have diffrent values in dev/test and production since trigger this action is assoisated with a billable action so frequency is often something we change between the environments. So whit any trigger that has reccurence propperties such as Interval and Frequencey are automatically generated as properties to the ARM Template. Here we can see the standard reccurence trigger:

And in the extracted ARM template we will automatically get:

"parameters": {
...
 "RecurrenceFrequency": {
      "type": "string",
      "defaultValue": "Day"
    },
    "RecurrenceInterval": {
      "type": "int",
      "defaultValue": 1
    }
...
  "triggers": {
    "Recurrence": {
      "recurrence": {
        "frequency": "[parameters('RecurrenceFrequency')]",
        "interval": "[parameters('RecurrenceInterval')]"
      },
      "type": "Recurrence"
    }
  },

File Connector and Base64 paths

The File Connector amongst others are saving the folder path in Base64 format to make sure that the Path is valid, for the File Connector it is so forthe trigger and List files action. The Designers are working with this withouth any problems but as you want to automate the deployment this becomes something we need to know and understand how to handle.

Understanding the Base64 modell

So let’s start with understanding the base64 modell used in these actions/triggers. So first we pick our path:

And if we then go in and look in the codeview:

"List_files_in_folder": {
    "inputs": {
        "host": {
            "connection": {
                "name": "@parameters('$connections')['filesystem_1']['connectionId']"
            }
        },
        "method": "get",
        "path": "/datasets/default/folders/@{encodeURIComponent('XFxcXHNlcnZlclxcQVJCRVRTT1JERVJcXE9VVFxcWE1MX0VYUE9SVFxcVE8=')}"
    },
    "metadata": {
        "XFxcXHNlcnZlclxcQVJCRVRTT1JERVJcXE9VVFxcWE1MX0VYUE9SVFxcVE8=": "\\\\server\\ARBETSORDER\\OUT\\XML_EXPORT\\TO"
    },
    "runAfter": {},
    "type": "ApiConnection"
}

So as we can see the path we picked in the designer is in the metdata tag and the name of the property is just a “random” name. The “random” name is not so random it’s actually the base64 representation of the path.

\\server\ARBETSORDER\OUT\XML_EXPORT\TO = decodeBase64(‘XFxcXHNlcnZlclxcQVJCRVRTT1JERVJcXE9VVFxcWE1MX0VYUE9SVFxcVE8=’).

The metadata tag is used in the GUI to present the path in text and the actuall value sent to the API Connection is found in the path property:

"path": "/datasets/default/folders/@{encodeURIComponent('XFxcXHNlcnZlclxcQVJCRVRTT1JERVJcXE9VVFxcWE1MX0VYUE9SVFxcVE8=')}"

So in order to be able to handle deployments this is the actual value we need to change but if we want the GUI to present this value we also need to update the metadata tag. To do this there are handy functions available to use in the ARM template [base64(‘somevalue’)]. The full extract when using the Deployment Template Creator will handle this and look like this:

"parameters": {
...
"List_files_in_folder-folderPath": {
      "type": "string",
      "defaultValue": "\\\\server\\ARBETSORDER\\OUT\\XML_EXPORT\\TO"
    },
}
...
	"List_files_in_folder": {
	  "runAfter": {},
	  "metadata": {
	    "[base64(parameters('List_files_in_folder-folderPath'))]": "[parameters('List_files_in_folder-folderPath')]"
	  },
	  "type": "ApiConnection",
	  "inputs": {
	    "host": {
	      "connection": {
	        "name": "@parameters('$connections')['filesystem_1']['connectionId']"
	      }
	    },
	    "method": "get",
	    "path": "[concat('/datasets/default/folders/@{encodeURIComponent(''',base64(parameters('List_files_in_folder-folderPath')),''')}')]"
	  }
	}

Setting the parameter in the parameters file to the new value will then be populated and working with both the designer and setting the correct value as parameter to the File Connector.

Small fixes

There has also been a number of small fixes as the parameter type now supports all kind of types, we can have objects, strings, integers etc.

Here is a sample of how parameters inside a Logic App of type Object will be handled:

 "parameters": {
    "ismanager": {
        "defaultValue": {
            "0": 572,
            "1": 571,
            "No": 572,
            "Yes": 571
        },
        "type": "Object"
    },

After generating the ARM template the Logic App parameter will be pushed up to an ARM template Parameter, making the ARM template looking like this:

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
	"parameters": {
		...
		paramismanager": {
		  "type": "Object",
		  "defaultValue": {
		    "0": 572,
		    "1": 571,
		    "No": 572,
		    "Yes": 571
		  }
		},
		....
	}
	"variables": {},
	"resources": [
	    {
	      "type": "Microsoft.Logic/workflows",
	      "apiVersion": "2016-06-01",
	      "name": "[parameters('logicAppName')]",
	      "location": "[parameters('logicAppLocation')]",
	      "dependsOn": [],
	      "properties": {
	        "definition": {
	          "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
	          "contentVersion": "1.0.0.0",
	          "parameters": {
	            "ismanager": {
	              "defaultValue": "[parameters('paramismanager')]",
	              "type": "Object"
	            },
				...
			 }
          },
          "outputs": {}
        },
        "parameters": {}
      }
    }
  ],
  "outputs": {}
}
				

Tools like the Logic App Template Creator helps us focus on the fun and good parts, building great solutions for our customers.

I strongly recomend you to try it and help out evolving it!

https://github.com/jeffhollan/LogicAppTemplateCreator

Posted in: •Logic Apps  •Integration  | Tagged: •DTAP  •Logic Apps  •Deployments  •Azure  •ARM  •ARM Template