Batching Messages – Integration Account Batch Mode

Posted: July 30, 2022  |  Categories: Azure

Message Batching can define release criteria in an Integration account and this blog shows an example of this.

At the end of the last decade there was a flurry of blogs about batching in Azure. Nonetheless, all of these use the inline mode instead of an integration account. Furthermore Kent Weare published a comprehensive video on the same topic. However, he only show cased the inline mode too. To get back to the point, I found that if you use the integration account batch mode there are some issues you have to overcome. The rest of this blog will highlight these with examples.

My Message Batching Scenario

Firstly migrating a old BizTalk solution requires batching invoices in one file. Furthermore the file must be sent by email once a day at 5 a.m.

Configuring the solution

A list of steps are;

  1. Configure the release criteria.
  2. Create the Batch Receiver Logic App.
  3. Set up the Batch Sender Logic App.

Next we will talk about each step and highlight some issues when using the integration account batch mode.

Setting release criteria in an integration account

In my hands I could not change the batchGroupName from DEFAULT using the Integration account Batch configurations blade. Every batch configuration created from the blade has a batchGroupName of “DEFAULT”.

Attempts to edit the BatchGroupName in the JSON configuration on the blade fail with this error.

Nevertheless changing the configuration using this Powershell script solves this issue.

#AddorUpdateBatchConfigurations-Dev.ps1
$RG = "edi-dev-rg"
$IA = "edi-dev-ia"
$agreementdir ='C:\EDI_BATCH\src\'


Set-AzIntegrationAccountBatchConfiguration -ResourceGroupName $RG -IntegrationAccountName $IA -BatchConfigurationName "SKICORINVOICE" -BatchConfigurationFilePath ($agreementdir + "edi-batch-batchconfigurations-ia\SKICORINVOICE.json")

The SKICORINVOICE.json has the new batchGroupName which is not “DEFAULT”.

{
	"properties": {
		"batchGroupName": "SKICORINVOICE",
		"releaseCriteria": {
			"recurrence": {
				"frequency": "Week",
				"interval": 1,
				"timeZone": "E. Australia Standard Time",
				"schedule": {
					"minutes": [
						0
					],
					"hours": [
						5
					],
					"weekDays": [
						"Monday",
						"Tuesday",
						"Wednesday",
						"Thursday",
						"Friday",
						"Saturday",
						"Sunday"
					]
				}
			}
		}
	}
}

I choose to assign the batchGroupName to the same value as the BatchConfigurationName. Thus I configured all my Batch Configurations in DevOps with powershell scripts.

Create the Batch Receiver Logic App

Firstly , choose a Batch trigger which uses a Integration account in the Batch mode. On the blade there are no options to configure when you chose Integration account. How do you associate this with the batch configuration in the integration account?

Batch Receiver

Nevertheless, if you examine the code view you see the following. Thus it is the batchGroupName that links the trigger to the Integration Account Batch Configuration.

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {},
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {},
        "triggers": {
            "Batch_messages": {
                "inputs": {
                    "batchGroupName": "DEFAULT",
                    "mode": "IntegrationAccount"
                },
                "type": "Batch"
            }
        }
    },
    "parameters": {}
}

Once again if you try to update the batchGroupName in the code view you get this error.

The solution is to create the batch trigger using an arm template. This is how you create a batchGroupName different from “DEFAULT”. With that out of the way the creating rest of Logic flow is as shown above.

Firstly initialize a string variable to hold all the batched invoice. Secondly iterate through each batched item and appending each item to the string. Finally attach the string variable to an email and send it.

Create the Batch Sender Logic App

This starts with a service bus trigger, receiving an XML invoice. Secondly transform the XML invoice to the customers invoice. Thirdly encode the customer invoice as a tab delimited string. Finally add the string to a batch using the Batch action and sending this to the Batch receiver Logic App. Subsequently the Batch Receiver Logic App releases the entire batch at 5 a.m.

Batch Sender

Looking at the Batch task you configure a BatchName, Message Content, a trigger name and the Batch Receiver Logic app. Populate the last two from the blade by selecting the Batch Receiver Logic App for a drop down list. Alternatively you can configure this in Devops. By contrast, the Batch Name is free text and you cannot browse a list from the integration account. What value do you choose?

Before answering this question look at the code view of the Batch Action. Rightly or wrongly I choose to assign the Batch Name to the be the same as the BatchConfigurationName stored in the Integration Account.

            "nz-edi-invoice-post-skicor-batch-la": {
                "inputs": {
                    "batchName": "SKICORINVOICE",
                    "content": "@body('Flat_File_Encoding')",
                    "host": {
                        "triggerName": "Batch_SKICORINVOICE_messages",
                        "workflow": {
                            "id": "/subscriptions/<sub id>/resourceGroups/nz-edi-UAT-rg/providers/Microsoft.Logic/workflows/nz-edi-invoice-post-skicor-batch-uat-la"
                        }
                    }
                },
                "runAfter": {
                    "Flat_File_Encoding": [
                        "Succeeded"
                    ]
                },
                "type": "SendToBatch"
            }
        },

Conclusion

To conclude with I have shown that configuring the Integration Account Batch Mode is different from the Inline Mode for batching. Firstly, the best way to setup release configuration is to use Powershell because the Azure Portal always sets the batchGroupName to “DEFAULT”. Secondly create the Batch Receiver Logic App trigger using Devops because changing the batchGroupName in the Portal fails. Thirdly it is not possible to browse to the BatchName in the Integration Account when setting up the Batch Sender Logic App. I think this would be a very useful feature enhancement.

I hope this is useful. Please let me know if you think it was.

turbo360

Back to Top