azure-logic-apps - Add an Azure AD user to a Azure DevOps project group using Azure Logic Apps
问题描述
I am trying to add an Azure AD user to an Azure DevOps project group using the Azure Logic Apps DevOps Connector, action Send an HTTP request to Azure DevOps but I receive status Unauthorized while with the same user I am able to do it manually in the portal. Because there is almost no documentation regarding this tool and APIs it's using, I guess it is something with the URI but not sure. Any ideas?
Thank you
解决方案
We could not add an Azure AD user to a Azure DevOps project group via Azure Logic Apps. This is an known issue in the action Send an HTTP request to Azure DevOps
We are using this REST API to add an AAD user as member of a group, it need the permission scope vso.graph_manage
And according to this doc Action Send an HTTP request to Azure DevOps has a limited set of scopes which control what resources can be accessed by the action and what operations the action is allowed to perform on those resources.
The Scopes contain:
- vso.agentpools_manage
- vso.build_execute
- vso.chat_manage
- vso.code_manage
- vso.code_status
- vso.connected_server
- vso.dashboards_manage
- vso.entitlements
- vso.extension.data_write
- vso.extension_manage
- vso.identity
- vso.loadtest_write
- vso.packaging_manage
- vso.project_manage
- vso.release_manage
- vso.test_write
- vso.work_write
Since it does not contain the scope vso.graph_manage
, and we could see the error message : TF400813: The user xxx is not authorized to access this resource
in the output content
Update1
Power shell script:
$connectionToken="{PAT}"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))
$URL = "https://vssps.dev.azure.com/{Org name}/_apis/graph/users?groupDescriptors={groupDescriptors}&api-version=6.0-preview.1"
$body =@"
{
"principalName": "{User email}"
}
"@
$Result = Invoke-RestMethod -Uri $URL -ContentType "application/json" -Body $body -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Method POST
推荐阅读
- flutter - 颤振摩尔查询过滤器与日期
- excel - 为什么我在复制/粘贴时收到此错误?
- python - 如何在 Windows Pycharm 上安装 faiss
- gremlin - Gremlin:获取按父顶点分组的顶点属性键
- python - 如何在大型数组中更快地生成随机点?
- xamarin - 有没有办法在 iOS 启动屏幕上添加一些动画或任何类型的移动效果?
- c - 如何在 trie 中搜索一个错误的字符串?
- c++ - 如何计算线性锥形变换矩阵
- docker - Docker compose/Swarm:使用 compose 文件的网络名称
- java - 错误:尝试在 Java 中格式化十进制输出时