小编Jay*_*Jay的帖子

Azure Python SDK 错误

我已经编写了 python 代码来使用 azure-python sdk 获取订阅的 azure 资源,列出资源组内所有资源的功能不起作用,这在一周前工作正常,可能是微软改变了他们的 api? ? 我收到一个属性错误,AttributeError: 'ResourceGroupsOperations' 对象没有属性 'list_resources'

请找到下面的代码,

from azure.common.credentials import ServicePrincipalCredentials  
from azure.mgmt.resource.resources import ResourceManagementClient   
from azure.mgmt.compute import ComputeManagementClient
from azure.mgmt.network import NetworkManagementClient
subscription_id = ''
credentials = ServicePrincipalCredentials(
client_id = '',
secret = '',
tenant = '',
)
resource_client = ResourceManagementClient(credentials,subscription_id)
resource_client.providers.register('Microsoft.Batch')
def get_resources():
for rg in resource_client.resource_groups.list():
for item in resource_client.resource_groups.list_resources(rg.name):
print "%s,%s,%s,%s,"%(item.name,item.type,item.location,rg.name)
get_resources()
Run Code Online (Sandbox Code Playgroud)

请帮忙解决这个问题!提前致谢 !

python api azure

4
推荐指数
1
解决办法
2123
查看次数

标签 统计

api ×1

azure ×1

python ×1