Permissions required when tagging resources
See original GitHub issueI am trying to trying to update tags (adding tags but also removing/updating) on the resources of type Microsoft.Compute
.
I have a service principal that has been granted Tag Contributor, however I receive this when updating the tag using the code below:
The client '<guid>' with object id '<guid>' does not have authorisation to perform action 'Microsoft.Compute/disks/write' over scope <resource id> or the scope is invalid
.
Please can you take a look at the code below either let me know if it can be modified so I can get away with the tag contributor permission or will I need to grant my service principal a higher level of privileges?
var azureCredentials #set above
using (var client = new Microsoft.Azure.Management.Resources.ResourceManagementClient(azureCredentials))
{
var tags = new Dictionary<string, string>
{
{ "environment", "test" },
{ "department", "tech" }
};
try
{
var result = await client.Resources.CreateOrUpdateAsync(resourceGroupName, resourceIdentity, genericResourceParameters, cts.Token);
if (result.StatusCode == System.Net.HttpStatusCode.OK)
{
System.Console.WriteLine(string.Format("Tags updated for {0}", resource.Name));
InsertLogEntry(resource.Id, true, null);
}
}
catch (Hyak.Common.CloudException cloudException)
{
System.Console.WriteLine(string.Format("Caught Hyak.Common.CloudException when updating {0}, {1}", resource.Name, cloudException.Message));
}
}
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Grant permission to tag resources during creation
To force users to specify tags when they create a resource, you must use the aws:RequestTag condition key or the aws:TagKeys condition key...
Read more >Permissions by Resource-Tag at AWS - 1-Minute IAM Lesson
Bart continues his AWS Identity & Access Management video series. Today he is talking about enforcing permissions for actions based on the ...
Read more >Use IAM authorization based resource tags with ...
IAM policies can use the global condition key aws:ResourceTag to control access based on the resource's tag key and value. Not all AWS...
Read more >tag-resources — AWS CLI 2.13.11 Command Reference
To add tags to a resource, you need the necessary permissions for the service that the resource belongs to as well as permissions...
Read more >Granting users access to tag resources and service IDs
Tagging permissions. Any user in an account can view tags. When a resource is tagged, all users that have read access to the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I am using Microsoft.Azure.Management.ResourceManager SDK. Here is a sample project I tested with.
To leverage the
tag contributor
permission, the call must explicitly go thrutags
operation instead of general update operation on the resource. Otherwise the underlying call is a PUT on/provider/Microsoft.Provider/xxx
instead of/provider/Microsoft.Provider/xxx/provider/Microsoft.Resource/tags/default
which triggers different RBAC.Here is the sample code. You can look into TagsOperation documentation. Methods without
AtScope
are creating default tags collections at subscription level vs ones with it applying the tags on each resource (specified with scope). Hope this clears it up.