Creates a new Azure DevOps service endpoint (service connection).
New-AdoServiceEndpoint [[-CollectionUri] <string>] [-Configuration] <PSCustomObject>
[[-Version] <string>] [-WhatIf] [-Confirm] [<CommonParameters>]
This cmdlet has the following aliases,
- N/A
This function creates a new service endpoint (service connection) in an Azure DevOps project. The endpoint is created using a configuration object that defines the endpoint type, authorization, and project references. If a service endpoint with the same name already exists, the cmdlet retrieves and returns the existing endpoint.
$config = [PSCustomObject]@{
data = [PSCustomObject]@{
creationMode = 'Manual'
environment = 'AzureCloud'
scopeLevel = 'Subscription'
subscriptionId = '00000000-0000-0000-0000-000000000000'
subscriptionName = 'my-subscription-1'
}
name = 'MyAzureConnection'
type = 'AzureRM'
url = 'https://management.azure.com/'
authorization = [PSCustomObject]@{
parameters = [PSCustomObject]@{
serviceprincipalid = '11111111-1111-1111-1111-111111111111'
tenantid = '22222222-2222-2222-2222-222222222222'
scope = '/subscriptions/00000000-0000-0000-0000-000000000000'
}
scheme = 'WorkloadIdentityFederation'
}
isShared = $false
serviceEndpointProjectReferences = [PSCustomObject[]]@(
[PSCustomObject]@{
name = 'MyAzureConnection'
projectReference = [PSCustomObject]@{
id = '33333333-3333-3333-3333-333333333333'
name = 'my-project-1'
}
}
)
}
$params = @{
CollectionUri = 'https://dev.azure.com/myorg'
Configuration = $config
}
New-AdoServiceEndpoint @paramsCreates a new Azure Resource Manager service endpoint with Workload Identity Federation authentication.
$config = [PSCustomObject]@{
name = 'MyGitHubConnection'
type = 'GitHub'
url = 'https://github.com'
authorization = [PSCustomObject]@{
parameters = [PSCustomObject]@{
accessToken = 'ghp_token'
}
scheme = 'Token'
}
isShared = $false
serviceEndpointProjectReferences = [PSCustomObject[]]@(
[PSCustomObject]@{
name = 'MyGitHubConnection'
projectReference = [PSCustomObject]@{
id = '33333333-3333-3333-3333-333333333333'
name = 'my-project-1'
}
}
)
}
New-AdoServiceEndpoint -Configuration $configCreates a new GitHub service endpoint using a personal access token.
Optional. The URI of the Azure DevOps collection or Azure DevOps Server. If not provided, it uses the default collection URI from $env:DefaultAdoCollectionUri.
Type: System.String
DefaultValue: $env:DefaultAdoCollectionUri
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 0
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''Mandatory. The service endpoint configuration object containing endpoint details, authorization, and project references.
Type: System.Management.Automation.PSCustomObject
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: 1
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''Optional. The API version to use. Defaults to '7.1'.
Type: System.String
DefaultValue: 7.1
SupportsWildcards: false
Aliases:
- ApiVersion
- Api
ParameterSets:
- Name: (All)
Position: 2
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues:
- 7.1
- 7.2-preview.4
HelpMessage: ''This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
- N/A
- The cmdlet extracts the project name from Configuration.serviceEndpointProjectReferences[0].projectReference.name.
- If a service endpoint with the same name already exists, the cmdlet returns the existing endpoint with a warning.
- The API call is made to the organization level endpoint (without project in the URI path).
- Supports ShouldProcess for WhatIf and Confirm parameters (high impact).
- Requires authentication to Azure DevOps. Use
Set-AdoDefaultto configure default organization and project values. - The cmdlet automatically retrieves authentication through
Invoke-AdoRestMethodwhich callsNew-AdoAuthHeader.