Enterprise Integration and B2B
Enterprise Integration Overview
Azure Logic Apps provides a comprehensive B2B integration platform for enterprises that need to exchange structured data with trading partners using industry-standard protocols.
Microsoft Reference: Enterprise integration overview
Integration Accounts
An Integration Account is a separate Azure resource that stores B2B artifacts — schemas, maps, certificates, partners, and agreements. It acts as a centralised repository for your enterprise integration assets.
Integration Account Tiers
| Tier | Schemas | Maps | Partners | Agreements | Price |
|---|---|---|---|---|---|
| Free | 25 | 25 | 25 | 10 | Free |
| Basic | 500 | 500 | 500 | 500 | ~£20/month |
| Standard | 1,000 | 1,000 | 1,000 | 1,000 | ~£240/month |
Creating an Integration Account
resource integrationAccount 'Microsoft.Logic/integrationAccounts@2019-05-01' = {
name: 'ia-enterprise-${environment}'
location: location
sku: {
name: environment == 'prod' ? 'Standard' : 'Basic'
}
properties: {}
}
// Link to Logic App (Consumption)
resource logicApp 'Microsoft.Logic/workflows@2019-05-01' = {
name: 'la-b2b-processing-${environment}'
location: location
properties: {
integrationAccount: {
id: integrationAccount.id
}
definition: {
// workflow definition
}
}
}
Microsoft Reference: Create integration accounts
Schemas
XML and JSON schemas validate the structure of incoming and outgoing messages.
XML Schema (XSD) Upload
resource schema 'Microsoft.Logic/integrationAccounts/schemas@2019-05-01' = {
parent: integrationAccount
name: 'PurchaseOrder_V1'
properties: {
schemaType: 'Xml'
content: loadTextContent('schemas/PurchaseOrder.xsd')
contentType: 'application/xml'
}
}
XML Validation in Workflows
{
"XML_Validation": {
"type": "XmlValidation",
"inputs": {
"content": "@triggerBody()",
"integrationAccount": {
"schema": {
"name": "PurchaseOrder_V1"
}
}
}
}
}
JSON Schema Validation
{
"Parse_JSON": {
"type": "ParseJson",
"inputs": {
"content": "@triggerBody()",
"schema": {
"type": "object",
"required": ["orderId", "items"],
"properties": {
"orderId": { "type": "string", "pattern": "^ORD-[0-9]{6}$" },
"items": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"required": ["productId", "quantity"],
"properties": {
"productId": { "type": "string" },
"quantity": { "type": "integer", "minimum": 1 },
"price": { "type": "number", "minimum": 0 }
}
}
}
}
}
}
}
}
Maps (Data Transformation)
Maps transform data between formats using XSLT or Liquid templates.
XSLT Maps
Transform XML documents between different schemas:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<InternalOrder>
<OrderRef>
<xsl:value-of select="PurchaseOrder/Header/OrderNumber"/>
</OrderRef>
<Customer>
<Id><xsl:value-of select="PurchaseOrder/Header/BuyerCode"/></Id>
<Name><xsl:value-of select="PurchaseOrder/Header/BuyerName"/></Name>
</Customer>
<Lines>
<xsl:for-each select="PurchaseOrder/Lines/Line">
<Line>
<Product><xsl:value-of select="ItemCode"/></Product>
<Qty><xsl:value-of select="Quantity"/></Qty>
<UnitPrice><xsl:value-of select="Price"/></UnitPrice>
</Line>
</xsl:for-each>
</Lines>
</InternalOrder>
</xsl:template>
</xsl:stylesheet>
Liquid Templates
Transform JSON data using Liquid template syntax:
{
"internalOrder": {
"reference": "{{ content.orderId }}",
"customer": {
"id": "{{ content.customerId }}",
"name": "{{ content.customerName | upcase }}"
},
"lines": [
{% for item in content.items %}
{
"product": "{{ item.productId }}",
"quantity": {{ item.quantity }},
"unitPrice": {{ item.price }},
"lineTotal": {{ item.quantity | times: item.price }}
}{% unless forloop.last %},{% endunless %}
{% endfor %}
],
"total": {{ content.items | map: "price" | sum }},
"processedAt": "{{ 'now' | date: '%Y-%m-%dT%H:%M:%SZ' }}"
}
}
Using Maps in Workflows
{
"Transform_XML": {
"type": "Xslt",
"inputs": {
"content": "@body('Receive_EDI')",
"integrationAccount": {
"map": {
"name": "PurchaseOrder_to_InternalOrder"
}
}
}
}
}
Microsoft Reference: Transform XML with maps
Trading Partners
Define organisations that exchange B2B messages:
resource partnerContoso 'Microsoft.Logic/integrationAccounts/partners@2019-05-01' = {
parent: integrationAccount
name: 'Contoso'
properties: {
partnerType: 'B2B'
content: {
b2b: {
businessIdentities: [
{
qualifier: 'ZZ'
value: 'CONTOSO'
}
]
}
}
}
}
resource partnerSupplier 'Microsoft.Logic/integrationAccounts/partners@2019-05-01' = {
parent: integrationAccount
name: 'SupplierCo'
properties: {
partnerType: 'B2B'
content: {
b2b: {
businessIdentities: [
{
qualifier: 'ZZ'
value: 'SUPPLIERCO'
}
]
}
}
}
}
EDI Message Processing
X12 (North America)
X12 is the EDI standard primarily used in North America:
| Transaction Set | Description |
|---|---|
| 810 | Invoice |
| 820 | Payment order/remittance advice |
| 850 | Purchase Order |
| 855 | Purchase Order Acknowledgement |
| 856 | Advance Ship Notice |
| 997 | Functional Acknowledgement |
EDIFACT (International)
EDIFACT is the international EDI standard:
| Message Type | Description |
|---|---|
| ORDERS | Purchase Order |
| ORDRSP | Purchase Order Response |
| DESADV | Despatch Advice |
| INVOIC | Invoice |
| CONTRL | Acknowledgement |
X12 Agreement Configuration
resource x12Agreement 'Microsoft.Logic/integrationAccounts/agreements@2019-05-01' = {
parent: integrationAccount
name: 'X12-Contoso-SupplierCo'
properties: {
agreementType: 'X12'
hostPartner: 'Contoso'
guestPartner: 'SupplierCo'
hostIdentity: {
qualifier: 'ZZ'
value: 'CONTOSO'
}
guestIdentity: {
qualifier: 'ZZ'
value: 'SUPPLIERCO'
}
content: {
x12: {
receiveAgreement: {
protocolSettings: {
validationSettings: {
validateCharacterSet: true
checkDuplicateInterchangeControlNumber: true
interchangeControlNumberValidityDays: 30
checkDuplicateGroupControlNumber: true
checkDuplicateTransactionSetControlNumber: true
validateEDITypes: true
}
framingSettings: {
dataElementSeparator: 42 // *
componentSeparator: 58 // :
segmentTerminator: 126 // ~
segmentTerminatorSuffix: 'None'
}
envelopeSettings: {
// envelope configuration
}
}
}
sendAgreement: {
protocolSettings: {
// similar configuration for outbound
}
}
}
}
}
}
X12 Decode Workflow
{
"definition": {
"triggers": {
"When_file_arrives": {
"type": "ApiConnection",
"inputs": {
"host": { "connection": { "name": "@parameters('$connections')['azureblob']['connectionId']" } },
"method": "get",
"path": "/datasets/default/triggers/batch/onupdatedfile",
"queries": { "folderId": "/inbound-edi" }
}
}
},
"actions": {
"Decode_X12": {
"type": "X12Decode",
"inputs": {
"content": "@triggerBody()",
"integrationAccount": {
"agreementName": "X12-Contoso-SupplierCo"
}
}
},
"For_each_transaction": {
"type": "Foreach",
"foreach": "@body('Decode_X12')?['transactionSets']",
"actions": {
"Route_by_type": {
"type": "Switch",
"expression": "@items('For_each_transaction')?['transactionSetIdentifier']",
"cases": {
"PurchaseOrder": {
"case": "850",
"actions": {
"Process_PO": {
"type": "Workflow",
"inputs": {
"body": "@items('For_each_transaction')"
}
}
}
},
"Invoice": {
"case": "810",
"actions": {
"Process_Invoice": {
"type": "Workflow",
"inputs": {
"body": "@items('For_each_transaction')"
}
}
}
}
}
}
}
},
"Send_997_Acknowledgement": {
"type": "X12Encode",
"inputs": {
"content": "@body('Decode_X12')?['acknowledgement']",
"integrationAccount": {
"agreementName": "X12-Contoso-SupplierCo"
}
}
}
}
}
}
Microsoft Reference: X12 message processing
AS2 Protocol
AS2 (Applicability Statement 2) is a secure transport protocol for EDI messages over HTTP/S.
AS2 Features
- Encryption — S/MIME encryption for message confidentiality
- Digital Signatures — Non-repudiation of origin
- MDN (Message Disposition Notification) — Receipt acknowledgement
- Compression — Reduce payload size
- HTTPS — Transport layer security
AS2 Agreement
resource as2Agreement 'Microsoft.Logic/integrationAccounts/agreements@2019-05-01' = {
parent: integrationAccount
name: 'AS2-Contoso-SupplierCo'
properties: {
agreementType: 'AS2'
hostPartner: 'Contoso'
guestPartner: 'SupplierCo'
hostIdentity: { qualifier: 'AS2Identity', value: 'Contoso' }
guestIdentity: { qualifier: 'AS2Identity', value: 'SupplierCo' }
content: {
aS2: {
receiveAgreement: {
protocolSettings: {
messageConnectionSettings: {
ignoreCertificateNameMismatch: false
supportHttpStatusCodeContinue: true
keepHttpConnectionAlive: true
unfoldHttpHeaders: true
}
mdnSettings: {
needMDN: true
signMDN: true
sendMDNAsynchronously: false
mdnText: 'Message received successfully'
micHashingAlgorithm: 'SHA2256'
}
securitySettings: {
overrideGroupSigningCertificate: false
enableNRRForInboundEncodedMessages: true
enableNRRForInboundDecodedMessages: true
}
envelopeSettings: {
messageContentType: 'text/plain'
transmitFileNameInMimeHeader: true
}
}
}
}
}
}
}
Microsoft Reference: AS2 message processing
Certificates
Store certificates for signing, encryption, and authentication:
resource certificate 'Microsoft.Logic/integrationAccounts/certificates@2019-05-01' = {
parent: integrationAccount
name: 'ContosoCert'
properties: {
key: {
keyVault: {
id: keyVault.id
}
keyName: 'contoso-private-key'
}
publicCertificate: loadFileAsBase64('certs/contoso-public.cer')
}
}
Flat File Processing
Process fixed-width and delimited flat files:
Flat File Schema
Define the structure of flat files for encoding/decoding:
{
"Decode_Flat_File": {
"type": "FlatFileDecode",
"inputs": {
"content": "@triggerBody()",
"integrationAccount": {
"schema": {
"name": "OrderFlatFileSchema"
}
}
}
}
}
Common Flat File Patterns
| Pattern | Description |
|---|---|
| CSV | Comma-separated values with header row |
| Fixed-width | Positional fields with padding |
| Multi-record | Multiple record types identified by a tag |
| Hierarchical | Parent-child record relationships |
Microsoft Reference: Flat file encoding/decoding
Integration Patterns for Enterprise
Message Correlation
Track related messages across multiple workflows:
1. Purchase Order received (850) → Assign correlation ID
2. Purchase Order Acknowledgement sent (855) → Link to correlation ID
3. Advance Ship Notice received (856) → Match by PO number
4. Invoice received (810) → Match by PO number
5. Payment sent (820) → Close the loop
Guaranteed Delivery
Ensure messages are never lost:
Receive EDI message via AS2
→ Persist to Azure Blob Storage (audit copy)
→ Send to Service Bus Queue (guaranteed delivery)
→ Acknowledge (send MDN)
Separate workflow:
→ Service Bus trigger (with peek-lock)
→ Process message
→ Complete message (removes from queue)
→ On failure: message returns to queue after lock timeout
Idempotent Processing
Prevent duplicate processing using control numbers:
Receive message
→ Check: Has this interchange control number been processed?
→ Yes: Return acknowledgement (skip processing)
→ No: Process message, store control number
Monitoring B2B Transactions
Tracking Messages
Enable tracking in your agreement settings to log:
- Interchange control numbers
- Group control numbers
- Transaction set control numbers
- Correlation IDs
- Message status (received, processed, acknowledged, rejected)
Log Analytics Queries for B2B
// All B2B messages in the last 24 hours
AzureDiagnostics
| where ResourceType == "INTEGRATIONACCOUNTS"
| where TimeGenerated > ago(24h)
| project TimeGenerated, OperationName, status_s,
as2From_s, as2To_s,
interchangeControlNumber_s,
isMessageFailed_b
| order by TimeGenerated desc
// Failed B2B messages
AzureDiagnostics
| where ResourceType == "INTEGRATIONACCOUNTS"
| where isMessageFailed_b == true
| project TimeGenerated, OperationName,
errorDescription_s,
interchangeControlNumber_s
Microsoft Reference: Track B2B messages
Best Practices
- Use Integration Accounts for all B2B scenarios — they provide centralised management of artifacts
- Store certificates in Key Vault — never embed private keys in Integration Account directly
- Implement duplicate detection using interchange control numbers
- Archive all messages to Blob Storage for audit and compliance
- Use AS2 with MDN for reliable message delivery with non-repudiation
- Version your schemas — use naming conventions like
PurchaseOrder_V2 - Test with trading partners in a non-production environment before going live
- Monitor B2B transactions via Log Analytics and set up alerts for failures
- Implement compensation for failed multi-step B2B processes
- Use Liquid templates for JSON-to-JSON transformations (simpler than XSLT)