Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取azure python delete\u by\u id方法的正确api版本_Python_Azure_Api_Cloud - Fatal编程技术网

获取azure python delete\u by\u id方法的正确api版本

获取azure python delete\u by\u id方法的正确api版本,python,azure,api,cloud,Python,Azure,Api,Cloud,我正在根据附加到这些资源的标签自动删除Azure资源 我正在使用Azure SDK for python()-我发现了如何获取我的资源列表,并且可以使用ResourceManagementClient with resources.delete_by_id方法删除它们。 但是,此方法需要两个参数—资源id(我从ResourceManagementClient列出的资源中获得)和API版本(对于每种资源类型都不同) 如何确定应将哪个API版本传递给该方法? 我试图在SDK的文档和代码中找到一些东西

我正在根据附加到这些资源的标签自动删除Azure资源

我正在使用Azure SDK for python()-我发现了如何获取我的资源列表,并且可以使用ResourceManagementClient with resources.delete_by_id方法删除它们。 但是,此方法需要两个参数—资源id(我从ResourceManagementClient列出的资源中获得)和API版本(对于每种资源类型都不同)

如何确定应将哪个API版本传递给该方法? 我试图在SDK的文档和代码中找到一些东西,但我没有找到合适的解决方案

API版本甚至可以硬编码,但它需要适用于所有资源类型

当使用某些api版本(例如2018-05-01)时,我发现某些资源类型存在错误:

Azure Error: NoRegisteredProviderFound
Message: No registered resource provider found for location 'westeurope' and API version '['2018-05-01']' for type 'virtualMachines'. The supported api-versions are '2015-05-01-preview, 2015-06-15, 2016-03-30, 2016-04-30-preview, 2016-08-30, 2017-03-30, 2017-12-01, 2018-04-01, 2018-06-01, 2018-10-01, 2019-03-01'. The supported locations are 'eastus, eastus2, westus, centralus, northcentralus, southcentralus, northeurope, westeurope, eastasia, southeastasia, japaneast, japanwest, australiaeast, australiasoutheast, brazilsouth, southindia, centralindia, westindia, canadacentral, canadaeast, westus2, westcentralus, uksouth, ukwest, koreacentral, koreasouth, francecentral, southafricanorth'.
ERROR: 'CloudError' object has no attribute '__traceback__'

如果我没有弄错的话,
resources.delete\u by\u id
是REST API方法的包装器。目前此操作的最新API版本是
2018-05-01
。您可以在方法调用中使用它。

我建议使用与CLI实现相同的方法,对ARM进行初始调用以从Res获取可能的映射将提供程序/资源类型转换为API版本,并使用它在调用中注入正确的API版本

获取此映射将是一个简单的过程


编辑:我在Python SDK团队的MS工作。

不幸的是,此版本不适用于磁盘资源类型。:(您收到的错误消息是什么?请编辑您的问题,并包括您使用的代码和收到的错误消息。