无法通过Azure运行书籍为用户分配的身份分配角色

发布于 2025-02-12 09:22:05 字数 488 浏览 1 评论 0原文

通过使用以下命令,尝试使用PowerShell Runbook(5.1运行时版本)为托管身份分配角色。

$roleAssignment = New-AzRoleAssignment -ObjectId 'xxxx-xxxx-xxxx-xxxx' -Scope '/subscriptions/xxxx-xxxx-xxxx/resourceGroups/xxxxxxxxx' -RoleDefinitionName 'Contributor'

当我们执行Runbook时,我们会遇到以下错误。

Exception of type 'Microsoft.Rest.Azure.CloudException' was thrown.

但是,当从本地PowerShell ISE执行相同的命令时,我们可以通过任何失败分配角色。

如何制作runbook将角色分配给用户分配的身份。

任何人都可以帮助我解决这个问题吗?

By using the below command, trying to assign a role to the managed identity using PowerShell runbook(5.1 Runtime version).

$roleAssignment = New-AzRoleAssignment -ObjectId 'xxxx-xxxx-xxxx-xxxx' -Scope '/subscriptions/xxxx-xxxx-xxxx/resourceGroups/xxxxxxxxx' -RoleDefinitionName 'Contributor'

When we execute the runbook we ran into the below error.

Exception of type 'Microsoft.Rest.Azure.CloudException' was thrown.

But, When executed the same command from local PowerShell ISE we are able to assign the role with out any fail.

How to make runbook to assign the role to the user assigned identity.

Can any one help me solve this.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

妞丶爷亲个 2025-02-19 09:22:05

无法通过Azure运行书籍为用户分配的身份分配角色(1).html

无法通过Azure运行书籍为用户分配的身份分配角色

抛出了'microsoft.rest.azure.cloudexception'的例外。

要解决上述错误,我建议您尝试遵循以下对我有用的解决方法: -

转到Azure AD->应用注册 - >选择您的应用 - > API许可 - >添加许可 - > Microsoft Graph(您可以选择要授予权限的任何Azure资源) - >申请许可 - >目录 - > Directory.Read.All
然后授予该特定资源所选权限的管理员同意。

“在此处输入图像说明”

在这里,您可以选择您使用的其他服务,也可以在Microsoft Graph以外的“请求API权限”中使用,您可以使用您正在工作的其他API,因为该过程与以下快照中所示: -

src =“ https://i.sstatic.net/jp167.png”

< img =“ https://i.sstatic.net/d6yji.png” alt =“在此处输入图像说明”>

“在此处输入图像说明”

Unable to assign a role to user assigned identity through Azure Run books (1).html

Unable to assign a role to user assigned identity through Azure Run books

Exception of type ‘Microsoft.Rest.Azure.CloudException’ was thrown.

To resolve the above error, I would suggest you try to follow the below workaround that worked for me: -

Go to Azure AD --> App registrations --> Select your app --> API Permissions --> Add permission --> Microsoft Graph (You can select any Azure resource for which you want to grant permissions for) --> Application Permissions --> Directory --> Directory.Read.All
Then grant admin consent for the selected permissions for that particular resource.

enter image description here

enter image description here

Here, you can select other services which you are using, also in ‘Request API Permissions’ other than Microsoft Graph, you can use other APIs that you are working since the process is same as shown in the below snapshot: -

enter image description here

enter image description here

enter image description here

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文