This guide provides step-by-step instructions for provisioning Azure AI services and Azure AI Foundry resources, configuring environment variables, installing Python & Node.js dependencies, and running both the backend and frontend applications.
- Python: 3.10 or higher (python.org)
- Node.js: 18.0 or higher with
npm(nodejs.org) - Azure Subscription: Active Azure account (Azure for Students, Free Trial, or Pay-As-You-Go)
- Azure CLI: Installed and authenticated (
az login)
You will need to create the following 4 primary resource components in the Azure Portal and Azure AI Foundry:
- Create a Storage Account in your resource group.
- Under Data storage, create a Container named
pdf-uploads(Access level: Private). - Copy your Storage Account Connection String from Access keys.
- Create an Azure AI Document Intelligence resource.
- Select the Standard S0 Tier for high-throughput OCR text extraction without free-tier page processing limits.
- Copy the Endpoint URL and API Key 1 from Keys and Endpoint.
- Open the Azure AI Foundry Portal (Azure AI Studio).
- Create or connect your Azure OpenAI workspace.
- Deploy the Chat Model:
- Model:
gpt-4.1-mini(orgpt-4o-mini) - Deployment Name:
gpt-4.1-mini
- Model:
- Deploy the Embedding Model:
- Model:
text-embedding-3-small - Deployment Name:
text-embedding-3-small
- Model:
- Copy your workspace Endpoint URL, API Key, and API Version (e.g.
2024-08-01-preview).
- Create an Azure AI Search resource (F0 Free tier or Basic/Standard).
- Copy the Url Endpoint and Primary Admin Key from Keys.
Create a .env file in the project root directory by copying .env.example:
cp .env.example .envOpen .env in your editor and enter your Azure resource values:
# Azure Blob Storage
AZURE_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=core.windows.net
AZURE_STORAGE_CONTAINER_NAME=pdf-uploads
# Azure Document Intelligence (Standard S0 Tier)
AZURE_DOCUMENT_INTELLIGENCE_ENDPOINT=https://<your-doc-intel-name>.cognitiveservices.azure.com/
AZURE_DOCUMENT_INTELLIGENCE_KEY=your_azure_doc_intel_key
# Azure AI Foundry / Azure OpenAI
AZURE_OPENAI_ENDPOINT=https://<your-foundry-resource-name>.openai.azure.com/
AZURE_OPENAI_KEY=your_azure_foundry_key
AZURE_OPENAI_API_VERSION=2024-08-01-preview
AZURE_OPENAI_CHAT_DEPLOYMENT=gpt-4.1-mini
AZURE_OPENAI_EMBEDDING_DEPLOYMENT=text-embedding-3-small
# Azure AI Search
AZURE_SEARCH_ENDPOINT=https://<your-search-resource-name>.search.windows.net
AZURE_SEARCH_KEY=your_azure_search_admin_key
AZURE_SEARCH_INDEX_NAME=pdf-chat-index
# Backend URL
BACKEND_API_URL=http://localhost:8000Caution
Security Reminder: Never commit your .env file to source control. The .gitignore file is pre-configured to ignore .env.
From the project root directory:
# Create Python virtual environment
python3 -m venv venv
# Activate virtual environment
# On Linux/macOS:
source venv/bin/activate
# On Windows PowerShell:
.\venv\Scripts\Activate.ps1
# Upgrade pip and install dependencies
pip install --upgrade pip
pip install -r requirements.txtWith the virtual environment activated, start the backend server:
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000- Backend REST API:
http://localhost:8000 - Interactive Swagger Docs:
http://localhost:8000/docs - ReDoc Interactive Docs:
http://localhost:8000/redoc
(Upon backend startup, ensure_index_exists() automatically initializes the pdf-chat-index in Azure AI Search if it doesn't already exist).
Open a new terminal window:
# Navigate to frontend-react directory
cd DocSpring-RAG-Assistant/frontend-react
# Install Node modules
npm install
# Start Vite dev server
npm run dev- React Dashboard URL:
http://localhost:5173
If you wish to run the alternative Streamlit dashboard:
# From project root with virtual environment activated
streamlit run frontend-streamlit/app.py- Streamlit App URL:
http://localhost:8501
- Open
http://localhost:5173. - Click New Chat to initialize a new session.
- Drag & drop one or more PDF files into the upload dropzone. Check that files upload to Azure Blob Storage, extract text via Azure Document Intelligence (S0), and index 1536-dim embeddings via Azure AI Foundry into Azure AI Search.
- Submit a question in the chat bar. Verify that
gpt-4.1-minivia Azure AI Foundry returns an answer rendered with bold markdown section headings (Summary, Key points, Sources) and page-level citations across your uploaded PDFs.
- Cause: The storage container name specified in
.envdoes not exist or account connection string is invalid. - Fix: Verify
AZURE_STORAGE_CONTAINER_NAME=pdf-uploadsand ensure container permission is valid.
- Cause: The SAS URL expired or endpoint is incorrect.
- Fix: Check
AZURE_DOCUMENT_INTELLIGENCE_ENDPOINTandAZURE_DOCUMENT_INTELLIGENCE_KEYin.env. Ensure your Document Intelligence resource is active.
- Cause: Vector dimensions mismatch or deployment name typo.
- Fix: Ensure your Azure AI Foundry embedding deployment is named
text-embedding-3-small(1536 dims) and chat deployment is namedgpt-4.1-mini.