Features, capabilities, or properties marked (preview) aren’t covered by a service-level agreement, aren’t recommended for production workloads, and might change or be constrained before they become generally available. The Azure AI Search preview terms apply to all preview functionality, whether it’s standalone or part of a generally available feature.
outputMode (preview) and retrievalReasoningEffort (preview) to explicitly specify extractive output and minimal reasoning, although equivalent behavior is generally available. The project connection uses RemoteTool (preview) and the project managed identity to authenticate to Azure AI Search.
Prerequisites
- Completion of Set up private inbound connectivity and Set up private outbound connectivity.
-
Owner,User Access Administrator, orRole Based Access Control Administratorat scopes where you assign roles to your user account. -
Foundry model deployments for
text-embedding-3-largeand a GPT-5 family model (such asgpt-5-turbo). The template used in part one deploys a GPT-5 family model, but it doesn’t deploytext-embedding-3-large. Deploytext-embedding-3-large, and then verify both deployments before you continue. For deployment instructions, see Deploy Microsoft Foundry Models in the Foundry portal. - Visual Studio Code with the REST Client extension.
- The same in-VNet client you used in part one, such as a jumpbox, VM, dev box, or Azure Bastion-connected workstation, connected to the private network path in your deployment and able to reach your private endpoints.
- The Foundry resource’s Allow Azure services on the trusted services list setting remains enabled. Part two explains why knowledge source ingestion still depends on this bypass for the embedding call.
Verify model deployments
Verify that your Foundry resource includes the deployments used later in this article.-
List the model deployments on the Foundry resource.
-
Confirm that
text-embedding-3-largeand a GPT-5 family model both appear with aSucceededstatus. If a GPT-5 family model isn’t deployed yet, deploy one before you create the agent later in this article.
Assign user account roles
Part two of the tutorial grants runtime access to Azure AI Search. In this section, you grant your user account the permissions needed to upload sample content, create agentic retrieval objects, configure the project connection, and run agent operations. To assign the roles to your user account:-
Get your account object ID to use as
<principal-object-id>in the following commands. -
Assign a role on the Azure Storage account scope.
Storage Blob Data Contributoris required to create the blob container and upload the sample content in the next section. -
Assign roles on the Azure AI Search service scope.
Search Service Contributoris required to manage the knowledge source and knowledge base.Search Index Data Contributoris required for knowledge base retrieval during validation. -
Assign roles on the Foundry resource scope.
Foundry Project Manageris required to create the project connection.Foundry Useris required to create the agent and run the validation conversation in the Foundry project.
The Foundry RBAC roles were recently renamed. Foundry User, Foundry Owner, Foundry Account Owner, and Foundry Project Manager were previously named Azure AI User, Azure AI Owner, Azure AI Account Owner, and Azure AI Project Manager. You might still see the previous names in some places while the rename rolls out. The role IDs and core permissions are unchanged by the rename.
-
Verify role assignments.
You should see
Search Service Contributor,Search Index Data Contributor,Foundry Project Manager,Foundry User, andStorage Blob Data Contributorat the expected scopes.
Upload sample content
Upload sample JSON documents to a container in Azure Blob Storage. The validation prompt later in this article grounds its answers in this blob content, so the documents must be in place before the knowledge source ingests them.Run the commands and REST calls in the rest of this article from your in-VNet client. Several steps reach private endpoints on Azure Blob Storage, Azure AI Search, and Foundry, including the upload commands in this section. Because part one disables public network access on these services, these steps succeed only over the private network path.
-
Download the sample JSON documents to your in-VNet client.
-
Create the
earth-at-night-jsonblob container. -
Split the sample file into one blob per record.
The downloaded sample stores all records in one
documents.jsonfile. Uploading that file as a single blob can delay or stall ingestion, so split it before you upload.If Python isn’t available on your in-VNet client, use another JSON-aware tool to create one blob per record before you continue. -
Upload the split sample documents to the container.
-
Verify that the documents uploaded successfully.
The output lists the JSON files from the Earth at Night sample set. These per-record blobs become the private content that the knowledge source ingests in the next section.
Create a knowledge source and knowledge base
In Azure AI Search, agentic retrieval involves two objects: a knowledge source and a knowledge base. This section creates a blob knowledge source, which generates an ingestion pipeline that chunks your private blob content, uses your deployedtext-embedding-3-large model for vectorization, and stores the enriched content in a search index. The knowledge base then orchestrates retrieval from the knowledge source and exposes results through an MCP endpoint, which becomes the target that the agent calls in a later section.
To create the knowledge source and knowledge base:
-
Get an Azure AI Search bearer token to use as
<search-access-token>in the following requests. -
Open Visual Studio Code and create a file named
private-agentic-retrieval.rest. -
Create a blob knowledge source.
-
Create a knowledge base that references the knowledge source.
-
Confirm the knowledge source was created successfully.
This request should return HTTP 200. The response payload should include
"name": "ks-private-retrieval". -
Confirm the knowledge base was created successfully.
This request should return HTTP 200. The response payload should include
"name": "kb-private-retrieval"and list"name": "ks-private-retrieval"underknowledgeSources.
Creating the knowledge source starts asynchronous ingestion of your blob content. First-time ingestion can take several minutes to complete. Re-run the knowledge source and knowledge base
GET requests in this section before you create the agent, and confirm they still return HTTP 200. If you run the validation prompt too early, the response can fail before citations appear. Wait 30 to 60 seconds, and then retry. If ingestion stalls, verify that you uploaded split per-record blobs instead of a single large documents.json file, and confirm that the Foundry trusted-service bypass described in part two is still enabled.Create a project connection
Register the knowledge base MCP endpoint as aRemoteTool project connection (preview) in Foundry. This connection lets the agent call the MCP endpoint by using the project managed identity instead of embedded secrets. When you finish this section, you have a reusable connection name that the agent definition references.
To create the project connection:
-
Get an Azure Resource Manager token to use as
<management-access-token>in the following requests. -
Get your project resource ID to use as
<project-resource-id>in the following requests. -
Create the project connection by using Azure Resource Manager.
-
Confirm the connection was created.
This request returns HTTP 200. Verify
authTypeisProjectManagedIdentity,targetmatches your knowledge base MCP URL, andnameisconn-kb-private-retrieval. You must grantProjectManagedIdentityauthorization to your Azure AI Search service by assigning the Search Index Data Reader role and, if write access is needed, the Search Index Data Contributor role. For help, see Create a project connection.
Create an agent and validate citations
Create an agent that uses the project connection to call the knowledge base MCP tool, and then run a validation prompt through a conversation. The goal is to confirm end-to-end retrieval behavior: the agent answers from private content and returns grounded citations instead of relying on general model knowledge. To create the agent and validate citations:-
Get a Foundry access token to use as
<foundry-access-token>in the following requests. -
Get your project endpoint to use as
<project-endpoint>in the following requests. -
Create a prompt agent that uses your MCP connection.
-
Create a conversation, and then copy the
idvalue from the response to use as<conversation-id>in the next step. -
Run a validation prompt through the agent.
Expected result:
- The agent returns an answer that’s grounded in your uploaded blob content.
- The response includes citations that reference the Earth at Night source content.
- The request succeeds from your private network client by using the same private path configured in parts one and two.
Troubleshooting
Use the following table to isolate failures in the retrieval-validation flow.Clean up resources
When you work in your own subscription, it’s a good idea to finish a project by removing the resources you no longer need. Resources that are left running can cost you money. This tutorial used a dedicated resource group namedrg-private-retrieval. If you no longer need the resource group, delete it: