question

YahavHorevCloudTeamai-2791 avatar image
0 Votes"
YahavHorevCloudTeamai-2791 asked YahavHorevCloudTeamai-2791 answered

how to use operation Merge/Replce/Delete in azure python for tagging?

i am trying to figure out how can i tag resources with operation Merge like in PS.

example in powershell -

 Update-AzTag -ResourceId $s.ResourceId -Tag $mergedTags -Operation Replace

my code in python -


   # Tag the resource groups.
     resource_group_client.resource_groups.create_or_update(resource_group_name=rg["Resource-group-name"],parameters=
     {'location': rg['location'], 
         'tags':tags_dict,
         'Operation': 'Merge'})

as you can see i am trying my luck to put 'operation' : 'merge' but it dosent work... any help here please?


azure-stack-hub
· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@YahavHorevCloudTeamai-2791 Can you please share which Azure services or products is this issue related to, so that we can direct it to the right team?

0 Votes 0 ·

@YahavHorevCloudTeamai-2791 Is there an update?

0 Votes 0 ·

1 Answer

YahavHorevCloudTeamai-2791 avatar image
0 Votes"
YahavHorevCloudTeamai-2791 answered

hey , i have been fixed it with this way :

 resource_group_client = ResourceManagementClient(credential, subscription_id=sub.subscription_id)
    
    
          body = {
              "operation" :  "Merge",
              "properties" : {
                  "tags" : 
                      tags_dict,
              }
          }
    
          resource_group_client.tags.update_at_scope(rg["Resource-id"] ,body)

the only way i found it work is to use "ResourceManagementClient" under tags.update_at_scope library .

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.