2017-06-23 41 views
-1

我正在学习Microsoft Azure并使用python3。我得到以下错误代码:Microsoft Azure身份验证错误

C:\Python\python.exe D:/Phyton/Restapi/a.py 
Cannot find resource group sgelastic. Check connection/authorization. 
{ 
    "error": { 
    "code": "AuthorizationFailed", 
    "message": "The client '22273c48-3d9d-4f31-9316-210135595353' with object id '22273c48-3d9d-4f31-9316-210135595353' does not have authorization to perform action 'Microsoft.Resources/subscriptions/resourceGroups/read' over scope '/subscriptions/0f3e0eec-****-****-b9f9-************resourceGroups/sgelastic'." 
    } 
} 

Process finished with exit code 0 

该怎么办?我应该创建新的订阅或其他东西? 谢谢。

+0

你的描述不清楚。你能发布更多细节吗?比如你想做什么,你的源代码是'a.py'等。 –

回答

0

正如@Laurent Mazuel所说,尝试按照下图所示的步骤添加必要的权限。

enter image description here

  1. 点击在Azure门户Subscription标签。
  2. 选择相关资源组的订阅。
  3. 移至Access control (IAM)选项卡。
  4. 点击+ Add按钮。
  5. Add permission对话框中选择角色Contributor
  6. 搜索您的用户或应用程序的名称,然后选择您在搜索结果列表中使用的名称。
  7. 保存。

或者您可以使用Azure CLI 2.0创建服务主体来执行此操作。

az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/mySubscriptionID/resourceGroups/myResourceGroupName" 

希望它有帮助。

+0

谢谢你的帮助:) –

1

您使用的凭据没有必要的权限来读取资源组“sgelastic”。 根据您的需要,您可以将“参与者”角色添加到这些凭据,或对此特定资源组的更精确的权限。

你应该阅读RBAC的文档在Azure上的是,目前有: https://docs.microsoft.com/azure/active-directory/role-based-access-control-what-is

可用操作的列表(并有它内置的角色的名字)有: https://docs.microsoft.com/azure/active-directory/role-based-access-built-in-roles

+0

谢谢你的帮助:) –