分享方式:


對應資料流程中的外部呼叫轉換

適用於:Azure Data Factory Azure Synapse Analytics

提示

試用 Microsoft Fabric 中的 Data Factory,這是適用於企業的全方位分析解決方案。 Microsoft Fabric 涵蓋從資料移動到資料科學、即時分析、商業智慧和報告的所有項目。 了解如何免費啟動新的試用版

Azure Data Factory 和 Azure Synapse Pipelines 中均可使用資料流。 本文適用於對應資料流。 若您不熟悉轉換作業,請參閱簡介文章使用對應資料流轉換資料

外部呼叫轉換可讓資料工程師逐列呼叫外部 REST 端點,以便將自訂或協力廠商結果新增至資料流程串流。

組態

在 [外部呼叫轉換組態] 面板中,您會先挑選您想要連線的外部端點類型。 下一個步驟是對應傳入的資料行。 最後,定義下游轉換所取用的輸出資料結構。

External call

設定

選擇內嵌資料集類型以及相關聯的連結服務。 目前僅支援 REST。 不過,後續也會推出 SQL 預存程序和其他連結服務類型。 如需設定屬性的說明,請參閱 REST 來源組態

對應

您可以選擇自動對應,將所有輸入資料行傳遞至端點。 您也可以選擇手動設定資料行,並重新命名傳送至目標端點的資料行。

輸出

您將於此定義外部呼叫輸出的資料結構。 您可以定義本文的結構,以及選擇如何儲存標頭和從外部呼叫傳回的狀態。

如果您選擇儲存本文、標頭和狀態,請先為每行選擇資料行名稱,以便下游資料轉換時取用這些名稱。

您可以使用 ADF 資料流程語法,手動定義本文資料結構。 若要定義本文資料行名稱和資料類型,請按一下「匯入投影」,並允許 ADF 偵測外部呼叫的結構描述輸出。 以下是做為從天氣 REST API GET 呼叫輸出的範例結構描述定義結構:

({@context} as string[],
		geometry as (coordinates as string[][][],
		type as string),
		properties as (elevation as (unitCode as string,
		value as string),
		forecastGenerator as string,
		generatedAt as string,
		periods as (detailedForecast as string, endTime as string, icon as string, isDaytime as string, name as string, number as string, shortForecast as string, startTime as string, temperature as string, temperatureTrend as string, temperatureUnit as string, windDirection as string, windSpeed as string)[],
		units as string,
		updateTime as string,
		updated as string,
		validTimes as string),
		type as string)

範例

包含資料流程指令碼的範例

External call sample

source(output(
		id as string
	),
	allowSchemaDrift: true,
	validateSchema: false,
	ignoreNoFilesFound: false) ~> source1
Filter1 call(mapColumn(
		id
	),
	skipDuplicateMapInputs: false,
	skipDuplicateMapOutputs: false,
	output(
		headers as [string,string],
		body as (name as string)
	),
	allowSchemaDrift: true,
	store: 'restservice',
	format: 'rest',
	timeout: 30,
	httpMethod: 'POST',
	entity: 'api/Todo/',
	requestFormat: ['type' -> 'json'],
	responseFormat: ['type' -> 'json', 'documentForm' -> 'documentPerLine']) ~> ExternalCall1
source1 filter(toInteger(id)==1) ~> Filter1
ExternalCall1 sink(allowSchemaDrift: true,
	validateSchema: false,
	skipDuplicateMapInputs: true,
	skipDuplicateMapOutputs: true,
	store: 'cache',
	format: 'inline',
	output: false,
	saveOrder: 1) ~> sink1

資料流程指令碼

ExternalCall1 sink(allowSchemaDrift: true,
	validateSchema: false,
	skipDuplicateMapInputs: true,
	skipDuplicateMapOutputs: true,
	store: 'cache',
	format: 'inline',
	output: false,
	saveOrder: 1) ~> sink1