Srikaran Tirukovela
Srikaran Tirukovela

Reputation: 1

"azure-search-openai-demo" File upload feature is not working after enabling the settings

File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1510, in request return await self._request( ^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/openai/_base_client.py", line 1611, in _request raise self._make_status_error_from_response(err.response) from None openai.AuthenticationError: Error code: 401 - {'statusCode': 401, 'message': 'Unauthorized. Access token is missing, invalid, audience is incorrect (https://cognitiveservices.azure.com), or have expired.'}

followed the exact steps in documentation provided by the git repo for the upload feature.

commands which i followed :-

azd env set AZURE_USE_AUTHENTICATION true
python ./scripts/manageacl.py --acl-action enable_acls
azd env set AZURE_ENFORCE_ACCESS_CONTROL true
azd env set AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS true
azd env set AZURE_ENABLE_UNAUTHENTICATED_ACCESS true
azd env set AZURE_ENABLE_GLOBAL_DOCUMENT_ACCESS true
azd env set USE_USER_UPLOAD true

Upvotes: 0

Views: 97

Answers (1)

Nicolas R
Nicolas R

Reputation: 14619

This part of the error is quite clear:

openai.AuthenticationError: Error code: 401 - {'statusCode': 401, 'message': 'Unauthorized. Access token is missing, invalid, audience is incorrect (https://cognitiveservices.azure.com), or have expired.'}

You are trying to call your Azure OpenAI request without authentication details. If you check the demo code (here) you will see that the behavior is the following:

  • if you provided an Azure OpenAI API key (in AZURE_OPENAI_API_KEY_OVERRIDE setting), it is using it for authentication
  • if not, then it tries to authenticate using credentials: in that case, the account that it will use needs to have permissions on the Azure OpenAI resource. A good permission is "Cognitive Services OpenAI User", which allows to consume models

Upvotes: 1

Related Questions