I am attempting to create a service endpoint through the Azure DevOps Rest API but cannot set the "Allow all pipelines to use this service connection" option. I cannot find documentation on the json structure to accomplish this.
Current snippet for creating the connection:
$baseUri = "https://dev.azure.com/org/proj/";
$createEndpointUri = "$($baseUri)_apis/serviceendpoint/endpoints?api-version=5.0-preview.2";
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("token:{0}" -f $devOpsPAT)))
$DevOpsHeaders = @{Authorization = ("Basic {0}" -f $base64AuthInfo)};
$AzureSubscriptionData = New-Object PSObject -Property @{
authorizationType = "AzureSubscription"
azureSubscriptionId = $SubscriptionId
azureSubscriptionName = $subscriptionName
clusterId = $clusterId
};
$Authorization = New-Object PSObject -Property @{
parameters = New-Object PSObject -Property @{
azureEnvironment = "AzureCloud"
azureTenantId = "$tenantID"
};
scheme = "Kubernetes"
};
$ServiceEndpointBody = New-Object PSObject -Property @{
authorization =$Authorization
data = $AzureSubscriptionData
name = $serviceConnectionName
type = "kubernetes"
url = $k8sUrl
isReady = "true"
};
$jsonbody = $ServiceEndpointBody | ConvertTo-Json -Depth 100
Invoke-RestMethod -UseBasicParsing -Uri $createEndpointUri -Method Post -ContentType "application/json" -Headers $DevOpsHeaders -Body $jsonbody;