使用XML源的Azure数据工厂复制数据

时间:2020-09-18 12:05:07

标签: azure azure-data-factory azure-data-factory-2 azure-data-factory-pipeline

假设我有一个简单的XML文件源,已将其映射到SQL Server数据库中的相应接收器。

<Date Date="2020-03-13Z">
    <Identification>
        <Identifier>Maverick</Identifier>
    </Identification>
    <Pilot HomeAirport="New York">
        <AirportICAOCode>USA</AirportICAOCode>
    </Pilot>
</Date>

然后是模式

CREATE TABLE pilots
identifier VARCHAR(20),
ICAO_code VARCHAR(3)
)

我在sql服务器数据库中创建了一个存储过程,该存储过程接受用户定义的表类型pilots_type的输入,该表类型对应于上述架构,以正确地合并我的数据。

但是在运行时管道失败并显示以下错误:

{
"errorCode": "2200",
"message": "ErrorCode=UserErrorInvalidPluginType,'Type=Microsoft.DataTransfer.Common.Shared.PluginNotRegisteredException,Message=Invalid type 'XmlFormat' is provided in 'format'. Please correct the type in payload and retry.,Source=Microsoft.DataTransfer.ClientLibrary,'",
"failureType": "UserError",
"target": "Sink XML",
"details": []
}

查看图片
这里的源是包含XML的Blob。 enter image description here

毕竟不支持将XML作为源吗?

1 个答案:

答案 0 :(得分:1)

支持XML作为源。
我已经根据您的示例x​​ml文件和sql表成功进行了相同的测试。

  1. 我创建了一个名为ct_pilot_type的表类型:
CREATE TYPE ct_pilot_type AS TABLE(
identifier  nvarchar(MAX),
ICAO_code nvarchar(MAX)
)
  1. 我创建了名为spUpsertPolit的存储过程:
CREATE PROCEDURE spUpsertPolit

@polit ct_pilot_type READONLY

AS

BEGIN

MERGE [dbo].[pilot_airports] AS target_sqldb

USING @polit AS source_tblstg

ON (target_sqldb.identifier = source_tblstg.identifier)

WHEN MATCHED THEN

UPDATE SET

identifier = source_tblstg.identifier,

ICAO_code = source_tblstg.ICAO_code


WHEN NOT MATCHED THEN

INSERT (

identifier,

ICAO_code

)

VALUES (

source_tblstg.identifier,

source_tblstg.ICAO_code

);

END
  1. 我在“复制”活动中设置了接收器:

enter image description here

  1. 我设置了映射:

enter image description here

  1. 已成功cpoied: enter image description here

  2. 结果显示:
    enter image description here