I am new to use Azure python sdk. I have been using the following command to add tags to a subscription:
az tag update --operation merge --resource-id /subscriptions/{subscription-id} --tags <tag-name>=<tag-value>
The above command works good and creates the tag with the specified value in the subscription. However, I want to use the similar functionality in Python SDK. I found this to create / update a tag. It is returning a successful message. But I could not find any tag attached to the subscription with the given name. Please find attached code sample:
import os
import json
import csv
from azure.identity import DefaultAzureCredential
from azure.identity import InteractiveBrowserCredential
from azure.mgmt.resource.subscriptions import SubscriptionClient
from azure.mgmt.resource.resources import ResourceManagementClient
# from azure.
def main() :
header = ("subscription name", "subscription id", "pce-identity-functional-group")
subscription_client = SubscriptionClient(credential=DefaultAzureCredential())
result = subscription_client.subscriptions.list()
for e in result:
rc = ResourceManagementClient(credential=DefaultAzureCredential(), subscription_id=e.subscription_id)
print(rc.tags.create_or_update(tag_name="testing_one"))
Could anyone help me find where I am going wrong ? Thanks in advance.