如何使用特定的 api 版本创建 Monitor Client?
How do you create a Monitor Client using a specific api-version?
我正在尝试调用特定版本的 ARM API:
2017-03-01-preview
在正常的 REST API 调用中,您可以指定 api-version=2017-03-01-preview
,但是我没有看到使用 Azure Python SDK 的类似选项。
专门尝试针对此 API 版本创建新的 Monitor Client。
http://azure-sdk-for-python.readthedocs.io/en/latest/sample_azure-monitor.html
谢谢!
首先,我将回答您有关监视器的具体问题。这被认为是先进的,我们不能保证反序列化会起作用。 raw=True
应该用于获取 JSON 并且不要尝试反序列化(raw=True
不适用于列表操作)。 API 版本是操作组级别的属性:
client = MonitorClient(**parameters)
# 2015-05-05 for instance (fake value, I don't know monitor Api Version history)
client.metric_definitions.api_version = "2015-05-05"
如果您确实需要调用较旧的 Api 版本并 100% 保证调用有效,您可以使用 azure-mgmt-resource
包和通用调用:
get_result = self.resource_client.resources.get(
resource_group_name=group_name,
resource_provider_namespace="Microsoft.Compute",
parent_resource_path="",
resource_type="availabilitySets",
resource_name=resource_name,
api_version="2015-05-01-preview",
)
请注意,我们目前正在向包中添加多 api 版本支持。 azure-mgmt-(compute/resource/storage/network/containerregistry)
中已支持此功能
这些包有一个 api_version
参数,这意味着您会根据此 api_version
.
收到正确的 class
(我在 MS 拥有 SDK)
编辑:使用 raw=True 改进文本
我正在尝试调用特定版本的 ARM API:
2017-03-01-preview
在正常的 REST API 调用中,您可以指定 api-version=2017-03-01-preview
,但是我没有看到使用 Azure Python SDK 的类似选项。
专门尝试针对此 API 版本创建新的 Monitor Client。 http://azure-sdk-for-python.readthedocs.io/en/latest/sample_azure-monitor.html
谢谢!
首先,我将回答您有关监视器的具体问题。这被认为是先进的,我们不能保证反序列化会起作用。 raw=True
应该用于获取 JSON 并且不要尝试反序列化(raw=True
不适用于列表操作)。 API 版本是操作组级别的属性:
client = MonitorClient(**parameters)
# 2015-05-05 for instance (fake value, I don't know monitor Api Version history)
client.metric_definitions.api_version = "2015-05-05"
如果您确实需要调用较旧的 Api 版本并 100% 保证调用有效,您可以使用 azure-mgmt-resource
包和通用调用:
get_result = self.resource_client.resources.get(
resource_group_name=group_name,
resource_provider_namespace="Microsoft.Compute",
parent_resource_path="",
resource_type="availabilitySets",
resource_name=resource_name,
api_version="2015-05-01-preview",
)
请注意,我们目前正在向包中添加多 api 版本支持。 azure-mgmt-(compute/resource/storage/network/containerregistry)
这些包有一个 api_version
参数,这意味着您会根据此 api_version
.
(我在 MS 拥有 SDK)
编辑:使用 raw=True 改进文本