azure-sdk-for-net
azure-sdk-for-net copied to clipboard
[BUG] Cannot add DataAction roles
Library name and version
Azure.ResourceManager.Authorization 1.0.0-beta.1
Describe the bug
When trying to add Key Vault Secrets Officer role to a keyvault i get the following error:
"Assignments to roles with DataActions and NotDataActions are not supported on API version '2015-07-01'. The minimum required API version for this operations is '2018-01-01-preview'"
I have tried to set the api version with client options but will then run into other errors
ArmClientOptions clientOptions = new();
clientOptions.SetApiVersion(KeyVaultResource.ResourceType, "2018-01-01-preview");
var armClient = new ArmClient(creds, {SubscriptionId}, clientOptions);
Gets me the following error: No registered resource provider found for location 'westeurope' and API version '2018-01-01-preview' for type 'vaults'
Expected behavior
Key Vault Secrets Officer role should be added to the resource
Actual behavior
Api throws error with api version
Reproduction Steps
ArmClientOptions clientOptions = new();
clientOptions.SetApiVersion(KeyVaultResource.ResourceType, "2018-01-01-preview");
var armClient = new ArmClient(creds, {SubscriptionId}, clientOptions);
Environment
.NET 6.0 visual studio 2022 17.5.2
Thank you for your feedback. Tagging and routing to the team member best able to assist.
@shareonline The error is complaining about the api-version of the RoleAssignmentResource, please override its version instead.
@shareonline The error is complaining about the api-version of the RoleAssignmentResource, please override its version instead.
I know this is old.. But i solved it by just not using the SDK instead for that call. However now i wanted to try because of the stable release 1.0.0, but are running into the same error on another endpoint. Can you explain how to change the ApiVersion?
For instance this doesn't seem to do anything? ArmClientOptions options = new ArmClientOptions(); options.SetApiVersion("Microsoft.Authorization/roleDefinitions", "2018-01-01-preview");
ArmClient armClient = new ArmClient(creds, subscriptionId, options);
I am more and more inclined to just use the api and http calls, as it seems all open tickets about stuff not working can be left alone for months.. We can't really wait that long for customer projects. 🤔
Is this error thrown when you call the below method? https://github.com/Azure/azure-sdk-for-net/blob/e2c35aea64f881c99e320393a0b03065731fd5de/sdk/authorization/Azure.ResourceManager.Authorization/src/Generated/RoleAssignmentCollection.cs#L47-L57
We have added the Request Path
for the method in comments, and you can get its resource type as Microsoft.Authorization/roleAssignments
. Therefore, you need options.SetApiVersion(new ResourceType("Microsoft.Authorization/roleAssignments"), "2018-01-01-preview");
or simply
options.SetApiVersion(RoleAssignmentResource.ResourceType, "2018-01-01-preview");
Hi, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!