Azure Logic Apps Schemas Tutorial: Beginner's Guide to Flat Files, XML, JSON, EDI with Hands-On Purchase Order Examples

{tocify} $title={Table of Contents}


Integration projects revolve around one fundamental concept: data exchange between systems. But here’s the challenge — every system speaks a different language and formats data differently.

Azure Logic Apps acts as a translator and orchestrator between systems, and schemas are the dictionary that helps it understand and translate messages correctly.

This blog explains all major schema types used in integration projects, especially in Azure Logic Apps, using a Purchase Order (PO) example. It is specifically to help beginners build strong fundamentals while still providing real-world implementation details.


Why Schemas Are Crucial in Azure Logic Apps Integrations and How They Work 

Azure Logic Apps is like a smart connector for apps and services, automating tasks such as file processing or API calls. Schemas are the blueprints that define data structure: fields, types (e.g., string or number), hierarchies, and rules. They enable validation (checking data correctness), encoding/decoding (format conversions), and transformations (reshaping data).

A schema is essentially a contract between two apps. It’s an agreement that says, 'I promise to send you the data in this exact format, and you promise to be ready to process it exactly that way.

Think of schemas as "data rulebooks" that help Logic Apps understand, validate, and transform information between systems.

Schemas Save Money

- Without schemas: Bad data costs companies millions annually on average

- With schemas: Catch errors early, save processing costs

- Example: Wrong date format crashes your entire order system


Common Problems Schemas Solve

- Customer sends "2/15/2026" but your system expects "2026-02-15"

- XML missing required fields breaks your workflow

- CSV has extra commas that mess up your data columns


Performance Impact

- Schema validation adds 50-100ms processing time

- But prevents hours of manual data cleanup later

- Think: spend 1 second validating vs 1 hour fixing bad data


In Logic Apps:

- Consumption Workflows (multi-tenant, pay-per-execution): Schemas are stored in an Integration Account—a central repository for sharing across workflows. Upload via Azure Portal.

- Standard Workflows (single-tenant, App Service Plan-based): Schemas are embedded in your project folder (Artifacts/Schemas) for local development and deployment. Use Visual Studio Code—no Integration Account needed unless sharing artifacts.

Understand the difference between Logic App consumption and Standard


Why schemas matter:

- Validation and Consistency: Prevent errors, like a PO with a text "price" instead of a number.

- Interoperability: Bridge formats, e.g., flat text from legacy systems to modern XML.

- Transformations: Customize data, such as adding totals or reformatting for partners.

- B2B Support: Essential for EDI, ensuring compliant exchanges.

Without schemas, integrations fail due to mismatched data—schemas make them reliable. 

Default Schema Type in Azure Logic Apps: The primary default is XML Schema Definition (XSD). It's the foundation for XML, Flat Files, and EDI validations/transformations. However, JSON is the most native format—Logic Apps workflows are JSON-based, with seamless data flow via expressions like `@triggerBody()?['orderNumber']`. Other formats often convert internally to JSON or XML for processing.


Read about Enterprise Appplication Integration using Logic App


Let’s consider below scenario as reference to understand the schemas and logic app

Real-World Scenario: System A places a Purchase Order (PO) as a Flat File on an SFTP server. Logic App fetches it, decodes/validates using a schema, transforms to XML expected by System B, and sends it. PO details: OrderNumber (PO123), Customer (ABC Stores), OrderDate (2025-01-10), Items (e.g., Laptop, Quantity 2, Price 1200).


System A → SFTP → Logic App

→ Flat File Decode

→ XML Transformation

→ Validation

→ Send to System B

 

Input Example (Delimited Flat File from System A):

PO123,ABC Stores,2025-01-10

Item001,Laptop,2,1200

Item002,Mouse,5,25

 

 

Expected Output (XML for System B):

<PurchaseOrder>

  <OrderNumber>PO123</OrderNumber>

  <Customer>ABC Stores</Customer>

  <OrderDate>2025-01-10</OrderDate>

  <Items>

    <Item>

      <ProductCode>Item001</ProductCode>

      <Description>Laptop</Description>

      <Quantity>2</Quantity>

      <Price>1200</Price>

    </Item>

    <Item>

      <ProductCode>Item002</ProductCode>

      <Description>Mouse</Description>

      <Quantity>5</Quantity>

      <Price>25</Price>

    </Item>

  </Items>

</PurchaseOrder>

 

  

Implementing the Scenario in Azure Logic Apps: Step-by-Step

1. Create Logic App: Choose Consumption (quick, pay-per-run) or Standard (high performance, local dev).

2. Integration Account (Consumption Only): Create in Portal, upload schemas/maps.

3. Build Workflow:

   - Trigger: SFTP "When a file is added or modified."

   - Action 1: Get file content.

   - Action 2: Flat File Decoding (select schema).

   - Action 3: XML Validation (if needed).

   - Action 4: Transform XML (apply map to reshape to System B XML).

   - Action 5: Send to System B (e.g., HTTP post or to SFTP location).

4. Test: Upload sample PO to SFTP, check run history for outputs/errors.

 

Now, let's explore each schema type with easy explanations, creation steps from scratch, tools, actions, and transformations. 

1. Flat File Schemas in Azure Logic Apps 

What They Are

Flat File schemas (XSD-based) describe text files without nested structures. Common in legacy systems, they include:

- Delimited: Fields separated by delimiters like commas (CSV) or pipes.

- Positional: Fields defined by fixed positions/lengths (no delimiters, e.g., "PO123     ABC Stores").

 

Schemas map these to XML for validation and processing.

 

How to Understand It

Imagine a flat list without folders—schemas add labels, types, and rules. For delimited, commas split fields; for positional, character positions do. In our scenario, System A's SFTP PO could be delimited CSV or positional, and the schema ensures correct parsing (e.g., Quantity as number).

 

Delimited Example (CSV PO with Schema Snippet):

Sample Message:

PO123,ABC Stores,2025-01-10

Item001,Laptop,2,1200

 

 

Schema (XSD excerpt):

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="Root">

    <xs:complexType>

      <xs:sequence>

        <xs:element name="Header" maxOccurs="1">

          <xs:annotation><xs:appinfo><ff:recordInfo structure="delimited" delimiter_type="char" delimiter_value="," /></xs:appinfo></xs:annotation>

          <xs:complexType>

            <xs:sequence>

              <xs:element name="OrderNumber" type="xs:string" />

              <xs:element name="Customer" type="xs:string" />

              <xs:element name="OrderDate" type="xs:date" />

            </xs:sequence>

          </xs:complexType>

        </xs:element>

        <xs:element name="Item" maxOccurs="unbounded">

          <xs:annotation><xs:appinfo><ff:recordInfo structure="delimited" delimiter_type="char" delimiter_value="," /></xs:appinfo></xs:annotation>

          <xs:complexType>

            <xs:sequence>

              <xs:element name="ProductCode" type="xs:string" />

              <xs:element name="Description" type="xs:string" />

              <xs:element name="Quantity" type="xs:integer" minOccurs="1" />

              <xs:element name="Price" type="xs:decimal" />

            </xs:sequence>

          </xs:complexType>

        </xs:element>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

</xs:schema>

 

  

Positional Example (Fixed-Width PO with Schema Snippet):

Sample Message:

PO123     ABC Stores     20250110

Item001   Laptop        021200

Item002   Mouse         050025

 

(Positions: OrderNumber 1-10, Customer 11-25, etc.)


Schema (XSD excerpt):

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="Root">

    <xs:complexType>

      <xs:sequence>

        <xs:element name="Header" maxOccurs="1">

          <xs:annotation><xs:appinfo><ff:recordInfo structure="positional" /></xs:appinfo></xs:annotation>

          <xs:complexType>

            <xs:sequence>

              <xs:element name="OrderNumber"><xs:annotation><xs:appinfo><ff:fieldInfo length="10" justification="left" /></xs:appinfo></xs:annotation><xs:simpleType><xs:restriction base="xs:string"><xs:length value="10" /></xs:restriction></xs:simpleType></xs:element>

              <xs:element name="Customer"><xs:annotation><xs:appinfo><ff:fieldInfo length="15" justification="left" /></xs:appinfo></xs:annotation><xs:simpleType><xs:restriction base="xs:string"><xs:length value="15" /></xs:restriction></xs:simpleType></xs:element>

              <xs:element name="OrderDate"><xs:annotation><xs:appinfo><ff:fieldInfo length="8" justification="left" /></xs:appinfo></xs:annotation><xs:simpleType><xs:restriction base="xs:string"><xs:length value="8" /></xs:restriction></xs:simpleType></xs:element>

            </xs:sequence>

          </xs:complexType>

        </xs:element>

        <xs:element name="Item" maxOccurs="unbounded">

          <xs:annotation><xs:appinfo><ff:recordInfo structure="positional" /></xs:appinfo></xs:annotation>

          <xs:complexType>

            <xs:sequence>

              <xs:element name="ProductCode"><xs:annotation><xs:appinfo><ff:fieldInfo length="8" justification="left" /></xs:appinfo></xs:annotation><xs:simpleType><xs:restriction base="xs:string"><xs:length value="8" /></xs:restriction></xs:simpleType></xs:element>

              <xs:element name="Description"><xs:annotation><xs:appinfo><ff:fieldInfo length="12" justification="left" /></xs:appinfo></xs:annotation><xs:simpleType><xs:restriction base="xs:string"><xs:length value="12" /></xs:restriction></xs:simpleType></xs:element>

              <xs:element name="Quantity"><xs:annotation><xs:appinfo><ff:fieldInfo length="2" justification="left" /></xs:appinfo></xs:annotation><xs:simpleType><xs:restriction base="xs:integer"><xs:length value="2" /></xs:restriction></xs:simpleType></xs:element>

              <xs:element name="Price"><xs:annotation><xs:appinfo><ff:fieldInfo length="4" justification="left" /></xs:appinfo></xs:annotation><xs:simpleType><xs:restriction base="xs:decimal"><xs:length value="4" /></xs:restriction></xs:simpleType></xs:element>

            </xs:sequence>

          </xs:complexType>

        </xs:element>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

</xs:schema>

 

 

How to Create It From Scratch

- Consumption: Build XSD, upload to Integration Account.

- Standard: Build XSD, add to Artifacts/Schemas folder.

 

Step-by-Step (Using Visual Studio 2019):

1. Install Visual Studio 2019 (free Community edition from https://visualstudio.microsoft.com/downloads/).

2. Install Microsoft Azure Logic Apps Enterprise Integration Tools extension (download: https://marketplace.visualstudio.com/items?itemName=ms-logicapps.EnterpriseIntegrationTools). 

3. Create a new project: File > New > Project > Integration Account Project.

4. Add schema: Right-click project > Add > New Item > Flat File Schema.

5. Launch Flat File Schema Wizard: Select "Delimited" or "Positional" for instance type.

6. Upload or paste sample message (e.g., CSV or fixed-width PO above).

7. Configure: For delimited, set delimiter (comma); for positional, define field lengths (e.g., OrderNumber=10 chars) and justifications (left/right padding).

8. Define hierarchy: Header record, child Item records; set data types (e.g., Quantity=integer, min=1) and validations (e.g., required fields).

9. Generate and test: Click Finish, then right-click schema > Test Schema with another sample to verify errors like invalid lengths.

10. Build project and export .xsd.

 

What Are the Tools

- Visual Studio 2019 + Enterprise Integration Tools (link above)—wizard for delimited/positional creation.

- Azure Portal for Consumption uploads (small files <2 MB direct; larger via Blob link).

- Visual Studio Code + Azure Logic Apps (Standard) extension (free from VS Code Marketplace: https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurelogicapps)—for managing/editing in Standard workflows; use VS 2019 for initial authoring.

 

What Are the Actions Used to Deal with Them in Logic App

In Designer (Portal for Consumption, VS Code for Standard):

- Flat File Decoding: Converts text to XML (e.g., decode SFTP PO for validation).

- Flat File Encoding: XML to text (e.g., output for legacy systems).

Setup: After SFTP "When a file is added" trigger, add action, select schema from Integration Account (Consumption) or local (Standard), input file content.

Handle options like empty nodes or delimiters. Test in run history to see XML output.

 

Transformations

After decoding to XML, use XSLT maps to reshape (e.g., add Total = sum(Quantity * Price)). 

Create maps: In VS 2019, add New Map, link source Flat File schema to target XML schema, drag fields, add functions (e.g., math operations). Upload to Integration Account (Consumption) or Artifacts/Maps (Standard). 

Apply via "Transform XML" action—in scenario, transform decoded PO to System B's XML.

 Flat files are always converted into XML internally before transformation in both models.


2. XML Schemas in Azure Logic Apps

 

What They Are

XML schemas (XSD files) define hierarchical data with elements, attributes, and constraints—common for structured integrations.

 

How to Understand It

Like a tree with branches: Root (PurchaseOrder) has children (Items). Schema sets rules like required elements or data types.

 

Brief PO Example (XML with Schema Snippet):

<PurchaseOrder>

  <OrderNumber>PO123</OrderNumber>

  <Customer>ABC Stores</Customer>

  <OrderDate>2025-01-10</OrderDate>

  <Items>

    <Item>

      <ProductCode>Item001</ProductCode>

      <Description>Laptop</Description>

      <Quantity>2</Quantity>

      <Price>1200</Price>

    </Item>

  </Items>

</PurchaseOrder>

 

 

Schema (XSD excerpt):

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="PurchaseOrder">

    <xs:complexType>

      <xs:sequence>

        <xs:element name="OrderNumber" type="xs:string" />

        <xs:element name="Customer" type="xs:string" />

        <xs:element name="OrderDate" type="xs:date" />

        <xs:element name="Items" minOccurs="1">

          <xs:complexType>

            <xs:sequence>

              <xs:element name="Item" maxOccurs="unbounded">

                <xs:complexType>

                  <xs:sequence>

                    <xs:element name="ProductCode" type="xs:string" />

                    <xs:element name="Description" type="xs:string" />

                    <xs:element name="Quantity" type="xs:positiveInteger" />

                    <xs:element name="Price" type="xs:decimal" />

                  </xs:sequence>

                </xs:complexType>

              </xs:element>

            </xs:sequence>

          </xs:complexType>

        </xs:element>

      </xs:sequence>

    </xs:complexType>

  </xs:element>

</xs:schema>

 

 

How to Create It From Scratch

- Consumption/Standard: Same process, upload accordingly.

 

Step-by-Step (VS 2019):

1. In Integration Project, right-click > Add > New Item > XML Schema.

2. Define root element (PurchaseOrder).

3. Add children visually: Drag elements, set types (e.g., OrderDate=date), constraints (minOccurs=1 for Items, positiveInteger for Quantity).

4. For relationships: Use complexTypes for nesting (e.g., Items as sequence of Item).

5. From sample: Right-click in editor > Generate Schema from pasted XML.

6. Validate: Right-click > Validate Schema; test with good/bad samples.

7. Export .xsd.

 

What Are the Tools

VS 2019 + Enterprise Integration Tools (link above). For Standard, VS Code handles management.

 

What Are the Actions Used to Deal with Them in Logic App

- XML Validation: Checks against schema (e.g., validate transformed PO).

- XPath Extract: Pulls data (e.g., `@xpath(xml(body('Decode_Flat_File')), '/PurchaseOrder/Items/Item/Price')`).

- Parse XML (Standard): Tokens for access.

- Compose XML (Standard): Builds from JSON.

Add after decode: Select schema, input XML.


Read for more insight:  Deep Dive in XML Schema


Transformations

XSLT maps for XML-to-XML (e.g., add subtotals). 

In VS 2019/Data Mapper (Standard), link schemas, map fields with functions. 

"Transform XML" action.


 Read about - Basic of Liquid Maps  

 And an Example of XML to JSON transformation using Liquid map


3. JSON Schemas in Azure Logic Apps

 

What They Are

JSON schemas define object-based data with properties, arrays, and rules—lightweight for APIs.


How to Understand It

Key-value pairs with validations. Native in Logic Apps for quick handling.

 

Brief PO Example (JSON with Schema Snippet):

{

  "purchaseOrder": {

    "orderNumber": "PO123",

    "customer": "ABC Stores",

    "orderDate": "2025-01-10",

    "items": [

      {

        "productCode": "Item001",

        "description": "Laptop",

        "quantity": 2,

        "price": 1200

      }

    ]

  }

}

 

 

Schema (excerpt):

{

  "$schema": "http://json-schema.org/draft-07/schema#",

  "type": "object",

  "properties": {

    "purchaseOrder": {

      "type": "object",

      "properties": {

        "orderNumber": { "type": "string" },

        "items": {

          "type": "array",

          "minItems": 1,

          "items": {

            "type": "object",

            "properties": {

              "quantity": { "type": "integer", "minimum": 1 }

            },

            "required": ["quantity"]

          }

        }

      }

    }

  }

}

 


How to Create It From Scratch

No external tools—inline.

- Both: In "Parse JSON" action, paste sample JSON, click "Generate from sample." Edit for rules (e.g., required fields).

 JSON schemas are usually embedded directly inside workflow actions rather than stored externally.


What Are the Tools

Logic Apps Designer (Portal/VS Code).

 

What Are the Actions Used to Deal with Them in Logic App

- Parse JSON: Validates and tokens (e.g., `@body('Parse_JSON')?['purchaseOrder']['items'][0]['price']`).

Parse JSON action does not actually stop the workflow if the data is wrong—it just passes the error to the next step. To truly "block" bad data, users must enable Schema Validation in the action's settings (dots menu -> Settings).

- Compose: Assembles JSON.

 

Transformations

Liquid templates (.liquid) for JSON-to-JSON/text/XML (e.g., {{purchaseOrder.items | Sum: 'price' }}). 

Create in text editor, upload/add to project. 

"Transform JSON to JSON" action.

By default, Logic Apps ignore extra fields. Adding this to the schema is a security best practice to ensure you only get the data you expect.

 

4. EDI Schemas in Azure Logic Apps

 

What They Are

EDI schemas (XSD-based) support B2B standards like X12 (North America), EDIFACT (global), RosettaNet—structured text with segments for documents like POs.

In following post I  have explained the basics oEDI and EDI X12 standards 


How to Understand It

Coded messages with headers/controls. Schema decodes to XML for processing.


Brief PO Example (X12 850 with Schema Snippet):

Sample Message:

ST*850*0001~

BEG*00*SA*PO12320250110~

PO1*1*2*EA*1200VN*Item001*Laptop~

PO1*2*5*EA*25VN*Item002*Mouse~

CTT*2~

SE*6*0001~

 


Schema (XSD excerpt for X12 00401 850):

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

  <xs:element name="X12_00401_850">

    <xs:complexType>

      <xs:sequence>

        <xs:element ref="ST" />

        <xs:element ref="BEG" />

        <xs:element ref="PO1" maxOccurs="unbounded" />

        <xs:element ref="CTT" />

        <xs:element ref="SE" />

      </xs:sequence>

    </xs:complexType>

  </xs:element>

</xs:schema>

 

 

How to Create It From Scratch

- Consumption: Requires Integration Account with agreements.

- Standard: Local storage.

 

Step-by-Step (VS 2019):

1. In project, add New Item > Flat File Schema (EDI uses flat file base).

2. Use wizard: Select EDI type (X12/EDIFACT), version (e.g., 00401), transaction set (850 for PO).

3. Customize segments (e.g., add qualifiers for sender/receiver).

4. For standards, download templates and import.

5. Validate with sample EDI message.

6. Export .xsd.

 

What Are the Tools

VS 2019 Enterprise Tools (link above). 

Download EDI schemas:https://www.microsoft.com/en-us/download/details.aspx?id=39087


What Are the Actions Used to Deal with Them in Logic App

- Decode X12/EDIFACT: Text to XML (e.g., decode B2B PO).

- Encode X12/EDIFACT: XML to text, with batching/acknowledgments.

Consumption: Link Integration Account with partners/agreements.

Standard: Local schema. Add after trigger, select agreement/schema.

 

Transformations

Post-decode to XML, use XSLT maps (as in XML). For B2B, chain with AS2 for secure transport.

EDI processing still heavily depends on agreement configuration even in Standard workflows.

Examples of EDI to XML in Logic App and XML to EDI in Logic App



Best Practices for Working with Schemas 

- Use Samples: Always start with real PO messages to generate schemas—avoids guesswork.

- Version Control: Name schemas with versions (e.g., PO_Schema_v1.xsd) for updates.

- Reusable Artifacts: Design schemas/maps for multiple workflows.

- Validation First: Test schemas/maps in tools before Logic Apps deployment.

- Error Handling: Add conditions for invalid data (e.g., if validation fails, send email).

- Security: Use SAS URLs for large files; link Integration Accounts securely.

Schemas are the backbone of Azure integrations, turning chaotic data into smooth flows. 


Schema = Structure + Rules for Data


 Summary

Schema Type

Purpose

Common Usage

Flat File

Legacy file-based integrations

Mainframe, ERP exports, batch files

XML

Enterprise structured data exchange

SOAP services, B2B integrations

JSON

Modern API communication

REST APIs, microservices

EDI

Standardized partner-to-partner business exchange

Supply chain, retail, logistics

 




Learn More about Logic App


Useful References:

- Visual Studio Downloads: https://visualstudio.microsoft.com/downloads/

- Enterprise Integration Tools: https://marketplace.visualstudio.com/items?itemName=ms-logicapps.EnterpriseIntegrationTools

- VS Code Logic Apps Extension: https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurelogicapps

- EDIFACT Schemas: https://github.com/DFDLSchemas/EDIFACT

- BizTalk EDI Templates (adaptable): https://github.com/microsoft/Integration/tree/master/BizTalk%20Server/Schema/EDIFACT

- Microsoft Learn: https://learn.microsoft.com/en-us/azure/logic-apps/

 


Post a Comment

If you have any suggestions or questions or want to share something then please drop a comment

Previous Post Next Post