Add schemas to validate XML in workflows with Azure Logic Apps

To check that documents use valid XML and have the expected data in the predefined format, your logic app workflow can use XML schemas with the XML Validation action. An XML schema describes a business document that's represented in XML using the XML Schema Definition (XSD).

If you're new to logic apps, review What is Azure Logic Apps? For more information about B2B enterprise integration, review B2B enterprise integration workflows with Azure Logic Apps and Enterprise Integration Pack.

Prerequisites

  • An Azure account and subscription. If you don't have a subscription yet, sign up for a free Azure account.

  • To create schemas, you can use the following tools:

    Important

    Don't install the extension alongside the BizTalk Server extension. Having both extensions might produce unexpected behavior. Make sure that you only have one of these extensions installed.

    Note

    On high resolution monitors, you might experience a display problem with the map designer in Visual Studio. To resolve this display problem, either restart Visual Studio in DPI-unaware mode, or add the DPIUNAWARE registry value.

  • An integration account resource where you define and store artifacts, such as trading partners, agreements, certificates, and so on, for use in your enterprise integration and B2B workflows. This resource has to meet the following requirements:

    • Is associated with the same Azure subscription as your logic app resource.

    • Exists in the same location or Azure region as your logic app resource where you plan to use the XML Validation action.

    • If you use the Logic App (Consumption) resource type, you have to link your integration account to your logic app resource before you can use your artifacts in your workflow.

      To create and add schemas for use in Logic App (Consumption) workflows, you don't need a logic app resource yet. However, when you're ready to use those schemas in your workflows, your logic app resource requires a linked integration account that stores those schemas.

    • If you use the Logic App (Standard) resource type, you need an existing logic app resource because you don't store schemas in your integration account. Instead, you can directly add schemas to your logic app resource using either the Azure portal or Visual Studio Code. You can then use these schemas across multiple workflows within the same logic app resource.

      You still need an integration account to store other artifacts, such as partners, agreements, and certificates, along with using the AS2, X12, and EDIFACT operations. However, you don't need to link your logic app resource to your integration account, so the linking capability doesn't exist. Your integration account still has to meet other requirements, such as using the same Azure subscription and existing in the same location as your logic app resource.

      Note

      Currently, only the Logic App (Consumption) resource type supports RosettaNet operations. The Logic App (Standard) resource type doesn't include RosettaNet operations.

  • If your schema is 2 MB or smaller, you can add your schema to your integration account directly from the Azure portal. However, if your schema is bigger than 2 MB but not bigger than the size limit for schemas, you can upload your schema to an Azure storage account. To add that schema to your integration account, you can then link to your storage account from your integration account. For this task, here are the items you need:

    Item Description
    Azure storage account In this account, create an Azure blob container for your schema. Learn how to create a storage account.
    Blob container In this container, you can upload your schema. You also need this container's content URI later when you add the schema to your integration account. Learn how to create a blob container.
    Azure Storage Explorer This tool helps you more easily manage storage accounts and blob containers. To use Storage Explorer, choose a step:

    - In the Azure portal, select your storage account. From your storage account menu, select Storage Explorer.

    - For the desktop version, download and install Azure Storage Explorer. Then, connect Storage Explorer to your storage account by following the steps in Get started with Storage Explorer. To learn more, see Quickstart: Create a blob in object storage with Azure Storage Explorer.

    To add larger schemas for the Logic App (Consumption) resource type, you can also use the Azure Logic Apps REST API - Schemas. However, for the Logic App (Standard) resource type, the Azure Logic Apps REST API is currently unavailable.

Limits

  • For Logic App (Standard), no limits exist for schema file sizes.

  • For Logic App (Consumption), limits exist for integration accounts and artifacts such as schemas. For more information, review Limits and configuration information for Azure Logic Apps.

    Usually, when you're using an integration account with your workflow and you want to validate XML, you add or upload the schema to that account. If you're referencing or importing a schema that's not in your integration account, you might receive the following error when you use the element xsd:redefine:

    An error occurred while processing the XML schemas: ''SchemaLocation' must successfully resolve if <redefine> contains any child other than <annotation>.'.

    To resolve this error, you need to use the element xsd:import or xsd:include instead of xsd:redefine, or use a URI.

Add schemas

  1. In the Azure portal, sign in with your Azure account credentials.

  2. In the main Azure search box, enter integration accounts, and select Integration accounts.

  3. Select the integration account where you want to add your schema.

  4. On your integration account's menu, under Settings, select Schemas.

  5. On the Schemas pane toolbar, select Add.

Based on your schema (.xsd) file's size, follow the steps for uploading a schema that's either up to 2 MB or more than 2 MB, up to 8 MB.

Add schemas up to 2 MB

  1. On the Add Schema pane, enter a name for your schema. Keep Small file selected. Next to the Schema box, select the folder icon. Find and select the schema you're uploading.

  2. When you're done, select OK.

    After your schema finishes uploading, the schema appears in the Schemas list.

Add schemas more than 2 MB

To add larger schemas, you can upload your schema to an Azure blob container in your Azure storage account. Your steps for adding schemas differ based whether your blob container has public read access. So first, check whether or not your blob container has public read access by following these steps: Set public access level for blob container

Check container access level

  1. Open Azure Storage Explorer. In the Explorer window, expand your Azure subscription if not already expanded.

  2. Expand Storage Accounts > {your-storage-account} > Blob Containers. Select your blob container.

  3. From your blob container's shortcut menu, select Set Public Access Level.

Upload to containers with public access

  1. Upload the schema to your storage account. In the right-hand window, select Upload.

  2. After you finish uploading, select your uploaded schema. On the toolbar, select Copy URL so that you copy the schema's URL.

  3. Return to the Azure portal where the Add Schema pane is open. Enter a name for your assembly. Select Large file (larger than 2 MB).

    The Content URI box now appears, rather than the Schema box.

  4. In the Content URI box, paste your schema's URL. Finish adding your schema.

After your schema finishes uploading, the schema appears in the Schemas list. On your integration account's Overview page, under Artifacts, your uploaded schema appears.

Upload to containers without public access

  1. Upload the schema to your storage account. In the right-hand window, select Upload.

  2. After you finish uploading, generate a shared access signature (SAS) for your schema. From your schema's shortcut menu, select Get Shared Access Signature.

  3. In the Shared Access Signature pane, select Generate container-level shared access signature URI > Create. After the SAS URL gets generated, next to the URL box, select Copy.

  4. Return to the Azure portal where the Add Schema pane is open. Select Large file.

    The Content URI box now appears, rather than the Schema box.

  5. In the Content URI box, paste the SAS URI you previously generated. Finish adding your schema.

After your schema finishes uploading, the schema appears in the Schemas list. On your integration account's Overview page, under Artifacts, your uploaded schema appears.

Edit a schema

To update an existing schema, you have to upload a new schema file that has the changes you want. However, you can first download the existing schema for editing.

  1. In the Azure portal, open your integration account, if not already open.

  2. On your integration account's menu, under Settings, select Schemas.

  3. After the Schemas pane opens, select your schema. To download and edit the schema first, on the Schemas pane toolbar, select Download, and save the schema.

  4. When you're ready to upload the updated schema, on the Schemas pane, select the schema that you want to update. On the Schemas pane toolbar, select Update.

  5. Find and select the updated schema you want to upload.

  6. When you're done, select OK.

    After your schema file finishes uploading, the updated schema appears in the Schemas list.

Delete a schema

  1. In the Azure portal, open your integration account, if not already open.

  2. On your integration account's menu, under Settings, select Schemas.

  3. After the Schemas pane opens, select your schema, and then select Delete.

  4. To confirm you want to delete the schema, select Yes.

Next steps