使用带有 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
Azure 订阅。An Azure subscription. 如果没有 Azure 订阅,请注册试用版订阅。If you don't have a subscription, sign up for a Trial Subscription.
一个集成帐户,用于存储映射以及企业集成与企业到企业 (B2B) 解决方案的其他项目。An integration account where you store your maps and other artifacts for enterprise integration and business-to-business (B2B) solutions.
如果映射引用了外部程序集,必须将该程序集和映射上传到集成帐户。 If your map references an external assembly, you have to upload both the assembly and the map to your integration account. 请务必先上传程序集,然后再上传引用程序集的映射。 Make sure you upload your assembly first, and then upload the map that references the assembly.
如果程序集为 2 MB 或更小,可以直接从 Azure 门户将程序集添加到集成帐户。 If your assembly is 2 MB or smaller, you can add your assembly to your integration account directly from the Azure portal. 但是,如果程序集或映射大于 2 MB 但不超过程序集或映射的大小限制,则可以使用以下选项:However, if your assembly or map is bigger than 2 MB but not bigger than the size limit for assemblies or maps, you have these options:
对于程序集,需要一个可在其中上传程序集的 Azure Blob 容器,并规划好该容器的位置。For assemblies, you need an Azure blob container where you can upload your assembly and that container's location. 这样,在将程序集添加到集成帐户时,便可以提供该位置。That way, you can provide that location later when you add the assembly to your integration account. 对于此任务,需要提供以下各项:For this task, you need these items:
项目Item 说明Description Azure 存储帐户Azure storage account 在此帐户中创建程序集的 Azure Blob 容器。In this account, create an Azure blob container for your assembly. 了解如何创建存储帐户。Learn how to create a storage account. Blob 容器Blob container 可在此容器中上传程序集。In this container, you can upload your assembly. 将程序集添加到集成帐户时,也需要此容器的位置。You also need this container's location when you add the assembly to your integration account. 了解如何创建 Blob 容器。Learn how to create a blob container. Azure 存储资源管理器Azure Storage Explorer 借助此工具可以更轻松地管理存储帐户和 Blob 容器。This tool helps you more easily manage storage accounts and blob containers. 若要使用存储资源管理器,请下载并安装 Azure 存储资源管理器。To use Storage Explorer, either download and install Azure Storage Explorer. 然后,遵循存储资源管理器入门中的步骤将存储资源管理器连接到存储帐户。Then, connect Storage Explorer to your storage account by following the steps in Get started with Storage Explorer. 若要了解详细信息,请参阅快速入门:使用 Azure 存储资源管理器在对象存储中创建 Blob。To learn more, see Quickstart: Create a blob in object storage with Azure Storage Explorer. 或者,在 Azure 门户中找到并选择你的存储帐户。Or, in the Azure portal, find and select your storage account. 在存储帐户菜单中选择“存储资源管理器”。 From your storage account menu, select Storage Explorer.
对于映射,目前可以使用 Azure 逻辑应用 REST API - 映射添加较大的映射。For maps, you can currently add larger maps by using the Azure Logic Apps REST API - Maps.
创建和添加映射时不需要逻辑应用。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
使用 Azure 帐户凭据登录到 Azure 门户。Sign in to the Azure portal with your Azure account credentials.
若要查找并打开集成帐户,请在 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.
选择要将程序集添加到的集成帐户,例如:Select the integration account where you want to add your assembly, for example:
在集成帐户的“概述”页上的“组件”下,选择“程序集”磁贴。 On your integration account's Overview page, under Components, select the Assemblies tile.
“程序集”页打开后,请选择“添加”。 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
在“添加程序集”下,输入程序集的名称。 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.
准备就绪后,选择“确定” 。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
打开 Azure 存储资源管理器。Open Azure Storage Explorer. 在“资源管理器”窗口中展开你的 Azure 订阅(如果尚未展开)。In the Explorer window, expand your Azure subscription if not already expanded.
展开“存储帐户”>“{你的存储帐户}”>“Blob 容器”。 Expand Storage Accounts > {your-storage-account} > Blob Containers. 选择你的 Blob 容器。Select your blob container.
在 Blob 容器的快捷菜单中,选择“设置公共访问级别”。 From your blob container's shortcut menu, select Set Public Access Level.
如果 Blob 容器至少具有公共访问权限,请选择“取消”,并执行本页稍后所述的以下步骤: 上传到具有公共访问权限的容器If your blob container has at least public access, choose Cancel, and follow these steps later on this page: Upload to containers with public access
如果 Blob 容器没有公共访问权限,请选择“取消”,并执行本页稍后所述的以下步骤: 上传到没有公共访问权限的容器If your blob container doesn't have public access, choose Cancel, and follow these steps later on this page: Upload to containers without public access
上传到具有公共访问权限的容器Upload to containers with public access
将程序集上传到存储帐户。Upload the assembly to your storage account. 在右侧窗口中,选择“上传”。 In the right-hand window, choose Upload.
完成上传后,选择上传的程序集。After you finish uploading, select your uploaded assembly. 在工具栏中,选择“复制 URL”以复制程序集的 URL。 On the toolbar, choose Copy URL so that you copy the assembly's URL.
返回 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.
在“内容 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
将程序集上传到存储帐户。Upload the assembly to your storage account. 在右侧窗口中,选择“上传”。 In the right-hand window, choose Upload.
上传完成后,为程序集生成共享访问签名 (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.
在“共享访问签名”窗格中,选择“生成容器级共享访问签名 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.
返回 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.
在“内容 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.
如果尚未登录,请使用 Azure 帐户凭据登录到 Azure 门户。If you haven't signed in already, sign in to the Azure portal with your Azure account credentials.
如果你的集成帐户尚未打开,请在 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.
选择要将映射添加到的集成帐户,例如:Select the integration account where you want to add your map, for example:
在集成帐户的“概述”页上的“组件”下,选择“映射”磁贴。 On your integration account's Overview page, under Components, select the Maps tile.
“映射”页打开后,请选择“添加” 。After the Maps page opens, choose Add.
添加不超过 2 MB 的映射Add maps up to 2 MB
在“添加映射”下,输入映射的名称。 Under Add Map, enter a name for your map.
在“映射类型”下选择类型,例如: “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.
将“小文件”保持选定状态。 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.
准备就绪后,选择“确定” 。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.
在 Azure 门户中,找到并打开你的集成帐户(如果尚未打开)。In the Azure portal, find and open your integration account, if not already open.
在 Azure 主菜单中,选择“所有服务” 。On the main Azure menu, select All services. 在搜索框中,输入“集成帐户”。In the search box, enter "integration account". 选择“集成帐户”。 Select Integration accounts.
选择要在其中更新映射的集成帐户。Select the integration account where you want to update your map.
在集成帐户的“概述”页上的“组件”下,选择“映射”磁贴。 On your integration account's Overview page, under Components, select the Maps tile.
“映射”页打开后,请选择你的映射。 After the Maps page opens, select your map. 若要先下载并编辑映射,请选择“下载”,然后保存映射。 To download and edit the map first, choose Download, and save the map.
准备好上传更新的映射时,请在“映射”页上选择要更新的映射,然后选择“更新”。 When you're ready to upload the updated map, on the Maps page, select the map you want to update, and choose Update.
找到并选择要上传的已更新映射。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
在 Azure 门户中,找到并打开你的集成帐户(如果尚未打开)。In the Azure portal, find and open your integration account, if not already open.
在 Azure 主菜单中,选择“所有服务” 。On the main Azure menu, select All services. 在搜索框中,输入“集成帐户”。In the search box, enter "integration account". 选择“集成帐户”。 Select Integration accounts.
选择要在其中删除映射的集成帐户。Select the integration account where you want to delete your map.
在集成帐户的“概述”页上的“组件”下,选择“映射”磁贴。 On your integration account's Overview page, under Components, select the Maps tile.
“映射”页打开后,请选择你的映射,然后选择“删除”。 After the Maps page opens, select your map, and choose Delete.
若要确认删除该映射,请选择“是”。 To confirm you want to delete the map, choose Yes.