我正在寻找在 Azure 中使用 python SDK 更新资源标签的帮助。我能够更新标签,resource groups
但我无法找到如何更新标签resources
下面是我用来更新resource groups
标签的代码
from azure.identity import AzureCliCredential
from azure.mgmt.resource import ResourceManagementClient
import os
credential = AzureCliCredential()
subscription_id = os.environ["AZURE_SUBSCRIPTION_ID"] = "Key"
#resource_group = os.getenv("RESOURCE_GROUP_NAME", "name")
resource_client = ResourceManagementClient(credential, subscription_id)
group_list = resource_client.resources.list()
for group in list(group_list):
a = group.location
b = group.name
if not group.tags:
resource_client.resources.create_or_update(
b,
{
"location" : a,
"tags" : tag_dict
}
)