【问题标题】:MSAL/ADAL support for new/old Azure python SDK modules对新/旧 Azure python SDK 模块的 MSAL/ADAL 支持
【发布时间】:2020-12-21 10:15:04
【问题描述】:

我们的应用程序从使用 Azure python SDK 2.0.0 的 ADAL 身份验证开始。 现在我开始将azure.mgmt.servicebus 升级到 6.0.0,在使用 ADAL 凭据时发现异常。

creatednamespace = servicebus_client.namespaces.begin_create_or_update(resource_group_name, namespace_name, namespaceparameter).result()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/azure/mgmt/servicebus/operations/_namespaces_operations.py", line 563, in begin_create_or_update
    **kwargs
  File "/usr/local/lib/python3.6/dist-packages/azure/mgmt/servicebus/operations/_namespaces_operations.py", line 502, in _create_or_update_initial
    pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 211, in run
    return first_node.send(pipeline_request)  # type: ignore
  File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 71, in send
    response = self.next.send(request)
  File "/usr/local/lib/python3.6/dist-packages/azure/mgmt/core/policies/_base.py", line 47, in send
    response = self.next.send(request)
  File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 71, in send
    response = self.next.send(request)
  File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 71, in send
    response = self.next.send(request)
  File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 71, in send
    response = self.next.send(request)
  [Previous line repeated 1 more time]
  File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/policies/_redirect.py", line 157, in send
    response = self.next.send(request)
  File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/policies/_retry.py", line 436, in send
    response = self.next.send(request)
  File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_base.py", line 69, in send
    _await_result(self._policy.on_request, request)
  File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/_tools.py", line 29, in await_result
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/azure/core/pipeline/policies/_authentication.py", line 93, in on_request
    self._token = self._credential.get_token(*self._scopes)

我阅读了 Azure 文档,新功能将需要 MSAL 或 azure.identity,我使用了 azure.identy,它确实有效。 现在的问题是我们混合了新旧 Azure SDK 包,我们应该遵循哪种身份验证?我尝试了带有 azure.identity 的旧包,它似乎仍然有效。但我不确定是否有任何我可能不知道的问题。 希望我们能得到一份清晰的 Azure 身份验证指南,以支持新旧 python SDK 包。

【问题讨论】:

    标签: azure adal msal


    【解决方案1】:

    azure.identity 提供一组凭据类,用于支持 Azure Active Directory (AAD) 令牌身份验证的 Azure SDK 客户端。 Mow Microsoft 建议客户使用该软件包对其他 Azure python sdk 进行身份验证。但请注意,它并不支持所有 azure 包。如果包没有使用azure.core,我们用它来做auth,我们会遇到错误。更多详情请参考herehere

    【讨论】:

    • 感谢您的详细解释。似乎我们需要有两组身份验证支持,具体取决于我们使用哪个包以及包是否使用 azure.core。这有点不方便,但我想我们只能忍受它。
    • 我已经添加到答案中,但现在似乎显示了一些方法。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-02-15
    • 1970-01-01
    • 1970-01-01
    • 2016-09-22
    • 2017-02-24
    • 2014-06-06
    相关资源
    最近更新 更多