Connect-FabricGit
Connects a Fabric workspace to a Git repository and branch.
Syntax
Connect-FabricGit -WorkspaceId <guid> -GitProviderType <string> -OrganizationName <string>
-ProjectName <string> -RepositoryName <string> -BranchName <string> [-DirectoryName <string>]
[-ConnectionId <guid>] [-Initialize] [-InitializationStrategy <string>] [-NoWait] [-WhatIf]
[-Confirm] [<CommonParameters>]Connect-FabricGit -WorkspaceId <guid> -GitProviderType <string> -OwnerName <string>
-RepositoryName <string> -BranchName <string> [-DirectoryName <string>] [-ConnectionId <guid>]
[-Initialize] [-InitializationStrategy <string>] [-NoWait] [-WhatIf] [-Confirm]
[<CommonParameters>]Description
Connects the specified workspace to an Azure DevOps or GitHub repository, branch and folder. After connecting, the connection must be initialized; use -Initialize to do this in the same call, or run Initialize-FabricGitConnection afterwards.
-GitProviderType is mandatory and must match the provider parameters supplied: AzureDevOps requires -OrganizationName and -ProjectName, GitHub requires -OwnerName and -ConnectionId.
Examples
Example 1
Connect-FabricGit -WorkspaceId '11111111-1111-1111-1111-111111111111' -GitProviderType AzureDevOps -OrganizationName 'contoso' -ProjectName 'Fabric' -RepositoryName 'sales' -BranchName 'main' -DirectoryName '/workspace' -Initialize -InitializationStrategy PreferRemoteConnects the workspace to an Azure DevOps repository and initializes the connection, preferring the content of the branch.
Example 2
Connect-FabricGit -WorkspaceId '11111111-1111-1111-1111-111111111111' -GitProviderType GitHub -OwnerName 'contoso' -RepositoryName 'sales' -BranchName 'main' -ConnectionId '22222222-2222-2222-2222-222222222222'Connects the workspace to a GitHub repository using the credentials stored in a configured connection.
Initialize-FabricGitConnection must be run afterwards.Parameters
| Name | Type | Req. | Pos. | Pipeline | Description |
|---|---|---|---|---|---|
| -BranchName | string | ✓Required | Named | – | The name of the branch in the repository to connect to. |
| -GitProviderType | string | ✓Required | Named | – | The Git provider: AzureDevOps or GitHub. |
| -OrganizationName | string | ✓Required | Named | – | Azure DevOps only. The Azure DevOps organization name. |
| -OwnerName | string | ✓Required | Named | – | GitHub only. The owner (user or organization) of the GitHub repository. |
| -ProjectName | string | ✓Required | Named | – | Azure DevOps only. The Azure DevOps project name. |
| -RepositoryName | string | ✓Required | Named | – | The name of the Git repository to connect to. |
| -WorkspaceIdalias: Id | guid | ✓Required | Named | By name | The ID of the workspace to connect. Accepts pipeline input by property name (alias Id). |
| -Confirmalias: cf | switch | Named | – | Prompts you for confirmation before running the cmdlet. |
|
| -ConnectionId | guid | Named | – | The ID of a configured Fabric connection holding the Git credentials. When supplied, the credentials source is 'ConfiguredConnection'; otherwise 'Automatic' (Azure DevOps with the signed-in user's identity). Required for GitHub. |
|
| -DirectoryName | string | Named | – | The folder in the repository that holds the workspace content. Defaults to '/'. Default: / |
|
| -InitializationStrategy | string | Named | – | Used with -Initialize. None (default), PreferRemote or PreferWorkspace. Default: None |
|
| -Initialize | switch | Named | – | Also initializes the Git connection after connecting (see Initialize-FabricGitConnection). Default: False |
|
| -NoWait | switch | Named | – | Used with -Initialize. Returns the long-running operation details instead of waiting. Default: False |
|
| -WhatIfalias: wi | switch | Named | – | Runs the command in a mode that only reports what would happen without performing the actions. |
This cmdlet also supports the common parameters, such as -Verbose and -ErrorAction. See about_CommonParameters.
Inputs
System.Guid
{{ Fill in the Description }}
Outputs
System.Management.Automation.PSCustomObject
Nothing without -Initialize. With -Initialize
{{ Fill in the Description }}
System.Management.Automation.PSCustomObject
{{ Fill in the Description }}
Notes
https://learn.microsoft.com/en-us/rest/api/fabric/core/git/connect
Requires the workspace Admin role. Service principals require -ConnectionId.
Author: Kamil Nowinski