为什么 Azure REST API 无法将用户角色分配给订阅?
Why doesn't Azure REST API to assign user role to a subscription work?
我正在尝试使用 REST API 将用户角色添加到 Azure 中的订阅 documentation。
- 我通过登录获得了不记名令牌,并将其作为 header 授权参数传递。
- 给出文档中描述的所有值
- PFA REST API 我进行了通话。
API 回复如下;
{
"error": {
"code": "AuthenticationFailed",
"message": "Authentication failed."
}
}
如果有人成功使用此 API 并执行操作,请告诉我。此操作是否还有任何 Azure .NET API?
REST API Postman request
该错误表示您的用户帐户没有创建角色分配的权限,特别是 Microsoft.Authorization/roleAssignments/write
。
要解决这个问题,你需要问管理员谁是Owner
或User Access Administrator
(或custom RBAC role with Microsoft.Authorization/roleAssignments/write
permission) of your subscription to assign the Owner
or User Access Administrator
or custom role with the permission above for you at the subscription scope first, follow this link,然后得到一个新的令牌,你就可以分配将角色分配给管理员等其他人将角色分配给您,即创建角色分配。
更新:
如果您想通过用户凭据获取访问令牌,可以使用auth code flow,请按照以下步骤操作。
1.In您的App注册,添加user_impersonation
授权Azure Service Management
API.
2.Hit浏览器下面的URL,把tenant-id
、client-id
、redirect_uri
改成你的,登录你的用户账号。
https://login.microsoftonline.com/tenant-id/oauth2/v2.0/authorize?
client_id=xxxxxxxx
&response_type=code
&redirect_uri=http://localhost
&response_mode=query
&scope=https://management.azure.com/.default
&state=12345
然后你会得到如下代码,复制它。
不要忘记删除状态和 session_state。
3.In邮递员,使用下面的查询,就可以拿到token了。
我正在尝试使用 REST API 将用户角色添加到 Azure 中的订阅 documentation。
- 我通过登录获得了不记名令牌,并将其作为 header 授权参数传递。
- 给出文档中描述的所有值
- PFA REST API 我进行了通话。
API 回复如下;
{
"error": {
"code": "AuthenticationFailed",
"message": "Authentication failed."
}
}
如果有人成功使用此 API 并执行操作,请告诉我。此操作是否还有任何 Azure .NET API?
REST API Postman request
该错误表示您的用户帐户没有创建角色分配的权限,特别是 Microsoft.Authorization/roleAssignments/write
。
要解决这个问题,你需要问管理员谁是Owner
或User Access Administrator
(或custom RBAC role with Microsoft.Authorization/roleAssignments/write
permission) of your subscription to assign the Owner
or User Access Administrator
or custom role with the permission above for you at the subscription scope first, follow this link,然后得到一个新的令牌,你就可以分配将角色分配给管理员等其他人将角色分配给您,即创建角色分配。
更新:
如果您想通过用户凭据获取访问令牌,可以使用auth code flow,请按照以下步骤操作。
1.In您的App注册,添加user_impersonation
授权Azure Service Management
API.
2.Hit浏览器下面的URL,把tenant-id
、client-id
、redirect_uri
改成你的,登录你的用户账号。
https://login.microsoftonline.com/tenant-id/oauth2/v2.0/authorize?
client_id=xxxxxxxx
&response_type=code
&redirect_uri=http://localhost
&response_mode=query
&scope=https://management.azure.com/.default
&state=12345
然后你会得到如下代码,复制它。
不要忘记删除状态和 session_state。
3.In邮递员,使用下面的查询,就可以拿到token了。