0

我正在尝试将 azure 标记(数组)添加到资源中。问题在于数组或作为标签的列表,Azure SDK for python 似乎只允许 str。

System.Private.CoreLib:执行函数时出现异常:Functions.azure_tags。System.Private.CoreLib:结果:失败异常:TypeError:必须是 str,而不是 dict

我在 Azure SDK 中搜索 python 文档:链接

是否可以在 Python 中实现天蓝色标签 dict/array/list 创建?

4

2 回答 2

0

目前,SDK 仅限于添加/更新一个标签值,这就是为什么它在参数中提供数组时会出错。

我建议你遍历你的数组并单独添加它。

create_or_update_value(tag_name, tag_value, custom_headers=None, raw=False, **operation_config)


create_or_update(tag_name, custom_headers=None, raw=False, **operation_config) 

Creates a tag in the subscription.

The tag name can have a maximum of 512 characters and is case insensitive. Tag names created by Azure have prefixes of microsoft, azure, or windows. You cannot create tags with one of these prefixes.

Parameters
tag_name
str
The name of the tag to create.

custom_headers
dict
headers that will be added to the request

default value: None
raw
bool
returns the direct response alongside the deserialized response

default value: False
operation_config
Operation configuration overrides.

Returns
TagDetails or ClientRawResponse if raw=true

Return type
TagDetails
ClientRawResponse
Exceptions
CloudError
于 2019-05-06T10:08:52.680 回答
0

作为补充,实际上在所有可用的 Azure API 中Tags包括 REST API(Tags如下所示)和 SDK API,没有一个 API 可以一次添加多个标签。

在此处输入图像描述

唯一的方法是循环以create_or_update_value迭代地在多个操作中使用方法。

于 2019-05-07T08:45:29.417 回答