This sample demonstrates a few approaches for creating ChatGPT-like experiences over your own data using the Retrieval Augmented Generation pattern. It uses Azure OpenAI Service to access the ChatGPT model (gpt-4o-mini), and Azure AI Search for data indexing and retrieval.

The repo includes sample data so it's ready to try end to end. In this sample application we use a fictitious company called Contoso Real Estate, and the experience allows its customers to ask support questions about the usage of its products. The sample data includes a set of documents that describe its terms of service, privacy policy and a support guide.
The application is made from multiple components, including:


📺 Watch a video overview of the app
IMPORTANT: In order to deploy and run this sample, you'll need:
Microsoft.Authorization/roleAssignments/write permissions, such as Role Based Access Control Administrator, User Access Administrator, or Owner. If you don't have subscription-level permissions, they must be granted to you with RBAC for an existing resource group and deploy to that existing group.Microsoft.Resources/deployments/write permissions at a subscription level.Pricing may vary per region and usage. Exact costs cannot be estimated. You may try the Azure pricing calculator for the resources below.
⚠️ To avoid unnecessary costs, remember to take down your app if it's no longer in use,
either by deleting the resource group in the Portal or running azd down --purge.
There are multiple ways to successfully setup this project.
The easiest way to get started is with GitHub Codespaces that provides preconfigurations to setup all the tools for you. Read more below. Alternatively you can set up your local environment follwing the instructions below.
You can run this repo virtually by using GitHub Codespaces, which will open a web-based VS Code in your browser:
A similar option to Codespaces is VS Code Remote Containers, that will open the project in your local VS Code instance using the Dev Containers extension:
pwsh.exe from a PowerShell command. If this fails, you likely need to upgrade PowerShell.Then get the project code:
azd auth loginazd init -t azure-search-openai-javascriptExecute the following command, if you don't have any pre-existing Azure services and want to start from a fresh deployment.
azd up - This will provision Azure resources and deploy this sample to those resources, including building the search index based on the files found in the ./data folder.eastus2. You can set a different location with azd env set AZURE_OPENAI_RESOURCE_GROUP_LOCATION {location}. Currently only a short list of locations is accepted. That location list is based on the OpenAI model availability table and may become outdated as availability changes.eastus2. You can set a different location with azd env set AZURE_WEBAPP_LOCATION {location}. Currently only a short list of locations is accepted. Note that Static Web App is a global service, and the location you choose will only affect the managed Functions App which is not used in this sample.It will look like the following:

NOTE: It can take 15+ minutes for the application to be fully deployed.
If you already have existing Azure resources, you can re-use those by setting azd environment values.
azd env set AZURE_RESOURCE_GROUP {Name of existing resource group}azd env set AZURE_LOCATION {Location of existing resource group}azd env set AZURE_OPENAI_SERVICE {Name of existing OpenAI service}azd env set AZURE_OPENAI_RESOURCE_GROUP {Name of existing resource group that OpenAI service is provisioned to}azd env set AZURE_OPENAI_CHATGPT_DEPLOYMENT {Name of existing ChatGPT deployment}. Only needed if your ChatGPT deployment is not the default 'chat'.azd env set AZURE_OPENAI_EMBEDDING_DEPLOYMENT {Name of existing GPT embedding deployment}. Only needed if your embeddings deployment is not the default 'embedding'.azd env set AZURE_SEARCH_SERVICE {Name of existing Azure AI Search service}azd env set AZURE_SEARCH_SERVICE_RESOURCE_GROUP {Name of existing resource group with ACS service}azd up step,
then run azd env set AZURE_SEARCH_SERVICE_LOCATION {Location of existing service}azd env set AZURE_SEARCH_SERVICE_SKU {Name of SKU}. The free tier won't work as it doesn't support managed identity. (See other possible values)You can also use an existing Storage Account. See ./infra/main.parameters.json for list of environment variables to pass to azd env set to configure those existing resources.
Now you can run azd up, following the steps in Deploying from scratch above.
That will both provision resources and deploy the code.
If you've only changed the backend/frontend code in the app folder, then you don't need to re-provision the Azure resources. You can just run:
azd deploy
If you've changed the infrastructure files (infra folder or azure.yaml), then you'll need to re-provision the Azure resources. You can do that by running:
azd up
To give someone else access to a completely deployed and existing environment, either you or they can follow these steps:
azd init -t azure-search-openai-javascript or clone this repository.azd env refresh -e {environment name}
They will need the azd environment name, subscription ID, and location to run this command. You can find those values in your .azure/{env name}/.env file. This will populate their azd environment's .env file with all the settings needed to run the app locally.AZURE_PRINCIPAL_ID either in that .env file or in the active shell to their Azure ID, which they can get with az ad signed-in-user show../scripts/roles.ps1 or ./scripts/roles.sh to assign all of the necessary roles to the user. If they do not have the necessary permission to create roles in the subscription, then you may need to run this script for them. Once the script runs, they should be able to run the app locally.To clean up all the resources created by this sample:
$ claude mcp add azure-search-openai-javascript \
-- python -m otcore.mcp_server <graph>