使用ARM模板创建VSTS帐户时安装扩展

时间:2018-07-11 14:43:51

标签: azure-devops arm-template azure-devops-extensions

我正在使用Powershell和ARM模板来创建新的Team Services帐户+ DevOps项目。模板类型:microsoft.visualstudio/account

是否可以通过模板或Powershell安装extensions

我一直在使用几个扩展,自动将它们启动并在新项目上运行会很好。

2 个答案:

答案 0 :(得分:1)

那是一个有趣的问题,如果可能的话,它应该模仿this rest call

这很可能是手臂模板无法做到的。鉴于这在文档中未得到引用,并且模板说"operation": "link"我认为没有办法。

答案 1 :(得分:1)

如果有人偶然发现了相同的问题,那么可以使用Powershell做到这一点。
创建VSTS帐户后,您需要登录并在选定范围内使用扩展(读取和管理)创建个人访问令牌。

$accountName = "yourAccount"
$personalAccessToken = "your-personal-access-token"

$uri = "https://" + $accountName + ".extmgmt.visualstudio.com/_apis/extensionmanagement/installedextensionsbyname/ms-appinsights/appinsightsreleaseannotations?api-version=5.0-preview.1"

Write-Host "Installing extension: Release Annotations for Azure Application Insights"
Invoke-RestMethod `
-Method Post `
-Uri $uri `
-ContentType application/json `
-Headers @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($personalAccessToken)")) }