如何在Python中添加azure标记数组

2024-09-28 03:17:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试向资源添加azure标记(数组)。 问题在于数组,或者列表为标记,azuresdkforpython似乎只允许str

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

我在azuresdk中搜索python文档:link

有没有可能在Python中实现azure标记dict/array/list的创建?在


Tags: 函数标记列表数组资源privatefunctionsazure
2条回答

正如添加一样,Tags的所有可用azureapi包括restapi(用于^{}如下)和sdkapi,没有一个API可以一次添加多个标记。在

enter image description here

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

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

相关问题 更多 >

    热门问题