question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Not able to update tag with tag contributors role

See original GitHub issue

Describe the bug We are trying to update / add tag to resource group using a service principal. While using PowerShell it is working as expected. But when we are trying to update tag via JAVA sdk we are getting following error

com.microsoft.azure.CloudException: Status code 403, {"error":{"code":"AuthorizationFailed","message":"The client '4c6edf90-19ac-6543-9aa5-0bb9994565bb' with object id '4c6edf90-19ac-6543-9aa5-0bb9994565bb' does not have authorization to perform action 'Microsoft.Resources/subscriptions/resourcegroups/write' over scope '/subscriptions/20dbcfe8-abcd-4c2d-C002-0927a4b7fffd/resourcegroups/cloud-shell-storage-southcentralus' or the scope is invalid. If access was recently granted, please refresh your credentials."}}: The client '4c6edf90-19ac-6543-9aa5-0bb9994565bb' with object id '4c6edf90-19ac-6543-9aa5-0bb9994565bb' does not have authorization to perform action 'Microsoft.Resources/subscriptions/resourcegroups/write' over scope '/subscriptions/20dbcfe8-abcd-4c2d-C002-0927a4b7fffd/resourcegroups/cloud-shell' or the scope is invalid. If access was recently granted, please refresh your credentials.

To Reproduce

  • Create a service principal
  • Attach tag contributor
  • Run java code to update resource group

Code Snippet image

Setup (please complete the following information):

  • OS: RHEL
  • IDE : Eclipse

The same setup will allow us to update the tag if we are using PowerShell but it won’t work with Azure CLI / Java SDK. could you please help us to fix it?

We cannot grant a service principal with permission ‘Microsoft.Resources/subscriptions/resourcegroups/write’ as it will gain the capability to update any RGs without any restrtction.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:29 (15 by maintainers)

github_iconTop GitHub Comments

2reactions
xseeseeseecommented, Jul 23, 2020

@johnakash @santhoshigorle We have released new version 1.36.0. Please try if it works to resolve your issue. Thanks.

1reaction
weidongxu-microsoftcommented, Jun 19, 2020

Hi @santhoshigorle

I am not aware there is a distinguish between environment tag and application tag.

If you would like to add new tag to existing tags, you would need to first get the existing tags, then add new one, finally do the update.

            ResourceGroup resourceGroup = azure.resourceGroups().getByName(RG_NAME);
            Map<String, String> tags = new HashMap<>(resourceGroup.tags());
            tags.put(newTagKey, newTagValue);

            azure.genericResources().manager().inner().resourceGroups()
                    .update(RG_NAME, new ResourceGroupPatchable().withTags(tags));
Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot create tag with RBAC rol "Tag Contributor" on a ...
Currently, the tag contributor role can't apply tags to resources or resource groups through the portal. It can apply tags to subscriptions ...
Read more >
Cannot add tags to Work Item even though permission is set to ...
I'm a Project Administrator and in the Contributors group where permission to add tags is defined as Allow. When I try to create...
Read more >
How to update a tag with a bug fix - Stack Overflow
I need to be able to change my local repository to a particular tag, make a change, push the change and then git...
Read more >
"Problem adding or updating tags" [#1543504] | Drupal.org
For some reason, i get this error "Problem adding or updating tags" for all files / roles / users. I've played around with...
Read more >
Managing tags - Adobe Support
If the user does not have the permissions to create new tags, an error message appears that the selected tag is no more...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found