Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]Error assigning role to service principal, exiting... #188

Open
SridharArrabelly opened this issue Oct 6, 2024 · 16 comments · May be fixed by #217
Open

[BUG]Error assigning role to service principal, exiting... #188

SridharArrabelly opened this issue Oct 6, 2024 · 16 comments · May be fixed by #217
Labels
bug Something isn't working

Comments

@SridharArrabelly
Copy link

Describe the bug
I followed the steps as explained in the deployment guide. It appears the provisioning of services has been completed successfully. but the problem with assigning roles after.

To Reproduce
Steps to reproduce the behavior:

  1. run bash deploy.sh -p deploy.parameters.json
  2. you will see the error as in the attached screenshot.

Screenshots
Screenshot 2024-10-06 164042

Desktop (please complete the following information):

  • OS: Windows 11
  • Bicep: 0.30.23

Additional context
Resource group and OpenAI are in the same subscription..

@SridharArrabelly SridharArrabelly added the bug Something isn't working label Oct 6, 2024
@timothymeyers
Copy link
Contributor

@SridharArrabelly - can you verify that your user (or service principal executing the deployment) has the Role Based Access Control (RBAC) Administrator role assigned on your subscription?

I've found this is generally the issue, where this role is either not assigned or is limited in scope to particular resources.

@DOliana
Copy link

DOliana commented Oct 8, 2024

I had a similar issue - for me restarting the deployment helped. It seems there are some timing issues. Also at some point the issue was that the nodes inthe AKS cluster were still starting.

@soon-nl
Copy link

soon-nl commented Oct 8, 2024

I had a similar issue - for me restarting the deployment helped. It seems there are some timing issues. Also at some point the issue was that the nodes inthe AKS cluster were still starting.

Having the same error. Did you just run bash deploy.sh -p deploy.parameters.json again?

@SridharArrabelly
Copy link
Author

SridharArrabelly commented Oct 9, 2024

@DOliana @soon-nl redploy/run again didn't work.
@timothymeyers I can confirm that i have the Role Based Access Control (RBAC) Administrator role. please see attached.

Screenshot 2024-10-09 062044

@DOliana
Copy link

DOliana commented Oct 21, 2024

I had a similar issue - for me restarting the deployment helped. It seems there are some timing issues. Also at some point the issue was that the nodes inthe AKS cluster were still starting.

Having the same error. Did you just run bash deploy.sh -p deploy.parameters.json again?

yes exactly. rerunning it did the trick for me.

@puneetpawaia
Copy link

puneetpawaia commented Dec 27, 2024

@DOliana rerun didn't work for me either.
Anything else I can do?
I am the subscription owner but I still have given the RBAC admin permission to myself. I am also the subscription owner.

@guybartal
Copy link

running again for many times didn't work for me, I'm also directory and subscription admin.

btw, added some traces to the deployment script and the scope looks empty, might be the cause?

Deployment name: graphrag-deploy-2025-01-01_18-31-00
Assigning 'Cognitive Services OpenAI Contributor' role to managed identity... 
servicePrincipalId: a7ffbae6-bae6-4faf-b137-b80743fbf256
scope: 
 ________________________________
/  Uh oh, an error has occurred. \
\  Please see message below.     /
 ‾‾‾‾‾‾‾‾‾‾/‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
          /
      __ /
     /  \
    ~    ~
   / \  /_\
   \o/  \o/
    |    |
    ||   |/
    ||   ||
    ||   ||
    | \_/ |
    \     /
     \___/

Error assigning role to service principal, exiting...

@guybartal
Copy link

I've tried to manually assign role to this principal, and it worked and also solved my indexing issue:

image

@guybartal
Copy link

I've found the problem, if your OpenAI service is deployed into another subscription the scope empty, you need to pass the subscription id to the following line:

local scope=$(az cognitiveservices account list --subscription=$GRAPHRAG_API_SUBSCRIPTION --query "[?contains(properties.endpoint, '$GRAPHRAG_API_BASE')] | [0].id" -o tsv)

and introduce this new GRAPHRAG_API_SUBSCRIPTION key in deploy.parameters.json

@puneetpawaia
Copy link

Hi @guybartal , my OpenAI service is in the same subscription but in a different resource group. Can you help me with adding the trace to print out servicePrincipalId as you have done so that I can add the role directly to the service. Or should I move the service to the same resource group?

@puneetpawaia
Copy link

Did some more exploring and found that in my case
AZURE_DEPLOY_RESULTS in the deployAzureResources function is coming out to be empty. For both a fresh run and for a rerun. Tested this with OpenAI service in different resource groups and in the same resource group.

@puneetpawaia
Copy link

Hi @markmassad , can you check if AZURE_DEPLOY_RESULTS contains some value or if it is blank as it is for me? This is the same message I get.

@markmassad
Copy link

markmassad commented Jan 4, 2025

Hello @puneetpawaia, I didn't check that... but I see the error is in: az role assignment create --role 'Cognitive Services OpenAI Contributor' --assignee [SPObjectID] --scope '/subscriptions/[SUBID]/resourceGroups/openAI/providers/Microsoft.CognitiveServices/accounts/openai1a'

I tried several variations of that command and none of them added the role assignment. For whatever reason, I could ONLY add the assignment to the SP using the Portal. Go figure??? Maybe a bug in the Az fabric?

BTW: I deleted a comment as it was a side effect of this issue here on the role assignment creation and didn't want to muddy the water.

@puneetpawaia
Copy link

Hi @markmassad , if I understand correctly, this code is in at line 422 in function assignAOAIRoleToManagedIdentity of deploy.sh
Unfortunately, I don't get to this code in my case. I get the error while the deployment is processing main.bicep. My error comes from line 362 which is before assignAOAIRoleToManagedIdentity get called in line 366.

@guybartal
Copy link

guybartal commented Jan 6, 2025 via email

@guybartal
Copy link

@puneetpawaia, in case this PR doesn't help you, I suggest you share the error captured in the deployment from Azure Portal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants