在没有用户的DevOps Pat的情况下对Azure Devops进行身份验证
当前,我们使用一种方法来触及DevOps并通过使用用户的DevOps Pat触发特定VM1的“释放管道”。我们在下面的VM1上运行PowerShell命令:
$userPatToken = "xxxdfdgklfdgofkglfg4565gfhgfhgfh4gf54h54545fhfghfdffg"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f "", $userPatToken)))
$url = "https://vsrm.dev.azure.com/MyOrg/MyProject/_apis/release/releases?definitionId=7&$top=100&api-version=6.0"
Invoke-RestMethod -Method Get -Uri $url -ContentType "application/json" -Headers @{Authorization = ("Basic {0}" -f $base64AuthInfo) }
用户是AAD,有没有一种方法可以说是AAD凭据并进行身份验证以进行DevOps并执行同样的操作? 还是可以使用托管(或任何用户托管的)身份的VMS系统来验证DevOps并触发发布管道的方法?我们不想依赖用户的PAT。 它应该用Powershell编写。
Currently we use an approach to reach DevOps and trigger "release pipelines" from a specific VM1 by utilizing user's DevOps PAT. We run PowerShell commands below at VM1:
$userPatToken = "xxxdfdgklfdgofkglfg4565gfhgfhgfh4gf54h54545fhfghfdffg"
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f "", $userPatToken)))
$url = "https://vsrm.dev.azure.com/MyOrg/MyProject/_apis/release/releases?definitionId=7&$top=100&api-version=6.0"
Invoke-RestMethod -Method Get -Uri $url -ContentType "application/json" -Headers @{Authorization = ("Basic {0}" -f $base64AuthInfo) }
The user is AAD one, is there a way to use it's let say AAD credentials and authenticate to DevOps and do the same?
Or may there is a way to use VMs system managed (or any user managed) identity to authenticate into DevOps and trigger release pipelines? We do not want to be dependent of the user's PAT.
It should be written in PowerShell.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您不想使用PAT,则可以安装
az
powerShell模块,使用connect> connect> connect-azaccount在您的DevOps org中获得许可的用户帐户登录。
然后,您可以通过下面的命令获得令牌。请注意,不要更改脚本中的499B84AC-1321-427F-AA17-267CA6975798,它是DevOps Rest API的著名资源ID。
然后,您可以将令牌传递给您的PowerShell脚本。您可以找到更多详细信息/示例脚本在这里。
编辑:
添加用户名&密码自动化脚本示例:
If you don't want to use the PAT, you can install
Az
powershell module, login with a user account which has the permission in your devops org viaConnect-AzAccount
.Then, you can get the token via below command. Please note don't change the 499b84ac-1321-427f-aa17-267ca6975798 in the script, it is the well-known resource id of the DevOps REST API.
Then, you can pass the token to your powershell script. You can find more details/sample script here.
Edit:
Add username&Password automation script sample: