azure-sdk-for-net
azure-sdk-for-net copied to clipboard
[BUG] Unable to use AuthorizationManagementClient due to preview api use
Library name and version
Microsoft.Azure.Management.Authorization 2.0.13.preview
Describe the bug
Trying to add a role assignment but unable to use AuthorizationManagementClient to do anything.
The library has been in preview for the last 5 years and each preview release used a release of the Azure preview API which subsequently got dropped in lieu of a properly dated library version.
If I drop to 2.0.1 which is the last stable release from 2017 I can't use with .net core.
Can you let me know when there will be another stable release of this library? For now I'm dropping back to the REST API.
Expected behavior
Adds role assignment to an Azure object
Actual behavior
Response produces:
{"error":{"code":"InvalidApiVersionParameter","message":"The api-version '2020-08-01-preview' is invalid. The supported versions are '2022-05-01,2022-03-01-preview,2022-01-01,2021-04-01,2021-01-01,2020-10-01,2020-09-01,2020-08-01,2020-07-01,2020-06-01,2020-05-01,2020-01-01,2019-11-01,2019-10-01,2019-09-01,2019-08-01,2019-07-01,2019-06-01,2019-05-10,2019-05-01,2019-03-01,2018-11-01,2018-09-01,2018-08-01,2018-07-01,2018-06-01,2018-05-01,2018-02-01,2018-01-01,2017-12-01,2017-08-01,2017-06-01,2017-05-10,2017-05-01,2017-03-01,2016-09-01,2016-07-01,2016-06-01,2016-02-01,2015-11-01,2015-01-01,2014-04-01-preview,2014-04-01,2014-01-01,2013-03-01,2014-02-26,2014-04'."}}
Reproduction Steps
Something like this.
- Generate a bearer token
- Use the AuthorizationManagementClient
- Assign a role definition (contributor used below)
- Watch is blow up with: "code":"InvalidApiVersionParameter","message":"The api-version '2020-08-01-preview' is invalid
var credentials = new TokenCredentials(await GetAccessTokenFor(resourceUriAzure,_tenantName, _tenantId, _clientId, _clientSecret)); var client = new AuthorizationManagementClient(credentials); var assignment = await client.RoleAssignments.CreateByIdAsync(resourceId, new Microsoft.Azure.Management.Authorization.Models.RoleAssignmentCreateParameters() { PrincipalId = userName, PrincipalType = "User", RoleDefinitionId = "b24988ac-6180-42a0-ab88-20f7382dd24c" });
Environment
.net 6 windows 11 Visual Studio 2022
Label prediction was below confidence level 0.6 for Model:ServiceLabels: 'ARM:0.18391359,Resource Authorization:0.08880011,Storage:0.04429862'
Thank you for your feedback. Tagging and routing to the team member best able to assist.
@azurecoder please try with our new generation of .NET SDK: https://www.nuget.org/packages/Azure.ResourceManager.Authorization/1.0.0 Here is a quick start guide: https://github.com/Azure/azure-sdk-for-net/blob/main/doc/dev/mgmt_quickstart.md
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!