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.

[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:

image

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:closed
  • Created a year ago
  • Reactions:1
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

0reactions
zadiguscommented, Oct 11, 2022

It seems to be fine with version 3.0.0.

Read more comments on GitHub >

github_iconTop 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 >

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