我想知道是否可以编写PowerShell来创建Azure DevOps服务连接终结点。
我想通过访问Azure DevOps限制所有人创建服务连接终结点的权限,我们需要创建多个服务连接终结点,包括UnitTesting工具,Build工具,Automation测试工具以及docker事物的连接终结点。
我可以使用PowerShell(Invoke-RestMethod <uri> -Method get -Header <myheader>
通过Azure DevOps Rest API读取已创建的Azure DevOps服务连接终结点,但是我想知道是否可以通过传递服务使用相同的Rest API创建新的服务连接终结点端点信息作为Rest API(Invoke-RestMethod
)的主体。
这是我如何获取现有服务连接端点的方法:
##Invoke-RestMethod $url -Method GET -Headers $headers -ContentType
'application/json' -Verbose
##I refer below code as Example to code to update existing work item,
this is working but for service connection endpoint, I'm having no clue:
$workitem = Invoke-RestMethod -Uri $wisUrl -Method Get -ContentType
"application/json" -Headers $header
Write-Host "Before: $($workitem.fields.'System.Title')"
$body = @"
[
{
"op": "add",
"path": "/fields/System.Title",
"value": "$($workitem.fields.'System.Title')+DEMO"
},
{
"op": "add",
"path": "/fields/System.History",
"value": "Changing Title"
}
]
"@
$workitem = Invoke-RestMethod -Uri $wisUrl -Method Patch -ContentType
"application/json-patch+json" -Headers $header -Body $body
Write-Host "After: $($workitem.fields.'System.Title')"
答案 0 :(得分:0)
Endpoints - Create Rest API是可能的:
POST https://dev.azure.com/{organization}/{project}/_apis/serviceendpoint/endpoints?api-version=5.1-preview.2
例如请求正文(对于Azure终结点):
{
"data": {
"SubscriptionId": "21312421-4123-1323-3123-12534543",
"SubscriptionName: "TestSub"
},
"id": "2e344hjds-23ds-242fs-42ds-dsfsdaf34s",
"name": "TestEndpoint",
"type": "Azure",
"authorization": {
"parameters": {
"Certificate": "dummyCertificate"
},
"scheme": "Certificate"
},
"isReady": false
}