Azure AI Foundry & Azure AI Search - Failed to upload documents to ACS index 'Forbidden'

Dushyant Priyadarshee 161 Reputation points
2025-06-16T21:49:32.8733333+00:00

Following the tutorial - https://learn.microsoft.com/en-us/azure/ai-foundry/tutorials/deploy-chat-web-app

Even though I have performed all the required role assignments, I keep getting the following error at Add your data and try the chat model again section.

[2025-06-16 20:34:11] ERROR    azureml.rag.azureml.rag.embeddings - Failed to upload documents to ACS index due to: Operation returned an invalid status 'Forbidden' (__init__.py:1202)
Traceback (most recent call last):
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/embeddings/__init__.py", line 1156, in upload_to_index
    index_store.upload_documents(batch)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/indexes/index_stores.py", line 147, in upload_documents
    results = self._search_client.upload_documents(documents)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/search/documents/_search_client.py", line 548, in upload_documents
    results = self.index_documents(batch, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/core/tracing/decorator.py", line 94, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/search/documents/_search_client.py", line 647, in index_documents
    return self._index_documents_actions(actions=batch.actions, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/search/documents/_search_client.py", line 655, in _index_documents_actions
    batch_response = self._client.documents.index(batch=batch, error_map=error_map, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/core/tracing/decorator.py", line 94, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/search/documents/_generated/operations/_documents_operations.py", line 1202, in index
    raise HttpResponseError(response=response, model=error)
azure.core.exceptions.HttpResponseError: Operation returned an invalid status 'Forbidden'
[2025-06-16 20:34:11] ERROR    azureml.rag.update_acs.update_acs - ActivityCompleted: Activity=update_acs, HowEnded=Failure, Duration=7239.85 [ms], Exception=HttpResponseError (activity.py:127)
[2025-06-16 20:34:11] ERROR    azureml.rag.update_acs - Failed to update ACS index (update_acs.py:429)
[2025-06-16 20:34:12] ERROR    azureml.rag.update_acs.update_acs - ServiceError: intepreted error = Rag system error, original error = Operation returned an invalid status 'Forbidden' (exceptions.py:124)
[2025-06-16 20:34:17] ERROR    azureml.rag.update_acs.update_acs - update_acs failed with exception: Traceback (most recent call last):
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/tasks/update_acs.py", line 465, in main_wrapper
    map_exceptions(main, activity_logger, args, logger, activity_logger)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/utils/exceptions.py", line 126, in map_exceptions
    raise e
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/utils/exceptions.py", line 118, in map_exceptions
    return func(*func_args, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/tasks/update_acs.py", line 456, in main
    raise e
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/tasks/update_acs.py", line 420, in main
    create_index_from_raw_embeddings(
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/tasks/update_acs.py", line 336, in create_index_from_raw_embeddings
    emb.upload_to_index(
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/embeddings/__init__.py", line 1156, in upload_to_index
    index_store.upload_documents(batch)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/indexes/index_stores.py", line 147, in upload_documents
    results = self._search_client.upload_documents(documents)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/search/documents/_search_client.py", line 548, in upload_documents
    results = self.index_documents(batch, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/core/tracing/decorator.py", line 94, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/search/documents/_search_client.py", line 647, in index_documents
    return self._index_documents_actions(actions=batch.actions, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/search/documents/_search_client.py", line 655, in _index_documents_actions
    batch_response = self._client.documents.index(batch=batch, error_map=error_map, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/core/tracing/decorator.py", line 94, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/search/documents/_generated/operations/_documents_operations.py", line 1202, in index
    raise HttpResponseError(response=response, model=error)
azure.core.exceptions.HttpResponseError: Operation returned an invalid status 'Forbidden'
 (update_acs.py:467)
[2025-06-16 20:34:17] ERROR    azureml.rag.update_acs.update_acs - ActivityCompleted: Activity=update_acs, HowEnded=Failure, Duration=14369.32 [ms], Exception=HttpResponseError (activity.py:127)
Traceback (most recent call last):
  File "/azureml-envs/rag-embeddings/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/azureml-envs/rag-embeddings/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/tasks/update_acs.py", line 499, in <module>
    main_wrapper(args, logger)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/tasks/update_acs.py", line 465, in main_wrapper
    map_exceptions(main, activity_logger, args, logger, activity_logger)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/utils/exceptions.py", line 126, in map_exceptions
    raise e
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/utils/exceptions.py", line 118, in map_exceptions
    return func(*func_args, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/tasks/update_acs.py", line 456, in main
    raise e
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/tasks/update_acs.py", line 420, in main
    create_index_from_raw_embeddings(
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/tasks/update_acs.py", line 336, in create_index_from_raw_embeddings
    emb.upload_to_index(
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/embeddings/__init__.py", line 1156, in upload_to_index
    index_store.upload_documents(batch)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azureml/rag/indexes/index_stores.py", line 147, in upload_documents
    results = self._search_client.upload_documents(documents)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/search/documents/_search_client.py", line 548, in upload_documents
    results = self.index_documents(batch, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/core/tracing/decorator.py", line 94, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/search/documents/_search_client.py", line 647, in index_documents
    return self._index_documents_actions(actions=batch.actions, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/search/documents/_search_client.py", line 655, in _index_documents_actions
    batch_response = self._client.documents.index(batch=batch, error_map=error_map, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/core/tracing/decorator.py", line 94, in wrapper_use_tracer
    return func(*args, **kwargs)
  File "/azureml-envs/rag-embeddings/lib/python3.9/site-packages/azure/search/documents/_generated/operations/_documents_operations.py", line 1202, in index
    raise HttpResponseError(response=response, model=error)
azure.core.exceptions.HttpResponseError: Operation returned an invalid status 'Forbidden'


If I change the connection to use primary key of Azure Search, it works.

Anyone else seen this issue? How did you solve it?

Azure AI Search
Azure AI Search
An Azure search service with built-in artificial intelligence capabilities that enrich information to help identify and explore relevant content at scale.
1,339 questions
{count} votes

Accepted answer
  1. JAYA SHANKAR G S 4,035 Reputation points Microsoft External Staff Moderator
    2025-06-18T09:12:48+00:00

    Hello @Dushyant Priyadarshee ,

    The error is because of roles assignment or access control for search service, here are the things you can check.

    I believe in your hub project, the ai search connection you set to AAD(Microsoft Entra ID) authentication like below, if not please add details like where you enabled managed identity while adding data source in chat playground.

    enter image description here

    Next, you set the access control in search service to both like below.

    enter image description here

    Additionally you need to add roles to yourself, below are the details.

    Resource Role Assignee Description
    Azure AI Search Search Services Contributor Developer's Microsoft Entra ID List API-Keys to list indexes from Azure AI Foundry portal.
    Azure AI Search Search Services Contributor Developer's Microsoft Entra ID List API-Keys to list indexes from Azure AI Foundry portal.
    Azure AI Search Search Index Data Contributor Developer's Microsoft Entra ID Required for the indexing scenario.
    Azure AI services/OpenAI Cognitive Services OpenAI Contributor Developer's Microsoft Entra ID Call public ingestion API from Azure AI Foundry portal.
    Azure AI services/OpenAI Cognitive Services Contributor Developer's Microsoft Entra ID List API-Keys from Azure AI Foundry portal.
    Azure AI services/OpenAI Contributor Developer's Microsoft Entra ID Allows for calls to the control plane.
    Azure Storage Account Contributor Developer's Microsoft Entra ID List Account SAS to upload files from Azure AI Foundry portal.
    Azure Storage Account Storage Blob Data Contributor Developer's Microsoft Entra ID Needed for developers to read and write to blob storage.
    Azure Storage Account Storage File Data Privileged Contributor Developer's Microsoft Entra ID Needed to Access File Share in Storage for Promptflow data.
    The resource group or Azure subscription where the developer need to deploy the web app to Contributor Developer's Microsoft Entra ID Deploy web app to the developer's Azure subscription.

    After assigning this roles try to add data source, i can confirm from my end it is working fine after following above steps along with assigning roles to Azure OpenAI managed identity.

    Do let us know if you face any error or query in comments.

    Thank you


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.