首页 > 解决方案 > Azure Python SDK Authentication Error

问题描述

I am trying to stop a virtual machine in the azure cloud using the azure-python-sdk. I am following this page https://github.com/Azure-Samples/virtual-machines-python-manage and I have created an Azure active directory application by following this link, https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal.

As a first step I am trying to authenticate using a call to ServicePrincipalCredentials passing client_id, secret, and tenant, but the connection throws the following error, 'Keyring cache token has failed: (1783, 'CredWrite', 'The stub received bad data')'

The application has a Virtual Machine Contributor permission setup. Is this a permission issue?

标签: pythonazureazure-management-apiazure-vm-role

解决方案


Keyring 是一个可选的子系统,它完全不影响身份验证。它旨在以一种即使 Python 进程消失也可以重新实例化凭据的方式存储您的令牌,而无需再次与 AD 交谈。如果凭据有效,这不会阻止身份验证,这只是一个警告日志,如果您的 Python 进程结束,您将无法重新创建 Credentials 类而不向 AD 重新请求令牌。

如果您有一个异常堆栈跟踪明确表示这会阻止身份验证工作,请在此处打开一个问题: https ://github.com/Azure/msrestazure-for-python/issues

(我在微软拥有这段代码和库,并写了你提到的文章)

编辑:从 msrestazure 0.5.0 开始,密钥环支持已被删除。


推荐阅读