Synchronize control numbers

Posted: November 10, 2023  |  Categories: Azure

This blog shows a PowerShell script that copies control numbers from one integration account and allows you to add them to another integration account. A disaster recovery failover of an Integration account requires that you increment the generated control numbers for all the primary region agreements to your secondary region. You can read the Microsoft documentation for this here. That article suggests “Increment the generated control numbers for all the primary region agreements by using¬†PowerShell cmdlets.” but there is no worked example. I provide an example here.

AS2/EDIFACT control numbers

EDIFACT control numbers are important because they help to ensure the integrity, traceability, and reliability of EDI messages exchanged between trading partners. They are used to uniquely identify each interchange, group, and message, and to verify that the received data matches the sent data. They also enable the sender and the receiver to communicate the status of the message processing, such as acceptance, rejection, or errors, using the EDIFACT CONTRL message123EDIFACT control numbers can save time, create transparency, and prevent duplication or loss of data in electronic purchasing processes4.

Thus, after a failover of an Integration account one must synchronize these between the primary and secondary accounts.

Worked Example

First, we run this script to generate a script that you can run against your target integration account.

$RG = "primary resource group name"
$IA = "primary integration account"
$RG2 = "secondary resource group name"
$IA2 = "secondary integration account"

#Use CTRL - to set the powershell windows size so it all fits in
Get-AzIntegrationAccountGeneratedIcn -AgreementType "Edifact" -ResourceGroupName $RG -Name $IA | Select-Object {"Set-AzIntegrationAccountGeneratedIcn -AgreementType ""Edifact"" -ResourceGroupName $RG2 -Name $IA2 -AgreementName " + $_.AgreementName + " -ControlNumber " + $_.ControlNumber} #>> SetControlNumbers-DR.ps1
#This won't work unless all agreements have been run at least once.
#Copy the output another powershell 7 window and run it.

Resize the PowerShell window so the output fits and then in pipe the output out to a file. The output looks like

"Set-AzIntegrationAccountGeneratedIcn -AgreementType ""Edifact"" -ResourceGroupName $RG2 -Name $IA2 -AgreementName " + $_.AgreementName + " -ControlNumber " + $_.ControlNumber
Set-AzIntegrationAccountGeneratedIcn -AgreementType "Edifact" -ResourceGroupName dr-rg -Name dr-ia -AgreementName Us-Them-EDI -ControlNumber 21094
Set-AzIntegrationAccountGeneratedIcn -AgreementType "Edifact" -ResourceGroupName dr-rg -Name dr-ia -AgreementName Us-Them2-EDI -ControlNumber 8176

Run the output in a Powershell 7 console to update the integration account in the secondary region.


In summary I have shown a Powershell 7 script that can be used to sycnchronize integration accounts during an active-passive failover.


Back to Top