gpt4 book ai didi

python - 使用 python sdk Azure 身份验证失败

转载 作者:行者123 更新时间:2023-12-01 08:33:28 33 4
gpt4 key购买 nike

我是azure新手,刚刚开始学习,我的目标是使用azure cli和python sdk获取实例信息,我正在从官方文档学习https://learn.microsoft.com/en-us/python/api/overview/azure/containerinstance?view=azure-python

我正在尝试验证并获取容器信息,但脚本不起作用,我已按照步骤 1 和 2 进行操作。请提供帮助,如果有任何其他简单的学习方法请通知我。

这是我正在使用的代码

from os import getenv
from azure.common.client_factory import get_client_from_auth_file
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
from azure.mgmt.resource.resources import ResourceManagementClient


AZURE_AUTH_LOCATION = 'C:\\Users\\gsc-30310\\PycharmProjects\\Azure\\my.azureauth'
auth_file_path = getenv('AZURE_AUTH_LOCATION', None)
if auth_file_path is not None:
print("Authenticating with Azure using credentials in file at {0}"
.format(auth_file_path))

aciclient = get_client_from_auth_file(ContainerInstanceManagementClient)
resclient = get_client_from_auth_file(ResourceManagementClient)
else:
print("\nFailed to authenticate to Azure. Have you set the"
" AZURE_AUTH_LOCATION environment variable?\n")

最佳答案

维卡斯。我关注了steps并设置 AZURE_AUTH_LOCATION

enter image description here

然后你需要重新启动你的开发工具,以便它可以在新的 Windows session 中读取你最新的环境值。否则,它将始终none

关于python - 使用 python sdk Azure 身份验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53831943/

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