使用带有 Enterprise Integration Pack 的 Azure 逻辑应用中的映射转换 XMLTransform XML with maps in Azure Logic Apps with Enterprise Integration Pack

若要在 Azure 逻辑应用中的企业集成方案格式之间传输 XML 数据,逻辑应用可以使用映射,或者更具体地说,使用可扩展样式表语言转换 (XSLT) 映射。To transfer XML data between formats for enterprise integration scenarios in Azure Logic Apps, your logic app can use maps, or more specifically, Extensible Style sheet Language Transformations (XSLT) maps. 映射是一个 XML 文档,描述如何将 XML 文档中的数据转换为另一种格式。A map is an XML document that describes how to convert data from an XML document into another format.

例如,假设你从使用 YYYMMDD 日期格式的客户定期接收 B2B 订单或发票。For example, suppose you regularly receive B2B orders or invoices from a customer who uses the YYYMMDD date format. 但是,你的组织使用 MMDDYYY 日期格式。However, your organization uses the MMDDYYY date format. 在将订单或发票详细信息存储在客户活动数据库中之前,可以定义并使用一个映射将 YYYMMDD 日期格式转换为 MMDDYYY 格式。You can define and use a map that transforms the YYYMMDD date format to the MMDDYYY format before storing the order or invoice details in your customer activity database.

有关集成帐户和映射等项目的限制,请参阅 Azure 逻辑应用的限制和配置信息For limits related to integration accounts and artifacts such as maps, see Limits and configuration information for Azure Logic Apps.

先决条件Prerequisites

创建和添加映射时不需要逻辑应用。You don't need a logic app when creating and adding maps. 但是,若要使用映射,逻辑应用需要链接到存储该映射的集成帐户。However, to use a map, your logic app needs linking to an integration account where you store that map. 了解如何将逻辑应用链接到集成帐户Learn how to link logic apps to integration accounts. 如果没有逻辑应用,请了解如何创建逻辑应用If you don't have a logic app yet, learn how to create logic apps.

添加引用的程序集Add referenced assemblies

  1. 使用 Azure 帐户凭据登录到 Azure 门户Sign in to the Azure portal with your Azure account credentials.

  2. 若要查找并打开集成帐户,请在 Azure 主菜单中选择“所有服务”。 To find and open your integration account, on the main Azure menu, select All services. 在搜索框中,输入“集成帐户”。In the search box, enter "integration account". 选择“集成帐户”。 Select Integration accounts.

    查找集成帐户

  3. 选择要将程序集添加到的集成帐户,例如:Select the integration account where you want to add your assembly, for example:

    选择“集成帐户”

  4. 在集成帐户的“概述”页上的“组件”下,选择“程序集”磁贴。 On your integration account's Overview page, under Components, select the Assemblies tile.

    选择“程序集”

  5. “程序集”页打开后,请选择“添加”。 After the Assemblies page opens, choose Add.

    选择“添加”

根据程序集文件的大小,遵循相应的步骤来上传不超过 2 MB大于 2 MB 但不超过 8 MB 的程序集。Based on your assembly file's size, follow the steps for uploading an assembly that's either up to 2 MB or more than 2 MB but only up to 8 MB. 有关集成帐户中程序集数量的限制,请参阅 Azure 逻辑应用的限制和配置For limits on assembly quantities in integration accounts, see Limits and configuration for Azure Logic Apps.

备注

如果更改程序集,则无论映射是否有更改,都必须更新映射。If you change your assembly, you must also update your map whether or not the map has changes.

添加不超过 2 MB 的程序集Add assemblies up to 2 MB

  1. 在“添加程序集”下,输入程序集的名称。 Under Add Assembly, enter a name for your assembly. 将“小文件”保持选定状态。 Keep Small file selected. 选择“程序集”框旁边的文件夹图标。 Next to the Assembly box, choose the folder icon. 找到并选择要上传的程序集,例如:Find and select the assembly you're uploading, for example:

    上传小型程序集

    选择程序集后,该程序集的文件名会自动显示在“程序集名称”属性中。 In the Assembly Name property, the assembly's file name appears automatically after you select the assembly.

  2. 准备就绪后,选择“确定” 。When you're ready, choose OK.

    完成程序集文件上传后,该程序集将显示在“程序集”列表中。 After your assembly file finishes uploading, the assembly appears in the Assemblies list.

    加载的程序集列表

    在集成帐户的“概述”页上的“组件”下,“程序集”磁贴现在会显示已上传的程序集数目,例如: On your integration account's Overview page, under Components, the Assemblies tile now shows the number of uploaded assemblies, for example:

    上传的程序集数目

添加 2 MB 以上的程序集Add assemblies more than 2 MB

若要添加更大的程序集,可将程序集上传到 Azure 存储帐户中的 Azure Blob 容器。To add larger assemblies, you can upload your assembly to an Azure blob container in your Azure storage account. 添加程序集的步骤因 Blob 容器是否具有公共读取访问权限而异。Your steps for adding assemblies differ based whether your blob container has public read access. 因此,首先请执行以下步骤检查 Blob 容器是否具有公共读取访问权限:为 Blob 容器设置公共访问级别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. 打开 Azure 存储资源管理器。Open Azure Storage Explorer. 在“资源管理器”窗口中展开你的 Azure 订阅(如果尚未展开)。In the Explorer window, expand your Azure subscription if not already expanded.

  2. 展开“存储帐户”>“{你的存储帐户}”>“Blob 容器”。 Expand Storage Accounts > {your-storage-account} > Blob Containers. 选择你的 Blob 容器。Select your blob container.

  3. 在 Blob 容器的快捷菜单中,选择“设置公共访问级别”。 From your blob container's shortcut menu, select Set Public Access Level.

上传到具有公共访问权限的容器Upload to containers with public access

  1. 将程序集上传到存储帐户。Upload the assembly to your storage account. 在右侧窗口中,选择“上传”。 In the right-hand window, choose Upload.

  2. 完成上传后,选择上传的程序集。After you finish uploading, select your uploaded assembly. 在工具栏中,选择“复制 URL”以复制程序集的 URL。 On the toolbar, choose Copy URL so that you copy the assembly's URL.

  3. 返回 Azure 门户,其中已打开“添加程序集”窗格。 Return to the Azure portal where the Add Assembly pane is open. 输入程序集的名称。Enter a name for your assembly. 选择“大文件(大于 2 MB)”。 Choose Large file (larger than 2 MB).

    此时会显示“内容 URI”框而不是“程序集”框。 The Content URI box now appears, rather than the Assembly box.

  4. 在“内容 URI”框中,粘贴程序集的 URL。 In the Content URI box, paste your assembly's URL. 完成添加程序集。Finish adding your assembly.

完成程序集上传后,架构将显示在“程序集”列表中。 After your assembly finishes uploading, the schema appears in the Assemblies list. 在集成帐户的“概述”页上的“组件”下,“程序集”磁贴现在会显示已上传的程序集数目。 On your integration account's Overview page, under Components, the Assemblies tile now shows the number of uploaded assemblies.

上传到没有公共访问权限的容器Upload to containers without public access

  1. 将程序集上传到存储帐户。Upload the assembly to your storage account. 在右侧窗口中,选择“上传”。 In the right-hand window, choose Upload.

  2. 上传完成后,为程序集生成共享访问签名 (SAS)。After you finish uploading, generate a shared access signature (SAS) for your assembly. 在程序集的快捷菜单中,选择“获取共享访问签名”。 From your assembly's shortcut menu, select Get Shared Access Signature.

  3. 在“共享访问签名”窗格中,选择“生成容器级共享访问签名 URI” > “创建”。 In the Shared Access Signature pane, select Generate container-level shared access signature URI > Create. 生成 SAS URL 后,选择“URL”框旁边的“复制”。 After the SAS URL gets generated, next to the URL box, choose Copy.

  4. 返回 Azure 门户,其中已打开“添加程序集”窗格。 Return to the Azure portal where the Add Assembly pane is open. 输入程序集的名称。Enter a name for your assembly. 选择“大文件(大于 2 MB)”。 Choose Large file (larger than 2 MB).

    此时会显示“内容 URI”框而不是“程序集”框。 The Content URI box now appears, rather than the Assembly box.

  5. 在“内容 URI”框中,粘贴前面生成的 SAS URI。 In the Content URI box, paste the SAS URI you previously generated. 完成添加程序集。Finish adding your assembly.

完成程序集上传后,该程序集将显示在“架构”列表中。 After your assembly finishes uploading, the assembly appears in the Schemas list. 在集成帐户的“概述”页上的“组件”下,“程序集”磁贴现在会显示已上传的程序集数目。 On your integration account's Overview page, under Components, the Assemblies tile now shows the number of uploaded assemblies.

创建映射Create maps

若要创建可用作映射的 XSLT 文档,可以在 Visual Studio 2015 中使用 Enterprise Integration Pack 创建 BizTalk 集成项目。To create an XSLT document you can use as a map, you can use Visual Studio 2015 for creating a BizTalk Integration project by using the Enterprise Integration Pack. 在此项目中,可以生成用于直观地在两个 XML 架构文件之间映射项的集成映射文件。In this project, you can build an integration map file, which lets you visually map items between two XML schema files. 生成此项目后,会获得一个 XSLT 文档。After you build this project, you get an XSLT document. 有关集成帐户中映射数量的限制,请参阅 Azure 逻辑应用的限制和配置For limits on map quantities in integration accounts, see Limits and configuration for Azure Logic Apps.

添加映射Add maps

上传映射引用的所有程序集之后,接下来可以上传映射。After you upload any assemblies that your map references, you can now upload your map.

  1. 如果尚未登录,请使用 Azure 帐户凭据登录到 Azure 门户If you haven't signed in already, sign in to the Azure portal with your Azure account credentials.

  2. 如果你的集成帐户尚未打开,请在 Azure 主菜单中选择“所有服务”。 If your integration account isn't already open, on the main Azure menu, select All services. 在搜索框中,输入“集成帐户”。In the search box, enter "integration account". 选择“集成帐户”。 Select Integration accounts.

    查找集成帐户

  3. 选择要将映射添加到的集成帐户,例如:Select the integration account where you want to add your map, for example:

    选择“集成帐户”

  4. 在集成帐户的“概述”页上的“组件”下,选择“映射”磁贴。 On your integration account's Overview page, under Components, select the Maps tile.

    选择“映射”

  5. “映射”页打开后,请选择“添加” 。After the Maps page opens, choose Add.

    选择“添加”

添加不超过 2 MB 的映射Add maps up to 2 MB

  1. 在“添加映射”下,输入映射的名称。 Under Add Map, enter a name for your map.

  2. 在“映射类型”下选择类型,例如: “Liquid”、“XSLT”、“XSLT 2.0”或“XSLT 3.0”。 Under Map type, select the type, for example: Liquid, XSLT, XSLT 2.0, or XSLT 3.0.

  3. 将“小文件”保持选定状态。 Keep Small file selected. 选择“映射”框旁边的文件夹图标。 Next to the Map box, choose the folder icon. 找到并选择要上传的映射,例如:Find and select the map you're uploading, for example:

    上传映射

    如果将“名称”属性留空,则选择映射文件后,映射的文件名将自动显示在该属性中。 If you left the Name property empty, the map's file name automatically appears in that property automatically after you select the map file. 但是,可以使用任何唯一名称。However, you can use any unique name.

  4. 准备就绪后,选择“确定” 。When you're ready, choose OK. 完成映射文件上传后,该映射将显示在“映射”列表中。 After your map file finishes uploading, the map appears in the Maps list.

    上传的映射列表

    在集成帐户的“概述”页上的“组件”下,“映射”磁贴现在会显示已上传的映射数目,例如: On your integration account's Overview page, under Components, the Maps tile now shows the number of uploaded maps, for example:

    上传的映射数目

添加 2 MB 以上的映射Add maps more than 2 MB

目前,若要添加较大的映射,需要使用 Azure 逻辑应用 REST API - 映射Currently, to add larger maps, use the Azure Logic Apps REST API - Maps.

编辑映射Edit maps

若要更新现有的映射,必须上传一个新的映射文件,其中包含所要做出的更改。To update an existing map, you have to upload a new map file that has the changes you want. 但是,可以先下载现有的映射进行编辑。However, you can first download the existing map for editing.

  1. Azure 门户中,找到并打开你的集成帐户(如果尚未打开)。In the Azure portal, find and open your integration account, if not already open.

  2. 在 Azure 主菜单中,选择“所有服务” 。On the main Azure menu, select All services. 在搜索框中,输入“集成帐户”。In the search box, enter "integration account". 选择“集成帐户”。 Select Integration accounts.

  3. 选择要在其中更新映射的集成帐户。Select the integration account where you want to update your map.

  4. 在集成帐户的“概述”页上的“组件”下,选择“映射”磁贴。 On your integration account's Overview page, under Components, select the Maps tile.

  5. “映射”页打开后,请选择你的映射。 After the Maps page opens, select your map. 若要先下载并编辑映射,请选择“下载”,然后保存映射。 To download and edit the map first, choose Download, and save the map.

  6. 准备好上传更新的映射时,请在“映射”页上选择要更新的映射,然后选择“更新”。 When you're ready to upload the updated map, on the Maps page, select the map you want to update, and choose Update.

  7. 找到并选择要上传的已更新映射。Find and select the updated map you want to upload. 完成映射文件上传后,更新的映射将显示在“映射”列表中。 After your map file finishes uploading, the updated map appears in the Maps list.

删除映射Delete maps

  1. Azure 门户中,找到并打开你的集成帐户(如果尚未打开)。In the Azure portal, find and open your integration account, if not already open.

  2. 在 Azure 主菜单中,选择“所有服务” 。On the main Azure menu, select All services. 在搜索框中,输入“集成帐户”。In the search box, enter "integration account". 选择“集成帐户”。 Select Integration accounts.

  3. 选择要在其中删除映射的集成帐户。Select the integration account where you want to delete your map.

  4. 在集成帐户的“概述”页上的“组件”下,选择“映射”磁贴。 On your integration account's Overview page, under Components, select the Maps tile.

  5. “映射”页打开后,请选择你的映射,然后选择“删除”。 After the Maps page opens, select your map, and choose Delete.

  6. 若要确认删除该映射,请选择“是”。 To confirm you want to delete the map, choose Yes.

后续步骤Next steps