共用方式為


Git - Connect

將特定工作區連線至 Git 存放庫和分支。
此作業不會在工作區與連線的分支之間進行同步處理。 若要完成同步處理,請使用 初始化連線 作業,並遵循 認可至 Git從 Git 更新 作業。

若要開始使用 GitHub,請參閱: 開始使用 Git 整合

若要取得連線標識碼,請參閱 自動化 Git 整合

權限

呼叫端必須具有工作區的 管理員 角色。

針對已設定的連接 Git 認證,呼叫端必須具有連線的許可權。

必要的委派範圍

Workspace.ReadWrite.All

局限性

使用自動認證來源時,會針對 GitHub 提供者和服務主體封鎖此 API。

Microsoft Entra 支援的身分識別

此 API 支援本節中列出的Microsoft 身分識別

身份 支援
使用者 是的
服務主體受控識別 只有在 myGitCredentials.source 為 ConfiguredConnection 時才支援

介面

POST https://api.fabric.microsoft.com/v1/workspaces/{workspaceId}/git/connect

URI 參數

名稱 位於 必要 類型 Description
workspaceId
path True

string (uuid)

工作區標識碼。

要求本文

名稱 必要 類型 Description
gitProviderDetails True GitProviderDetails:

Git 提供者詳細數據。

myGitCredentials GitCredentials:

使用者特定的 Git 認證,用於向 GitProvider 進行驗證。 這些認證不會與其他工作區參與者共用。 若為 GitHub,則需要此屬性。 針對 AzureDevOps,此屬性是選擇性的。 如果未設定,預設值為 AutomaticGitCredentials。

回應

名稱 類型 Description
200 OK

要求成功完成。

Other Status Codes

ErrorResponse

常見的錯誤碼:

  • UnknownError - 發生錯誤。

  • WorkspaceAlreadyConnectedToGit - 工作區已連線到 git。

  • WorkspaceHasNoCapacityAssigned - 沒有指派給工作區的容量。

  • InsufficientPrivileges - 呼叫者沒有足夠的工作區許可權。

  • PrincipalTypeNotSupported - 不支援呼叫端身分識別類型。

範例

Connect a workspace to Azure DevOps example
Connect a workspace to Azure DevOps using configured connection example
Connect a workspace to GitHub example

Connect a workspace to Azure DevOps example

範例要求

POST https://api.fabric.microsoft.com/v1/workspaces/1565e6a3-c020-4c0c-dda7-92bafe99eec5/git/connect

{
  "gitProviderDetails": {
    "organizationName": "Test Organization",
    "projectName": "Test Project",
    "gitProviderType": "AzureDevOps",
    "repositoryName": "Test Repo",
    "branchName": "Test Branch",
    "directoryName": "Test Directory"
  }
}

範例回覆

Connect a workspace to Azure DevOps using configured connection example

範例要求

POST https://api.fabric.microsoft.com/v1/workspaces/1565e6a3-c020-4c0c-dda7-92bafe99eec5/git/connect

{
  "gitProviderDetails": {
    "organizationName": "Test Organization",
    "projectName": "Test Project",
    "gitProviderType": "AzureDevOps",
    "repositoryName": "Test Repo",
    "branchName": "Test Branch",
    "directoryName": "Test Directory/Test Subdirectory"
  },
  "myGitCredentials": {
    "source": "ConfiguredConnection",
    "connectionId": "3f2504e0-4f89-11d3-9a0c-0305e82c3301"
  }
}

範例回覆

Connect a workspace to GitHub example

範例要求

POST https://api.fabric.microsoft.com/v1/workspaces/1565e6a3-c020-4c0c-dda7-92bafe99eec5/git/connect

{
  "gitProviderDetails": {
    "ownerName": "Test Owner",
    "gitProviderType": "GitHub",
    "repositoryName": "Test Repo",
    "branchName": "Test Branch",
    "directoryName": "Test Directory/Test Subdirectory"
  },
  "myGitCredentials": {
    "source": "ConfiguredConnection",
    "connectionId": "3f2504e0-4f89-11d3-9a0c-0305e82c3301"
  }
}

範例回覆

定義

名稱 Description
AutomaticGitCredentials

自動 Git 認證。

AzureDevOpsDetails

Azure DevOps 提供者詳細數據。

ConfiguredConnectionGitCredentials

已設定連線 Git 認證。

ErrorRelatedResource

錯誤相關的資源詳細資料物件。

ErrorResponse

錯誤回應。

ErrorResponseDetails

錯誤回應詳細數據。

GitConnectRequest

包含 Git connect 要求數據。

GitCredentialsSource

Git 認證來源。 可能會隨著時間新增其他 Git 認證來源。

GitHubDetails

GitHub 提供者詳細數據。

GitProviderType

Git 提供者類型。 可能會隨著時間新增其他提供者類型。

AutomaticGitCredentials

自動 Git 認證。

名稱 類型 Description
source string:

Automatic

Git 認證來源。

AzureDevOpsDetails

Azure DevOps 提供者詳細數據。

名稱 類型 Description
branchName

string

maxLength: 250

分支名稱。 長度上限為 250 個字元。

directoryName

string

maxLength: 256

目錄的相對路徑。 長度上限是 256 個字元。

gitProviderType string:

AzureDevOps

Git 提供者類型。 可能會隨著時間新增其他提供者類型。

organizationName

string

maxLength: 100

組織名稱。 長度上限為 100 個字元。

projectName

string

maxLength: 100

專案名稱。 長度上限為 100 個字元。

repositoryName

string

maxLength: 128

存放庫名稱。 長度上限是 128 個字元。

ConfiguredConnectionGitCredentials

已設定連線 Git 認證。

名稱 類型 Description
connectionId

string (uuid)

連接的物件識別碼。

source string:

ConfiguredConnection

Git 認證來源。

ErrorRelatedResource

錯誤相關的資源詳細資料物件。

名稱 類型 Description
resourceId

string

發生錯誤的資源識別碼。

resourceType

string

發生錯誤的資源類型。

ErrorResponse

錯誤回應。

名稱 類型 Description
errorCode

string

提供錯誤狀況相關信息的特定標識碼,允許服務與其使用者之間的標準化通訊。

message

string

錯誤的人類可讀取表示法。

moreDetails

ErrorResponseDetails[]

其他錯誤詳細數據的清單。

relatedResource

ErrorRelatedResource

錯誤相關的資源詳細數據。

requestId

string

與錯誤相關聯的要求標識碼。

ErrorResponseDetails

錯誤回應詳細數據。

名稱 類型 Description
errorCode

string

提供錯誤狀況相關信息的特定標識碼,允許服務與其使用者之間的標準化通訊。

message

string

錯誤的人類可讀取表示法。

relatedResource

ErrorRelatedResource

錯誤相關的資源詳細數據。

GitConnectRequest

包含 Git connect 要求數據。

名稱 類型 Description
gitProviderDetails GitProviderDetails:

Git 提供者詳細數據。

myGitCredentials GitCredentials:

使用者特定的 Git 認證,用於向 GitProvider 進行驗證。 這些認證不會與其他工作區參與者共用。 若為 GitHub,則需要此屬性。 針對 AzureDevOps,此屬性是選擇性的。 如果未設定,預設值為 AutomaticGitCredentials。

GitCredentialsSource

Git 認證來源。 可能會隨著時間新增其他 Git 認證來源。

Description
ConfiguredConnection

Git 認證是透過設定的連線取得。

Automatic

系統會自動取得 Git 認證,如果有的話,請使用預設認證。

None

未設定 Git 認證。

GitHubDetails

GitHub 提供者詳細數據。

名稱 類型 Description
branchName

string

maxLength: 250

分支名稱。 長度上限為 250 個字元。

directoryName

string

maxLength: 256

目錄的相對路徑。 長度上限是 256 個字元。

gitProviderType string:

GitHub

Git 提供者類型。 可能會隨著時間新增其他提供者類型。

ownerName

string

maxLength: 100

擁有者名稱。 長度上限為 100 個字元。

repositoryName

string

maxLength: 128

存放庫名稱。 長度上限是 128 個字元。

GitProviderType

Git 提供者類型。 可能會隨著時間新增其他提供者類型。

Description
AzureDevOps

Azure DevOps 提供者

GitHub

GitHub 提供者