Microsoft網狀架構資料管線公用 REST API (預覽)
重要
適用於 Data Factory 的Microsoft網狀架構 API 目前為公開預覽狀態。 這項資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不提供任何明確或隱含的瑕疵擔保。
在 Microsoft Fabric 中,Data Factory API 只包含管線和資料流的 CRUD 作業。 目前,僅支援資料管線。 資料流 API 將於稍後發行。 資料整合專案的其他常見區域位於不同的 API 中:排程、監視、連線,在 Fabric 中有自己的 API。 Microsoft網狀架構 REST API 參考中找到 Microsoft網狀架構 REST API 的主要在線參考檔。 另請參閱 核心專案 API 和 作業排程器。
掛接公用 API
掛接公用 API 現已可供使用。 這些 API 可讓您順暢地整合及存取資料管線內的各種公用數據源。
取得授權權杖
選項 1:使用 MSAL.Net
網狀架構 API 快速入門 - Microsoft Fabric REST API
使用 MSAL.Net,以下列範圍取得 Fabric 服務的 Microsoft Entra ID 令牌:Workspace.ReadWrite.All、Item.ReadWrite.All。 如需使用 MSAL.Net 取得令牌的詳細資訊,請參閱 令牌擷取 - Microsoft適用於 .NET 的驗證連結庫。
貼上您稍早複製的應用程式 (用戶端) 識別碼,並貼上 ClientId 變數的應用程式識別碼。
選項 2:使用網狀架構入口網站
登入您要測試之租使用者的 Fabric 入口網站,然後按 F12 以進入瀏覽器的開發人員模式。 在控制台中,執行:
powerBIAccessToken
複製令牌並貼上 ClientId 變數。
以承載base64編碼的項目定義
- 使用 Base64編碼和譯碼 來編碼 JSON。
- 確定未核取 [ 執行 URL 安全編碼 ] 方塊。
- 您可以透過檢視來取得管線定義 -->在 Fabric 使用者介面中檢視 JSON 程式碼索引標籤。
{
"name": "Pipeline_1_updated",
"objectId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"properties": {
"description": "this is the description",
"activities": [
{
"name": "Wait1",
"type": "Wait",
"dependsOn": [],
"typeProperties": {
"waitTimeInSeconds": 240
}
}
],
"annotations": [],
"lastModifiedByObjectId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"lastPublishTime": "2024-02-01T17:28:02Z"
}
}
取得屬性物件,並以大括弧 - { } 括住它們,因此 REST 專案定義承載會是:
{
"properties": {
"description": "this is the description",
"activities": [
{
"name": "Wait1",
"type": "Wait",
"dependsOn": [],
"typeProperties": {
"waitTimeInSeconds": 240
}
}
],
"annotations": [],
"lastModifiedByObjectId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"lastPublishTime": "2024-02-01T17:28:02Z"
}
}
建立項目
範例 1 - CreateDataPipeline:
POST https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items
本文:
{
"displayName": "pipeline_1",
"type": "DataPipeline"
}
注意
檔指出只有 2 個必要屬性 - displayName 和 type。 目前,Workload-DI 也不支持在沒有定義的情況下建立。 目前正在部署此錯誤需求的修正程式。 現在,您可以傳送 Fabric 使用者介面所使用的相同預設定義: ‘{"properties":{"activities":[]}}’
修改的 JSON,包括定義:
{
"displayName": "pipeline_1",
"type": "DataPipeline",
"definition": {
"parts": [
{
"path": "pipeline-content.json",
"payload": "eyJwcm9wZXJ0aWVzIjp7ImFjdGl2aXRpZXMiOltdfX0=",
"payloadType": "InlineBase64"
}
]
}
}
回應 201:
{
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"type": "DataPipeline",
"displayName": "Pipeline_1",
"description": "",
"workspaceId": "<Your WS Id>"
}
範例 2 – 建立 MountedDataFactory
POST https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items
本文:
承載:
{"DataFactoryResourceId":"/subscriptions/<ADF subscription Id>/resourceGroups/<ADF resource group name>/providers/Microsoft.DataFactory/factories/<ADF datafactory name>"}
編碼的 JSON:
{
"displayName": "pipeline_mdf",
"type": " MountedDataFactory ",
"definition": {
"parts": [
{
"path": "mountedDataFactory-content.json",
"payload": <base64 encoded value>,
"payloadType": "InlineBase64"
}
]
}
}
回應 201:
{
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"type": "MountedDataFactory",
"displayName": "Pipeline_mdf",
"description": "",
"workspaceId": "<Your WS Id>"
}
刪除項目
範例:
DELETE https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items/<pipeline id>
回應 200:(沒有本文)
取得項目
範例:
GET https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items/<pipeline id>
回應 200:
{
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"type": "DataPipeline",
"displayName": "Pipeline_1",
"workspaceId": "<your WS Id>"
}
取得項目定義
範例:
POST https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items/<pipeline id>/getDefinition
回應 200:
{
"definition": {
"parts":[
{
"path": "pipeline-content.json",
"payload": "ewogICJwcm9wZXJ0aWVzIjogewogICAgImFjdGl2aXRpZXMiOiBbXQogIH0KfQ==",
"payloadType": "InlineBase64"
}
]
}
}
列出 項目
範例:
GET https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items
回應 200:
{
"value": [
{
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"type": "SemanticModel",
"displayName": "deata_lh",
"description": "",
"workspaceId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
},
{
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"type": "SQLEndpoint",
"displayName": "deata_lh",
"description": "",
"workspaceId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
},
{
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"type": "Lakehouse",
"displayName": "deata_lh",
"description": "",
"workspaceId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
},
{
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"type": "DataPipeline",
"displayName": "Pipeline_1",
"description": "",
"workspaceId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
]
}
更新項目
範例:
PATCH https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items/<pipeline id>
本文:
{
"displayName": "Pipeline_1_updated",
"description": "This is the description."
}
回應 200:
{
"id": "<pipeline id>",
"type": "DataPipeline",
"displayName": "Pipeline_1_updated",
"description": "This is the description.",
"workspaceId": "<Your WS id>"
}
更新項目定義
範例:
POST https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items/<pipeline id>/updateDefinition
本文:
{
"definition": {
"parts": [
{
"path": "pipeline-content.json",
"payload": "eyJwcm9wZXJ0aWVzIjp7ImFjdGl2aXRpZXMiOltdfX0=",
"payloadType": "InlineBase64"
}
]
}
}
回應 200:(沒有本文)
執行隨選項目作業
範例:
POST https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items/<pipeline id>/jobs/instances?jobType=Pipeline
回應 202:(沒有本文)
具有兩個參數值的範例:
在這裡,我們有名為 param_waitsec 參數的 Wait 活動,可指定要等候的秒數。
POST https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items/<pipeline id>/jobs/instances?jobType=Pipeline
本文:
{
"executionData": {
"parameters": {
"param_waitsec": "10"
}
}
}
回應 202:(沒有本文)
注意
目前沒有傳回主體,但應該傳回作業標識符。 在預覽期間,可以在傳回的標頭中,在 『Location』 屬性中找到。
取得項目工作執行個體
範例:
GET https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items/<pipeline id>/jobs/instances/<job ID>
回應 200:
{
"id": "4511ffcd-a9f6-4f75-91a9-9ceab08d7539",
"itemId": "2bb9fe4a-0a84-4725-a01f-7ac4e6850259",
"jobType": "Pipeline",
"invokeType": "Manual",
"status": "Completed",
"failureReason": null,
"rootActivityId": "f14bdd95-2cff-4451-b839-bea81509126d",
"startTimeUtc": "2024-02-01T03:03:19.8361605",
"endTimeUtc": "2024-02-01T03:05:00.3433333"
}
取消項目工作執行個體
範例:
POST https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items/<pipeline id>/jobs/instances/<job ID>/cancel
回應 202:(沒有本文)
注意
取消作業之後,您可以呼叫 Get 專案作業實例 或查看 Fabric 使用者介面中的檢視執行歷程記錄 來檢查狀態。
查詢活動執行
範例:
POST https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/datapipelines/pipelineruns/<job id>/queryactivityruns
本文:
{
"filters":[],
"orderBy":[{"orderBy":"ActivityRunStart","order":"DESC"}],
"lastUpdatedAfter":"2024-05-22T14:02:04.1423888Z",
"lastUpdatedBefore":"2024-05-24T13:21:27.738Z"
}
注意
「作業標識碼」是建立並用於作業排程器公用 API 中的相同識別碼
回應 200:
[
{
"pipelineName": "ca91f97e-5bdd-4fe1-b39a-1f134f26a701",
"pipelineRunId": "bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f",
"activityName": "Wait1",
"activityType": "Wait",
"activityRunId": "cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a",
"linkedServiceName": "",
"status": "Succeeded",
"activityRunStart": "2024-05-23T13:43:03.6397566Z",
"activityRunEnd": "2024-05-23T13:43:31.3906179Z",
"durationInMs": 27750,
"input": {
"waitTimeInSeconds": 27
},
"output": {},
"error": {
"errorCode": "",
"message": "",
"failureType": "",
"target": "Wait1",
"details": ""
},
"retryAttempt": null,
"iterationHash": "",
"userProperties": {},
"recoveryStatus": "None",
"integrationRuntimeNames": null,
"executionDetails": null,
"id": "/SUBSCRIPTIONS/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/RESOURCEGROUPS/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/PROVIDERS/MICROSOFT.TRIDENT/WORKSPACES/aaaa0a0a-bb1b-cc2c-dd3d-eeeeee4e4e4e/pipelineruns/bbbb1b1b-cc2c-dd3d-ee4e-ffffff5f5f5f/activityruns/cccc2c2c-dd3d-ee4e-ff5f-aaaaaa6a6a6a"
}
]
已知的限制
- 目前不支援服務主體驗證(SPN)。