Skip to content

AzDoGitRepository

Michael Zanatta edited this page Aug 18, 2026 · 4 revisions

DSC AzDoGitRepository Resource

Syntax

AzDoGitRepository [string] #ResourceName
{
    ProjectName          = [String]$ProjectName
    RepositoryName       = [String]$RepositoryName
    [ SourceRepository   = [String]$SourceRepository ]
    [ Ensure             = [String] {'Present', 'Absent'} ]
}

Properties

Common Properties

Permission Usage

Not applicable for this resource.

Permission List

Not applicable for this resource.

Common Properties

  • Ensure: Specifies whether the repository should exist. Defaults to 'Present'.
  • ProjectName: The name of the Azure DevOps project.
  • RepositoryName: The name of the Git repository within the project.
  • SourceRepository: (Optional) The source repository from which to create the new repository.

Additional Information

This resource manages Git repositories in Azure DevOps projects using Desired State Configuration (DSC). It supports creating repositories from scratch or initializing them from a source/template repository.

Examples

Example 1: Sample Configuration using AzDoGitRepository Resource

Configuration ExampleConfig {
    Import-DscResource -ModuleName 'AzureDevOpsDscNative'

    Node localhost {
        AzDoGitRepository AddGitRepository {
            Ensure           = 'Present'
            ProjectName      = 'MyProject'
            RepositoryName   = 'MyRepository'
            SourceRepository = 'TemplateRepository'
        }
    }
}

Start-DscConfiguration -Path ./ExampleConfig -Wait -Verbose

Example 2: Sample Configuration using Invoke-DSCResource

# Return the current configuration for AzDoGitRepository
$properties = @{
    ProjectName    = 'MyProject'
    RepositoryName = 'MyRepository'
}

Invoke-DscResource -Name 'AzDoGitRepository' -Method Get -Property $properties -ModuleName 'AzureDevOpsDscNative'

Example 3: Sample Configuration using AzDO-DSC-LCM

parameters: {}

variables: {
  ProjectName: MyProject,
  RepositoryName: MyRepository
}

resources:
- name: My Git Repository
  type: AzureDevOpsDscNative/AzDoGitRepository
  dependsOn:
    - AzureDevOpsDscNative/AzDoProject/MyProject
  properties:
    ProjectName: $ProjectName
    RepositoryName: $RepositoryName
    SourceRepository: TemplateRepository
    Ensure: Present

LCM Initialization:

$params = @{
    AzureDevopsOrganizationName = "SampleAzDoOrgName"
    ConfigurationDirectory      = "C:\Datum\DSCOutput\"
    ConfigurationUrl            = 'https://configuration-path'
    JITToken                    = 'SampleJITToken'
    Mode                        = 'Set'
    AuthenticationType          = 'ManagedIdentity'
    ReportPath                  = 'C:\Datum\DSCOutput\Reports'
}

Invoke-AzDoLCM @params

Commands

Resources

Clone this wiki locally