Azure-Samples/jp-azureopenai-samples

5.internal-document-search `Authorization failed`

Opened this issue · 1 comments

Please provide us with the following information:

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

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

Error that occurs when running adz up on Dev Container

azd up

Any log messages given by the failure

Running "prepdocs.py"
Ensuring search index gptkbindex exists
Creating gptkbindex search index
Traceback (most recent call last):
  File "/workspaces/jp-azureopenai-samples/5.internal-document-search/./scripts/prepdocs.py", line 305, in <module>
    create_search_index()
  File "/workspaces/jp-azureopenai-samples/5.internal-document-search/./scripts/prepdocs.py", line 260, in create_search_index
    index_client.create_index(index)
  File "/workspaces/jp-azureopenai-samples/5.internal-document-search/scripts/.venv/lib/python3.11/site-packages/azure/core/tracing/decorator.py", line 78, in wrapper_use_tracer
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/jp-azureopenai-samples/5.internal-document-search/scripts/.venv/lib/python3.11/site-packages/azure/search/documents/indexes/_search_index_client.py", line 211, in create_index
    result = self._client.indexes.create(patched_index, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/jp-azureopenai-samples/5.internal-document-search/scripts/.venv/lib/python3.11/site-packages/azure/core/tracing/decorator.py", line 78, in wrapper_use_tracer
    return func(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/workspaces/jp-azureopenai-samples/5.internal-document-search/scripts/.venv/lib/python3.11/site-packages/azure/search/documents/indexes/_generated/operations/_indexes_operations.py", line 403, in create
    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 code: 1

Expected/desired behavior

Expect azd up to complete successfully

OS and Version?

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

  • macOS 14.2.1

Versions

  • VS Code Version: 1.85.2
  • Dev Container Version: v0.327.0
  • Docker Version: 24.0.7

Mention any other details that might be useful

This will occur by executing the procedure in README.md as a user with Microsoft Authorization/roleAssignments/write privileges on the Dev container

→ az role assignment list --assignee akira@xxxxxxxxxx.com --subscription aaa1088f-xxxxx-xxxxx-xxxxxxxxxx --output table
Principal                          Role                                      Scope
----------------------- -------------------------  ---------------------------------------------------
akira@xxxxxxxxxx.com  User Access Administrator  /subscriptions/aaa1088f-xxxx-xxxx-xxxx-xxxxxxxxxx

Similar Issue Azure-Samples/azure-search-openai-demo#17


The same error occurred in my environment.
In my case, the problem was resolved by granting permissions to the resource group.