我编写了一个运行 Python3 的 Azure 函数来简单地打开 Azure VM。
该函数应用程序具有系统分配的托管标识,我已为其授予 VM 贡献者角色。为了让该函数使用托管标识,我使用了 DefaultAzureCredential() 类。
我得到的错误是:
Exception: AttributeError: 'DefaultAzureCredential' object has no attribute 'signed_session'
我已经进行了大量的研究,但似乎找不到解决方案。
这是相关的代码:
from azure.identity import DefaultAzureCredential
credentials = DefaultAzureCredential()
compute_client = ComputeManagementClient(credentials, subscription_id)
# Starting the VM
print('\nStarting VM ' + VM_NAME)
vm_start = compute_client.virtual_machines.start(
RG_NAME, VM_NAME)
vm_start.wait()
Run Code Online (Sandbox Code Playgroud)
请原谅我,我只是 Python 新手,但对学习非常感兴趣。