azure-search-openai-demo icon indicating copy to clipboard operation
azure-search-openai-demo copied to clipboard

Authorization failed

Open gitpsk opened this issue 2 years ago • 12 comments

Requirement already satisfied: charset-normalizer<4,>=2 in ./scripts/.venv/lib/python3.9/site-packages (from requests>=2.18.4->azure-core<2.0.0,>=1.23.0->azure-ai-formrecognizer==3.2.1->-r ./scripts/requirements.txt (line 4)) (3.1.0) Requirement already satisfied: idna<4,>=2.5 in ./scripts/.venv/lib/python3.9/site-packages (from requests>=2.18.4->azure-core<2.0.0,>=1.23.0->azure-ai-formrecognizer==3.2.1->-r ./scripts/requirements.txt (line 4)) (3.4) Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./scripts/.venv/lib/python3.9/site-packages (from requests>=2.18.4->azure-core<2.0.0,>=1.23.0->azure-ai-formrecognizer==3.2.1->-r ./scripts/requirements.txt (line 4)) (1.26.15) Requirement already satisfied: oauthlib>=3.0.0 in ./scripts/.venv/lib/python3.9/site-packages (from requests-oauthlib>=0.5.0->msrest>=0.6.21->azure-ai-formrecognizer==3.2.1->-r ./scripts/requirements.txt (line 4)) (3.2.2) Running "prepdocs.py" Ensuring search index gptkbindex exists Traceback (most recent call last): File "/workspaces/azure-search-openai-demo/./scripts/prepdocs.py", line 299, in create_search_index() File "/workspaces/azure-search-openai-demo/./scripts/prepdocs.py", line 237, in create_search_index if args.index not in index_client.list_index_names(): File "/workspaces/azure-search-openai-demo/scripts/.venv/lib/python3.9/site-packages/azure/core/paging.py", line 132, in next return next(self._page_iterator) File "/workspaces/azure-search-openai-demo/scripts/.venv/lib/python3.9/site-packages/azure/core/paging.py", line 76, in next self._response = self._get_next(self.continuation_token) File "/workspaces/azure-search-openai-demo/scripts/.venv/lib/python3.9/site-packages/azure/search/documents/indexes/_generated/operations/_indexes_operations.py", line 520, in get_next raise HttpResponseError(response=response, model=error) azure.core.exceptions.HttpResponseError: () Authorization failed. Code: Message: Authorization failed. PS /workspaces/azure-search-openai-demo>

Please provide us with the following information:

This issue is for a: (mark with an x)

- [ ] bug report -> please search issues before submitting
- [ ] feature request
- [ ] documentation issue or request
- [ ] regression (a behavior that used to work and stopped in a new release)

Minimal steps to reproduce

Any log messages given by the failure

Expected/desired behavior

OS and Version?

Windows 7, 8 or 10. Linux (which distribution). macOS (Yosemite? El Capitan? Sierra?)

Versions

Mention any other details that might be useful


Thanks! We'll be in touch soon.

gitpsk avatar Mar 31 '23 19:03 gitpsk

I'm seeing the exact same issue. I'm using WSL 2 on Windows 11 Enterprise. I followed all the instructions exactly, except I had to use "azd login --use-device-code" instead of just "azd login". I didn't set any of the environment variables to use existing resources.

bstollnitz avatar Mar 31 '23 22:03 bstollnitz

same issue for me as well: File "/workspaces/azure-search-openai-demo/MIPGPT/scripts/.venv/lib/python3.9/site-packages/azure/search/documents/indexes/_generated/operations/_indexes_operations.py", line 520, in get_next raise HttpResponseError(response=response, model=error) azure.core.exceptions.HttpResponseError: () Authorization failed. Code: Message: Authorization failed.

alf233 avatar Apr 03 '23 23:04 alf233

This often happens when the previous runs of "azd up" don't run to completion, since one of the last steps is to add roles for the currently logged-in user so the account can access the storage account, search service, etc. Did you try adding your self as blob contributor (in the storage account) and search contributor (in the search service)?

pablocastro avatar Apr 04 '23 00:04 pablocastro

that did it for me, thanks @pablocastro

alf233 avatar Apr 04 '23 01:04 alf233

That didn't work for me :( As far as I can tell, my user has blob contributor permissions in the storage account, and search countributor permissions in the search service. I get the error while doing "azd up". Here's the full stack for the error I get:

Running "prepdocs.py" Ensuring search index gptkbindex exists Traceback (most recent call last): File "/home/bstollnitz/git/azure-search-openai-demo/./scripts/prepdocs.py", line 299, in create_search_index() File "/home/bstollnitz/git/azure-search-openai-demo/./scripts/prepdocs.py", line 237, in create_search_index if args.index not in index_client.list_index_names(): File "/home/bstollnitz/git/azure-search-openai-demo/scripts/.venv/lib/python3.9/site-packages/azure/core/paging.py", line 132, in next return next(self._page_iterator) File "/home/bstollnitz/git/azure-search-openai-demo/scripts/.venv/lib/python3.9/site-packages/azure/core/paging.py", line 76, in next self._response = self._get_next(self.continuation_token) File "/home/bstollnitz/git/azure-search-openai-demo/scripts/.venv/lib/python3.9/site-packages/azure/search/documents/indexes/_generated/operations/_indexes_operations.py", line 520, in get_next raise HttpResponseError(response=response, model=error) azure.core.exceptions.HttpResponseError: () Authorization failed. Code: Message: Authorization failed.

ERROR: failed running post hooks: 'postprovision' hook failed with exit code: '1', Path: './scripts/prepdocs.sh'. : exit status 1

bstollnitz avatar Apr 05 '23 01:04 bstollnitz

I also tried to delete the resource group and start fresh, just in case something was corrupt from previous attempts, and I get the same error.

bstollnitz avatar Apr 05 '23 01:04 bstollnitz

I am also running into the same error. Many attempts, I am not sure what else I need to do.

marknhenry avatar Apr 12 '23 10:04 marknhenry

My solution was to get the credentials from https://portal.azure.com/ add them to the .env file that was created during the deployment and adjust scripts/prepdocs.sh#L21 so the additional variables get passed. You need to do that for Storage, Search and Formrecognizer.

gregorwolf avatar Apr 12 '23 11:04 gregorwolf

This issue is fixed on the new azd version.

You can try from a new empty folder and you should not have this issue anymore.

And to fix an existing project, you go to the .env file from .azure/<env-name-folder>/.env and delete the AZURE_PRINCIPAL_ID entry. Then, the next time you run azd up, the value will be populated again correctly.

vhvb1989 avatar Apr 12 '23 17:04 vhvb1989

for me, added me Search Service Contributor as role in the search service. and then run azd up again and it worked.

JahvoTrust avatar Apr 17 '23 01:04 JahvoTrust

Same here. I have full admin permission of my own demo subscription. I can see the stack trace error when the script is executing command: azd auth token --output json --scope https://search.azure.com/.default --tenant-id {tenant-id}. When I execute this command using same venv environment it returns without error. I am not sure why it fails in the script.

rexpie avatar Apr 23 '23 00:04 rexpie

Same here. I have full admin permission of my own demo subscription. I can see the stack trace error when the script is executing command: azd auth token --output json --scope https://search.azure.com/.default --tenant-id {tenant-id}. When I execute this command using same venv environment it returns without error. I am not sure why it fails in the script.

Resolved by forcing the environment proxy and recreate entire project using a different name.

jiabinxia-sanofi avatar Apr 24 '23 04:04 jiabinxia-sanofi

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this issue will be closed.

github-actions[bot] avatar Jan 01 '24 01:01 github-actions[bot]