Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ STORAGE_KEY=your-storage-key
STORAGE_CONTAINER=your-container
STORAGE_FOLDER=your-folder

# ── Azure OpenAI (for EmbeddingSkillNotebook & embedding skills) ─────
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_API_KEY=your-azure-openai-api-key
AZURE_OPENAI_DEPLOYMENT=text-embedding-3-small

# Entra ID / Azure AD bearer token (for entra-id-auth-requests.http)
# Obtain via: az account get-access-token --resource https://search.azure.com --query accessToken -o tsv
ENTRA_TOKEN=
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- **Embedding notebook: `.env`-based configuration**: Azure OpenAI credentials (`AZURE_OPENAI_ENDPOINT`, `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_DEPLOYMENT`) are now loaded from the workspace root `.env` file via `python-dotenv` instead of being hardcoded in the notebook. Updated `.env.example`, `requirements.txt`, and README accordingly.

### Added

- **README: pre-built Docker image instructions**: Updated the README to document how to pull and run the pre-built image from `ghcr.io` (with `docker run` and `docker-compose` examples) and added a tag reference table.
- Cleaned Notebook from previous run.

Expand Down
40 changes: 20 additions & 20 deletions samples/AzureSearchNotebook/azure_search_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1071,32 +1071,32 @@
"# Uncomment to delete all resources created in this notebook\n",
"\n",
"# Delete indexer\n",
"# try:\n",
"# indexer_client.delete_indexer(INDEXER_NAME)\n",
"# print(f\"πŸ—‘οΈ Deleted indexer '{INDEXER_NAME}'\")\n",
"# except Exception as e:\n",
"# print(f\"⚠️ Could not delete indexer: {e}\")\n",
"try:\n",
" indexer_client.delete_indexer(INDEXER_NAME)\n",
" print(f\"πŸ—‘οΈ Deleted indexer '{INDEXER_NAME}'\")\n",
"except Exception as e:\n",
" print(f\"⚠️ Could not delete indexer: {e}\")\n",
"\n",
"# Delete skillset\n",
"# try:\n",
"# indexer_client.delete_skillset(SKILLSET_NAME)\n",
"# print(f\"πŸ—‘οΈ Deleted skillset '{SKILLSET_NAME}'\")\n",
"# except Exception as e:\n",
"# print(f\"⚠️ Could not delete skillset: {e}\")\n",
"try:\n",
" indexer_client.delete_skillset(SKILLSET_NAME)\n",
" print(f\"πŸ—‘οΈ Deleted skillset '{SKILLSET_NAME}'\")\n",
"except Exception as e:\n",
" print(f\"⚠️ Could not delete skillset: {e}\")\n",
"\n",
"# Delete data source\n",
"# try:\n",
"# indexer_client.delete_data_source_connection(DATA_SOURCE_NAME)\n",
"# print(f\"πŸ—‘οΈ Deleted data source '{DATA_SOURCE_NAME}'\")\n",
"# except Exception as e:\n",
"# print(f\"⚠️ Could not delete data source: {e}\")\n",
"try:\n",
" indexer_client.delete_data_source_connection(DATA_SOURCE_NAME)\n",
" print(f\"πŸ—‘οΈ Deleted data source '{DATA_SOURCE_NAME}'\")\n",
"except Exception as e:\n",
" print(f\"⚠️ Could not delete data source: {e}\")\n",
"\n",
"# Delete index\n",
"# try:\n",
"# index_client.delete_index(INDEX_NAME)\n",
"# print(f\"πŸ—‘οΈ Deleted index '{INDEX_NAME}'\")\n",
"# except Exception as e:\n",
"# print(f\"⚠️ Could not delete index: {e}\")\n",
"try:\n",
" index_client.delete_index(INDEX_NAME)\n",
" print(f\"πŸ—‘οΈ Deleted index '{INDEX_NAME}'\")\n",
"except Exception as e:\n",
" print(f\"⚠️ Could not delete index: {e}\")\n",
"\n",
"print(\"πŸ’‘ Uncomment the code above to clean up resources\")"
]
Expand Down
42 changes: 20 additions & 22 deletions samples/EmbeddingSkillNotebook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,29 +24,33 @@ The data is located at `../IndexerTestNotebook/data/`

## Prerequisites

### 1. Start the Azure AI Search Simulator
### 1. Configure Azure OpenAI credentials

Copy the workspace root `.env.example` to `.env` and fill in your Azure OpenAI values:

```bash
cd src/AzureAISearchSimulator.Api
dotnet run --urls "https://localhost:7250"
cp .env.example .env
```

> ⚠️ **Important**: The Azure SDK requires HTTPS. Make sure to use the `--urls` parameter.
Then edit `.env` and set:

### 2. Configure Azure OpenAI
```dotenv
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
AZURE_OPENAI_API_KEY=your-api-key
AZURE_OPENAI_DEPLOYMENT=text-embedding-3-small
```

> The notebook loads these variables automatically via `python-dotenv`. The `.env` file is gitignored.

Update `src/AzureAISearchSimulator.Api/appsettings.json` with your Azure OpenAI credentials:
### 2. Start the Azure AI Search Simulator

```json
{
"AzureOpenAI": {
"Endpoint": "https://your-resource.openai.azure.com",
"ApiKey": "your-api-key",
"EmbeddingDeployment": "text-embedding-ada-002"
}
}
```bash
cd src/AzureAISearchSimulator.Api
dotnet run --urls "https://localhost:7250"
```

> ⚠️ **Important**: The Azure SDK requires HTTPS. Make sure to use the `--urls` parameter.

### 3. Install Python Dependencies

```bash
Expand All @@ -56,7 +60,7 @@ pip install -r requirements.txt
Or install manually:

```bash
pip install azure-search-documents requests pandas numpy jupyter ipykernel
pip install azure-search-documents requests pandas numpy python-dotenv jupyter ipykernel
```

## Running the Notebook
Expand All @@ -69,13 +73,7 @@ pip install azure-search-documents requests pandas numpy jupyter ipykernel

2. Open `embedding_skill_demo.ipynb`

3. Update the Azure OpenAI configuration in cell 2:

```python
AZURE_OPENAI_ENDPOINT = "https://your-resource.openai.azure.com"
AZURE_OPENAI_DEPLOYMENT = "text-embedding-ada-002"
AZURE_OPENAI_API_KEY = "YOUR-AZURE-OPENAI-API-KEY-HERE"
```
3. Make sure your `.env` file is configured (see Prerequisites above)

4. Run all cells sequentially

Expand Down
71 changes: 43 additions & 28 deletions samples/EmbeddingSkillNotebook/embedding_skill_demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,23 @@
"\n",
"## Prerequisites\n",
"\n",
"1. **Start the Azure AI Search Simulator with HTTPS**:\n",
"1. **Configure your `.env` file** in the workspace root:\n",
"\n",
" ```bash\n",
" cd src/AzureAISearchSimulator.Api\n",
" dotnet run --urls \"https://localhost:7250\"\n",
" cp .env.example .env\n",
" ```\n",
" Then fill in the Azure OpenAI variables:\n",
" ```dotenv\n",
" AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com\n",
" AZURE_OPENAI_API_KEY=your-api-key\n",
" AZURE_OPENAI_DEPLOYMENT=text-embedding-3-small\n",
" ```\n",
"\n",
"2. **Start the Azure AI Search Simulator with HTTPS**:\n",
"\n",
"2. **Configure Azure OpenAI** in `appsettings.json`:\n",
" ```json\n",
" {\n",
" \"AzureOpenAI\": {\n",
" \"Endpoint\": \"https://your-resource.openai.azure.com\",\n",
" \"ApiKey\": \"your-api-key\",\n",
" \"EmbeddingDeployment\": \"text-embedding-ada-002\"\n",
" }\n",
" }\n",
" ```bash\n",
" cd src/AzureAISearchSimulator.Api\n",
" dotnet run --urls \"https://localhost:7250\"\n",
" ```\n",
"\n",
"3. **Sample data files** are located in `../IndexerTestNotebook/data`\n",
Expand All @@ -57,14 +59,15 @@
"outputs": [],
"source": [
"# Install required packages (uncomment if needed)\n",
"# !pip install azure-search-documents requests pandas numpy\n",
"# !pip install azure-search-documents requests pandas numpy python-dotenv\n",
"\n",
"import os\n",
"import json\n",
"import time\n",
"import urllib3\n",
"import numpy as np\n",
"from pathlib import Path\n",
"from dotenv import load_dotenv\n",
"\n",
"# Azure AI Search SDK imports\n",
"from azure.core.credentials import AzureKeyCredential\n",
Expand Down Expand Up @@ -98,6 +101,15 @@
"# Suppress SSL warnings for local development\n",
"urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)\n",
"\n",
"# Load environment variables from workspace root .env file\n",
"env_path = Path(\"../../.env\")\n",
"if env_path.exists():\n",
" load_dotenv(dotenv_path=env_path)\n",
" print(f\"βœ… Loaded .env from {env_path.resolve()}\")\n",
"else:\n",
" print(f\"⚠️ No .env file found at {env_path.resolve()}\")\n",
" print(\" Copy .env.example to .env in the workspace root and fill in your values.\")\n",
"\n",
"print(\"βœ… Libraries imported successfully!\")"
]
},
Expand All @@ -119,18 +131,19 @@
"outputs": [],
"source": [
"# Configuration for Azure AI Search Simulator\n",
"SEARCH_ENDPOINT = \"https://localhost:7250\"\n",
"ADMIN_API_KEY = \"admin-key-12345\"\n",
"# Values are loaded from the workspace root .env file (see .env.example)\n",
"SEARCH_ENDPOINT = os.getenv(\"BASE_URL\", \"https://localhost:7250\")\n",
"ADMIN_API_KEY = os.getenv(\"ADMIN_KEY\", \"admin-key-12345\")\n",
"\n",
"# Azure OpenAI Configuration (update with your values)\n",
"# The simulator will use these when calling Azure OpenAI for embeddings\n",
"AZURE_OPENAI_ENDPOINT = \"https://your-open-ai-url.cognitiveservices.azure.com\" # Update this\n",
"AZURE_OPENAI_DEPLOYMENT = \"text-embedding-3-small\" # Or your deployment name\n",
"# Azure OpenAI Configuration (from .env)\n",
"AZURE_OPENAI_ENDPOINT = os.getenv(\"AZURE_OPENAI_ENDPOINT\", \"\")\n",
"AZURE_OPENAI_DEPLOYMENT = os.getenv(\"AZURE_OPENAI_DEPLOYMENT\", \"text-embedding-3-small\")\n",
"AZURE_OPENAI_API_KEY = os.getenv(\"AZURE_OPENAI_API_KEY\", \"\")\n",
"\n",
"# ⚠️ IMPORTANT: Set your Azure OpenAI API key here\n",
"# Get it from: Azure Portal β†’ Your Azure OpenAI/AI Services resource β†’ Keys and Endpoint\n",
"# AZURE_OPENAI_API_KEY = \"YOUR-AZURE-OPENAI-API-KEY-HERE\" # <-- UPDATE THIS!\n",
"AZURE_OPENAI_API_KEY = \"YOUR-AZURE-OPENAI-API-KEY-HERE\" # <-- UPDATE THIS!\n",
"if not AZURE_OPENAI_ENDPOINT or not AZURE_OPENAI_API_KEY:\n",
" print(\"⚠️ WARNING: AZURE_OPENAI_ENDPOINT and/or AZURE_OPENAI_API_KEY are not set!\")\n",
" print(\" Copy .env.example to .env in the workspace root and fill in your Azure OpenAI values.\")\n",
" print(\" Required variables: AZURE_OPENAI_ENDPOINT, AZURE_OPENAI_API_KEY\")\n",
"\n",
"# Resource names for this demo\n",
"INDEX_NAME = \"embedding-demo-docs\"\n",
Expand Down Expand Up @@ -171,6 +184,8 @@
")\n",
"\n",
"print(f\"βœ… Connected to Azure AI Search Simulator at {SEARCH_ENDPOINT}\")\n",
"print(f\"πŸ”‘ Azure OpenAI endpoint: {AZURE_OPENAI_ENDPOINT}\")\n",
"print(f\"🧠 Embedding deployment: {AZURE_OPENAI_DEPLOYMENT}\")\n",
"print(f\"πŸ“ Data path: {DATA_PATH}\")\n",
"\n",
"# List sample data files\n",
Expand Down Expand Up @@ -362,7 +377,7 @@
"\n",
"Configure a skillset that uses Azure OpenAI to generate embeddings for the document content.\n",
"\n",
"> **Note**: The simulator forwards embedding requests to Azure OpenAI. Make sure your Azure OpenAI credentials are configured in `appsettings.json`."
"> **Note**: The Azure OpenAI credentials are loaded from the workspace root `.env` file. Make sure `AZURE_OPENAI_ENDPOINT`, `AZURE_OPENAI_API_KEY`, and `AZURE_OPENAI_DEPLOYMENT` are set."
]
},
{
Expand All @@ -376,9 +391,9 @@
"# The Azure SDK doesn't have direct support for AzureOpenAIEmbeddingSkill,\n",
"# so we'll use the REST API directly\n",
"\n",
"if AZURE_OPENAI_API_KEY == \"YOUR-AZURE-OPENAI-API-KEY-HERE\":\n",
" print(\"⚠️ WARNING: You need to set AZURE_OPENAI_API_KEY above!\")\n",
" print(\" Get your key from Azure Portal β†’ Your Azure OpenAI resource β†’ Keys and Endpoint\")\n",
"if not AZURE_OPENAI_API_KEY or not AZURE_OPENAI_ENDPOINT:\n",
" print(\"⚠️ WARNING: Azure OpenAI credentials are not configured in .env!\")\n",
" print(\" Set AZURE_OPENAI_ENDPOINT and AZURE_OPENAI_API_KEY in the workspace root .env file.\")\n",
"\n",
"skillset_payload = {\n",
" \"name\": SKILLSET_NAME,\n",
Expand All @@ -391,7 +406,7 @@
" \"context\": \"/document\",\n",
" \"resourceUri\": AZURE_OPENAI_ENDPOINT,\n",
" \"deploymentId\": AZURE_OPENAI_DEPLOYMENT,\n",
" \"apiKey\": AZURE_OPENAI_API_KEY, # API key passed directly to skillset\n",
" \"apiKey\": AZURE_OPENAI_API_KEY, # API key loaded from .env\n",
" \"modelName\": \"text-embedding-3-small\",\n",
" \"inputs\": [\n",
" {\n",
Expand Down
3 changes: 3 additions & 0 deletions samples/EmbeddingSkillNotebook/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ requests>=2.31.0
pandas>=2.0.0
numpy>=1.24.0

# Environment variable loading
python-dotenv>=1.0.0

# Jupyter notebook support
jupyter>=1.0.0
ipykernel>=6.0.0
Loading