[Authorization] Cannot find a way to az role assignment create with the SDK
See original GitHub issue- Package Name: azure-mgmt-authorization
- Package Version: 2.0.0
- Operating System: Windows
- Python Version: 3.10
Describe the bug Provided an assignee principal id and a role definition id, the following code
credential = ClientSecretCredential(
client_id=os.environ["AZURE_CLIENT_ID"],
tenant_id=os.environ["AZURE_TENANT_ID"],
client_secret=os.environ["AZURE_CLIENT_SECRET"],
)
with AuthorizationManagementClient(credential, subscription_id) as auth_mgmt_client:
auth_mgmt_client.role_assignments.create(
scope=aks_resource_id,
role_assignment_name=role_definition_id,
parameters=RoleAssignmentCreateParameters(
role_definition_id=role_definition_id,
principal_id=assignee_principal_id,
),
)
I get the following error:
azure.core.exceptions.HttpResponseError: (NoRegisteredProviderFound) No registered resource provider found for location 'eastus' and API version '2015-07-01' for type 'managedClusters'. The supported api-versions are '2017-08-31, 2018-03-31, 2018-08-01-preview, 2019-02-01, 2019-04-01, 2019-06-01, 2019-08-01, 2019-10-01, 2019-11-01, 2020-01-01, 2020-02-01, 2020-03-01, 2020-04-01, 2020-06-01, 2020-07-01, 2020-09-01, 2020-11-01, 2020-12-01, 2021-02-01, 2021-03-01, 2021-05-01, 2021-07-01, 2021-08-01, 2021-09-01, 2021-10-01, 2021-11-01-preview, 2022-01-01, 2022-01-02-preview, 2022-02-01, 2022-02-02-preview, 2022-03-01, 2022-03-02-preview, 2022-04-01, 2022-04-02-preview, 2022-05-02-preview, 2022-06-01, 2022-06-02-preview, 2022-07-01, 2022-07-02-preview, 2022-08-01, 2022-08-02-preview, 2022-08-03-preview'. The supported locations are 'australiacentral, australiacentral2, australiaeast, australiasoutheast, brazilsouth, brazilsoutheast, canadacentral, canadaeast, centralindia, centralus, eastasia, eastus, eastus2, francecentral, francesouth, germanynorth, germanywestcentral, japaneast, japanwest, jioindiacentral, jioindiawest, koreacentral, koreasouth, northcentralus, northeurope, norwayeast, norwaywest, qatarcentral, southafricanorth, southcentralus, southeastasia, southindia, swedencentral, switzerlandnorth, switzerlandwest, uaecentral, uaenorth, uksouth, ukwest, westcentralus, westeurope, westus, westus2, westus3'.
Code: NoRegisteredProviderFound
Message: No registered resource provider found for location 'eastus' and API version '2015-07-01' for type 'managedClusters'. The supported api-versions are '2017-08-31, 2018-03-31, 2018-08-01-preview, 2019-02-01, 2019-04-01, 2019-06-01, 2019-08-01, 2019-10-01, 2019-11-01, 2020-01-01, 2020-02-01, 2020-03-01, 2020-04-01, 2020-06-01, 2020-07-01, 2020-09-01, 2020-11-01, 2020-12-01, 2021-02-01, 2021-03-01, 2021-05-01, 2021-07-01, 2021-08-01, 2021-09-01, 2021-10-01, 2021-11-01-preview, 2022-01-01, 2022-01-02-preview, 2022-02-01, 2022-02-02-preview, 2022-03-01, 2022-03-02-preview, 2022-04-01, 2022-04-02-preview, 2022-05-02-preview, 2022-06-01, 2022-06-02-preview, 2022-07-01, 2022-07-02-preview, 2022-08-01, 2022-08-02-preview, 2022-08-03-preview'. The supported locations are 'australiacentral, australiacentral2, australiaeast, australiasoutheast, brazilsouth, brazilsoutheast, canadacentral, canadaeast, centralindia, centralus, eastasia, eastus, eastus2, francecentral, francesouth, germanynorth, germanywestcentral, japaneast, japanwest, jioindiacentral, jioindiawest, koreacentral, koreasouth, northcentralus, northeurope, norwayeast, norwaywest, qatarcentral, southafricanorth, southcentralus, southeastasia, southindia, swedencentral, switzerlandnorth, switzerlandwest, uaecentral, uaenorth, uksouth, ukwest, westcentralus, westeurope, westus, westus2, westus3'.
I have multiple choices on what RoleAssignmentCreateParameters
to import:
Whatever I choose, I get the above error.
Expected behavior
I expect to have one, and only one, possible RoleAssignmentCreateParameters
to import and no error. If I do the same (?) with the azure cli,
az role assignment create --role <role_definition_id> --assignee-object-id <assignee_principal_id> --scope <aks_resource_id>
then it works perfectly.
Am I doing something wrong?
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Troubleshoot Azure RBAC | Microsoft Learn
Authorization /roleAssignments/write permission such as Owner or User Access Administrator at the scope you are trying to assign the role.
Read more >Could not create a role assignment for ACR. Are you ... - GitHub
Have setup a AKS cluster with Azure AD auth, RBAC etc, all works well, when I try to connect to ACR in same...
Read more >Client does not have authorization to add role using az role ...
I added Azure CLI task in the VSTS pipeline and run 'az role assignment create' command to add role.
Read more >Perform Role Assignments on Azure Resources ... - Medium
We create a new AzDO yaml pipeline to do the following: Use the Azure CLI task; Use the Service Connection created above; Use...
Read more >Using RBAC Authorization | Kubernetes
It holds a list of subjects (users, groups, or service accounts), and a reference to the role being granted. A RoleBinding grants permissions ......
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
This code example helped.
https://github.com/Azure-Samples/azure-samples-python-management/blob/main/samples/authorization/manage_role_assignment.py
It seems to be fine with version 3.0.0.