首页 > 解决方案 > 如何在 Python 中添加天蓝色标签数组

问题描述

我正在尝试将 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 创建?

标签: pythontagsazure-sdk-python

解决方案


目前,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

推荐阅读