Azure Logic Apps — B2B EDI: AS2, X12, EDIFACT
Integration Account, Partner Profiles, Schema Validation
Introduction
Electronic Data Interchange (EDI) is the backbone of B2B commerce, enabling companies to exchange documents like purchase orders, invoices, and shipping notices in standardized formats. Azure Logic Apps with Integration Accounts provides a fully managed platform for EDI integration without writing complex parsing code.
Supported protocols:
- AS2 — Applicability Statement 2 (secure, receipt-based)
- X12 — Predominant in North America
- EDIFACT — International standard (UN/CEFACT)
Architecture Overview
┌──────────────────────────────────────────────────────────────────┐
│ B2B Integration Flow │
│ │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Partner A │───▶│ Logic App │───▶│ Partner B │ │
│ │ (Sending) │ │ (Azure) │ │ (Receiving) │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │ │ │ │
│ ▼ ▼ ▼ │
│ X12 850 PO Decode/Validate X12 855 POA │
│ (Purchase Order) Transform (Acknowledgment) │
└──────────────────────────────────────────────────────────────────┘
┌──────────────────────────────────────────────────────────────────┐
│ Integration Account │
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Partner │ │ Agreement │ │ Schema │ │
│ │ Profiles │ │ (Trading) │ │ (Maps) │ │
│ └──────────────┘ └──────────────┘ └──────────────┘ │
│ │
│ • Partner A: Sender │
│ • Partner B: Receiver │
│ • Agreement: X12 850 (Orders) │
│ • Schemas: 850, 855, 810 │
└──────────────────────────────────────────────────────────────────┘
Prerequisites
Create Integration Account
# Create Integration Account
az logic integration-account create \
--name my-integration-account \
--resource-group my-rg \
--location eastus \
--sku Standard
# Verify
az logic integration-account show \
--name my-integration-account \
--resource-group my-rg
Associate with Logic App
# Link integration account to Logic App
az logicapp update \
--name my-logic-app \
--resource-group my-rg \
--integration-account my-integration-account
Step 1: Create Trading Partners
Add Partner A (Your Company)
// Using Azure CLI
az logic integration-account-partner create \
--integration-account-name my-integration-account \
--name my-company \
--resource-group my-rg \
--partner-type B2B \
--content '{
"businessIdentities": [
{
"qualifier": "ZZZZ",
"value": "MY_COMPANY_ID"
}
],
"contactInformation": {
"contactName": "IT Department",
"email": "edi@mycompany.com"
}
}'
Add Partner B (Trading Partner)
az logic integration-account-partner create \
--integration-account-name my-integration-account \
--name partner-b \
--resource-group my-rg \
--partner-type B2B \
--content '{
"businessIdentities": [
{
"qualifier": "ZZZZ",
"value": "PARTNER_B_ID"
}
],
"contactInformation": {
"contactName": "EDI Coordinator",
"email": "edi@partnerb.com"
}
}'
Step 2: Upload EDI Schemas
Upload X12 Schema
# Upload 850 (Purchase Order) schema
az logic integration-account-map create \
--integration-account-name my-integration-account \
--name X12_850 \
--resource-group my-rg \
--map-type Xslt \
--map-schema-location "https://storage.blob.core.windows.net/schemas/X12_850.xsd"
Common X12 Document Types
| Code | Name | Description |
|---|---|---|
| 850 | Purchase Order | Order from buyer to seller |
| 855 | Purchase Order Acknowledgment | Seller confirms order |
| 856 | Ship Notice/Manifest | Shipping details |
| 810 | Invoice | Billing document |
| 820 | Payment Order/Remittance | Payment details |
| 997 | Functional Acknowledgment | Receipt confirmation |
| 999 | Implementation Acknowledgment | EDI syntax validation |
Upload EDIFACT Schema
| Code | Name | Description |
|---|---|---|
| ORDERS | Purchase Order | Similar to X12 850 |
| DESADV | Despatch Advice | Shipping notice |
| INVOIC | Invoice | Billing document |
| CONTRL | Acknowledgment | Receipt confirmation |
Step 3: Create Agreement
Create X12 Agreement
az logic integration-account-agreement create \
--integration-account-name my-integration-account \
--name x12-order-agreement \
--resource-group my-rg \
--metadata '{
"Partner1": "my-company",
"Partner2": "partner-b",
"AgreementType": "X12"
}'
Agreement Configuration (JSON)
{
"agreementType": "X12",
"senderPartner": "my-company",
"receiverPartner": "partner-b",
"senderProfile": {
"applicationIdentifier": "000000000",
"interchangeIdQualifier": "ZZ"
},
"receiverProfile": {
"applicationIdentifier": "000000000",
"interchangeIdQualifier": "ZZ"
},
"x12Settings": {
"version": "005010",
"controlNumber": {
"nextVersion": "0001",
"startValue": "1"
},
"validationSettings": {
"allowTrailingSeparators": true,
"validateCharacterSet": true,
"validateXsdType": true
},
"processingSettings": {
"convertToXml": true,
"preserveInterchange": true
}
}
}
Decode EDI in Logic App
Trigger: Receive EDI Message
{
"definition": {
"triggers": {
"When_an_X12_message_is_received": {
"type": "Request",
"kind": "X12",
"inputs": {
"host": {
"connection": {
"referenceName": "/subscriptions/xxx/resourceGroups/my-rg/providers/Microsoft.Logic/integrationAccounts/my-integration-account"
}
},
"metadata": {
"xsdSchemaName": "X12_005010_850"
}
}
}
},
"actions": {
"Validate_EDI": {
"type": "ediIntegration",
"operation": "decodeEdifact",
"inputs": {
"inputMessage": "@triggerBody()",
"agreement": {
"partnerName": "partner-b",
"agreementType": "X12"
}
}
},
"Transform_to_JSON": {
"type": "Liquid",
"operation": "transformJsonToJson",
"inputs": {
"content": "@body('Validate_EDI')",
"mapName": "X12_850_to_Internal_JSON"
}
},
"Create_Internal_Order": {
"type": "Http",
"inputs": {
"method": "POST",
"uri": "https://api.mycompany.com/orders",
"body": "@body('Transform_to_JSON')",
"authentication": {
"type": "ManagedIdentity"
}
}
},
"Send_Acknowledgment": {
"type": "ediIntegration",
"operation": "encodeEdifact",
"inputs": {
"inputMessage": "@body('Create_Internal_Order')",
"agreement": {
"partnerName": "my-company",
"agreementType": "X12"
},
"messageType": "855"
}
}
}
}
}
Encode EDI for Sending
Encode to X12
{
"actions": {
"Prepare_Order_for_EDI": {
"type": "Liquid",
"inputs": {
"content": "@variables('orderData')",
"mapName": "Internal_JSON_to_X12_850"
}
},
"Encode_to_X12": {
"type": "ediIntegration",
"inputs": {
"inputMessage": "@body('Prepare_Order_for_EDI')",
"agreement": {
"partnerName": "partner-b",
"agreementType": "X12"
},
"messageType": "850"
}
},
"Send_to_Partner": {
"type": "Sftp",
"inputs": {
"host": "partner-b.sftp.com",
"method": "File",
"path": "/outbound/orders/@{body('Encode_to_X12')}"
}
}
}
}
AS2 Configuration
AS2 Agreement
{
"agreementType": "AS2",
"senderPartner": "my-company",
"receiverPartner": "partner-b",
"as2Settings": {
"receiveAgreement": {
"senderPartner": "partner-b",
"receiverPartner": "my-company",
"senderProfile": {
"as2Identity": "PARTNER_B_AS2",
"as2Name": "PARTNER_B"
},
"receiverProfile": {
"as2Identity": "MY_COMPANY_AS2",
"as2Name": "MY_COMPANY"
}
},
"sendAgreement": {
"partnerName": "partner-b"
},
"mdnSettings": {
"sendMdn": true,
"signMdn": true,
"sendMdnAsync": false,
"receiptDeliveryUrl": "https://api.mycompany.com/as2/mdn"
},
"securitySettings": {
"enableCertificateValidation": true,
"checkCertificateRevocationList": true
}
}
}
Validation Settings
Configure Validation Rules
{
"validationSettings": {
"validateCharacterSet": true,
"validateXsdType": true,
"allowTrailingSeparators": true,
"treatEmptyNullAsWhiteSpace": false
},
"schemaValidationSettings": {
"validateRequiredDataElements": true,
"validateUnknownSegments": true,
"validateCrossField": true
}
}
Common Integration Patterns
Pattern 1: Purchase Order to Order System
Partner (X12 850) → Logic App (Decode) → Internal API → Database
↓
Partner (X12 855) ← Logic App (Encode) ← Order Confirmation
Pattern 2: Invoice Processing
Purchase (X12 850) → Logic App → Process Order
↓
Invoice (X12 810) ← Logic App ← Calculate & Send
Pattern 3: Ship Notice Correlation
X12 856 (ASN) → Decode → Correlate with Internal Order ID → Update System
Best Practices
| Practice | Description |
|---|---|
| Use Integration Account | Managed validation and transformation |
| Version Control Schemas | Store in Git, deploy via CI/CD |
| Test with Sample Files | Verify mappings before production |
| Monitor with Azure Monitor | Track message processing |
| Implement Acknowledgments | Ensure delivery confirmation |
Azure Integration Hub - Advanced Level