gpt4 book ai didi

azure - 对象 ID xxx 的客户端 xxx 无权在范围内执行操作 Microsoft.Resources/subscriptions/resourcegroups/write'

转载 作者:行者123 更新时间:2023-12-02 11:21:14 24 4
gpt4 key购买 nike

我正在尝试使用 Azure 管理 SDK 动态创建资源组这是我的 azure 配置详细信息

subscription=<private-data>
client=<private-data>
key=<private-data>
tenant=<private-data>
managementURI=https://management.core.windows.net/
baseURL=https://management.azure.com/
authURL=https://login.windows.net/
graphURL=https://graph.windows.net/

这是创建资源的代码

// Credentials
AzureCredentials credentials = new AzureCredentialsFactory()
.FromFile("azureauth.properties");
string resourceName = GetRandomString();

// Create Azure Instance
var azure = Azure
.Configure()
.Authenticate(credentials)
.WithDefaultSubscription();

// Create a Resource Group
azure.ResourceGroups
.Define(resourceName)
.WithRegion(Region.USWest)
.Create();

我得到的错误是:

The client 'ae8bc2ea-9680-4f66-934c-ad40b82c30ac' with object id 'ae8bc2ea-9680-4f66-934c-ad40b82c30ac' does not have authorization to perform action 'Microsoft.Resources/subscriptions/resourcegroups/write' over scope '/subscriptions/e9d61100-a82a-48ca-b6f8-51b06a1eebe6/resourcegroups/5oxjhjic'.

我已按照 https://learn.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal 上指定的步骤进行操作
我正在尝试使用我的全局管理员帐户

最佳答案

显然,你不能尝试使用全局管理员。您需要转到订阅并授予 objectid 'ae8bc2ea-9680-4f66-934c-ad40b82c30ac' 贡献者权限(简单方法)或创建满足您需求的自定义角色(或数字预定义角色)。

您可以使用门户网站或 azure powershell 来执行此操作:

New-AzRoleAssignment -ObjectId 'ae8bc2ea-9680-4f66-934c-ad40b82c30ac' -Scope '/subscriptions/e9d61100-a82a-48ca-b6f8-51b06a1eebe6' -RoleDefinitionName contributor

等效的 Azure CLI 命令是:

az role assignment create --assignee-object-id ae8bc2ea-9680-4f66-934c-ad40b82c30ac --scope subscriptions/e9d61100-a82a-48ca-b6f8-51b06a1eebe6 --role contributor

关于azure - 对象 ID xxx 的客户端 xxx 无权在范围内执行操作 Microsoft.Resources/subscriptions/resourcegroups/write',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53517458/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com