San*_*eev 1 azure-devops azure-pipelines
鉴于 azure 应用程序服务设置是在 azure 门户中完成的,并且除了服务连接之外,还设置了 azure devops 管道。有没有办法使用基于 Arm 模板的基础设施 yaml 管道来自动创建服务连接?我们想要运行此管道并更新用户 yaml 管道中的服务连接。
有没有办法使用基于 Arm 模板的基础设施 yaml 管道来自动创建服务连接?
ARM模板用于部署azure服务。到目前为止,它还不能用于在 azure devops 中创建服务连接。
根据您的情况,我认为您可以考虑通过使用Powershell任务和以下脚本来使用REST API :
$token = "{PAT token}"
$url="https://dev.azure.com/{org name}/{project name}/_apis/serviceendpoint/endpoints?api-version=5.1-preview.2"
$token = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($token)"))
$body = @"
{
"authorization": {
"parameters": {
"tenantid": "{tenant id}",
"serviceprincipalid": "{principal id}",
"authenticationType": "spnKey",
"serviceprincipalkey": "{principal key}"
},
"scheme": "ServicePrincipal"
},
"data": {
"subscriptionId": "{subscription id}",
"subscriptionName": "{subscription name}",
"environment": "AzureCloud",
"scopeLevel": "Subscription"
},
"name": "{service connection name}",
"type": "azurerm",
"url": "https://management.azure.com/"
}
"@
$response = Invoke-RestMethod -Uri $url -Headers @{Authorization = "Basic $token"} -Method Post -Body $Body -ContentType application/json
Run Code Online (Sandbox Code Playgroud)
执行该任务后,您将看到相应的服务连接被创建。
| 归档时间: |
|
| 查看次数: |
1545 次 |
| 最近记录: |