共用方式為


Microsoft Fabric 數據管線公用 REST API (預覽)

重要

適用於 Data Factory 建立/讀取/更新/刪除的 Microsoft Fabric API 目前為預覽狀態。 這項資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不提供任何明確或隱含的瑕疵擔保。

在 Microsoft Fabric 中,Data Factory API 只包含管線和數據流的 CRUD 作業。 目前僅支持數據管線。 數據流 API 將於稍後發行。 數據整合專案的其他常見區域位於不同的 API 中:排程、監視、連線,在 Fabric 中有自己的 API。 您可以在 Microsoft Fabric REST API 參考中找到 Microsoft Fabric REST API 的主要在線參考檔。 另請參閱 核心專案 API作業排程器

取得授權令牌

選項 1:使用 MSAL.Net

網狀架構 API 快速入門 - Microsoft Fabric REST API

使用 MSAL.Net 取得 Microsoft Entra ID Token for Fabric 服務,其範圍如下:Workspace.ReadWrite.All、Item.ReadWrite.All。 如需使用 MSAL.Net 取得令牌的詳細資訊,請參閱 令牌擷取 - 適用於 .NET 的 Microsoft 驗證連結庫。

貼上您稍早複製的應用程式(用戶端)標識符,並貼上 ClientId 變數的應用程式識別碼。

選項 2:使用網狀架構入口網站

登入您要測試之租使用者的 Fabric 入口網站,然後按 F12 以進入瀏覽器的開發人員模式。 在控制台中,執行:

powerBIAccessToken

複製令牌並貼上 ClientId 變數。

以承載base64編碼的項目定義

  • 使用 Base64編碼和譯碼 來編碼 JSON。
  • 確定未核取 [ 執行 URL 安全編碼 ] 方塊。
  • 您可以透過 Fabric 使用者介面中的 [檢視 ] -->View 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" 
    } 
} 

建立項目

REST API - 專案 - 建立專案

範例:

POST https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items

本文:

{ 
  "displayName": "pipeline_1", 
  "type": "DataPipeline" 
} 

注意

檔指出只有 2 個必要屬性 - displayNametype。 目前,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>" 
} 

刪除項目

REST API - 專案 - 刪除專案

範例:

DELETE https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items/<pipeline id>

回應 200:(沒有本文)

取得專案

REST API - 專案 - 取得專案

範例:

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>" 
} 

取得項目定義

REST API - 專案 - 取得項目定義

範例:

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" 
            } 
        ] 
    } 
} 

列出 項目

REST API - 專案 - 列表專案

範例:

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" 
        } 
    ] 
} 

更新項目

REST API - 專案 - 更新專案

範例:

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>" 
}

更新項目定義

REST API - 專案 - 更新項目定義

範例:

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:(沒有本文)

執行隨選項目作業

REST API - 專案 - 執行隨選項目作業

範例:

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』 屬性中找到。

取得專案作業實例

REST API - 專案 - 取得專案作業實例

範例:

GET https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items/<pipeline id>/jobs/instances/<job ID>dotnetcli

回應 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" 
} 

取消專案作業實例

REST API - 專案 - 取消專案作業實例

範例:

POST https://api.fabric.microsoft.com/v1/workspaces/<your WS Id>/items/<pipeline id>/jobs/instances/<job ID>/cancel

回應 202:(沒有本文)

注意

取消作業之後,您可以呼叫 Get 專案作業實例 或查看 Fabric 使用者介面中的檢視執行歷程記錄 來檢查狀態。

已知的限制

  • 不支援服務主體驗證 (SPN)

下一步