Skip to content

Commit 76eafd9

Browse files
diberryCopilot
andcommitted
Add Azure SQL vector search TypeScript quickstart sample
Add a complete TypeScript sample demonstrating vector search with Azure SQL Database: - Azure OpenAI text-embedding-3-small for generating embeddings - VECTOR_DISTANCE for similarity search with DiskANN index - Azure Identity (DefaultAzureCredential) for passwordless auth - Bicep infrastructure for Azure SQL + OpenAI provisioning - CI workflow for build validation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent b1ff6e6 commit 76eafd9

23 files changed

Lines changed: 100475 additions & 0 deletions
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# CI for the Azure SQL Vector Search TypeScript quickstart sample.
2+
# Security: uses `pull_request` (read-only token, no secrets on forks)
3+
# with an explicit same-repo check to skip fork PRs entirely.
4+
5+
name: "Vector Search TypeScript — Build"
6+
7+
on:
8+
pull_request:
9+
branches: [master]
10+
paths:
11+
- "samples/features/vector-search/vector-search-query-typescript/**"
12+
push:
13+
branches: [master]
14+
paths:
15+
- "samples/features/vector-search/vector-search-query-typescript/**"
16+
17+
# Cancel redundant runs for the same PR / branch.
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
20+
cancel-in-progress: true
21+
22+
permissions:
23+
contents: read
24+
25+
jobs:
26+
build:
27+
name: Build & type-check
28+
runs-on: ubuntu-latest
29+
timeout-minutes: 10
30+
31+
# Skip CI on fork PRs — prevents external actors from consuming minutes.
32+
if: >-
33+
github.event_name == 'push' ||
34+
github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name
35+
36+
defaults:
37+
run:
38+
working-directory: samples/features/vector-search/vector-search-query-typescript
39+
40+
steps:
41+
- name: Checkout
42+
uses: actions/checkout@v6
43+
44+
- name: Setup Node.js
45+
uses: actions/setup-node@v6
46+
with:
47+
node-version: "22"
48+
cache: "npm"
49+
cache-dependency-path: samples/features/vector-search/vector-search-query-typescript/package-lock.json
50+
51+
- name: Install dependencies
52+
run: npm ci
53+
54+
- name: Type-check (build)
55+
run: npm run build
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Environment files
2+
.env
3+
.env.*
4+
!.env.sample
5+
!.env.example
6+
7+
# Dependencies
8+
node_modules/
9+
10+
# Build artifacts
11+
dist/
12+
build/
13+
14+
# Logs
15+
*.log
16+
npm-debug.log*
17+
18+
# OS files
19+
.DS_Store
20+
Thumbs.db
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Vector Search Samples for Azure SQL Database
2+
3+
Native vector search samples demonstrating the `VECTOR()` data type and `VECTOR_DISTANCE()` function in Azure SQL Database.
4+
5+
## Prerequisites
6+
7+
- Azure subscription — [Create one free](https://azure.microsoft.com/pricing/purchase-options/azure-account)
8+
- [Azure Developer CLI (azd)](https://learn.microsoft.com/azure/developer/azure-developer-cli/install-azd)
9+
- [Azure CLI](https://learn.microsoft.com/cli/azure/install-azure-cli)
10+
11+
## Quick start with Azure Developer CLI
12+
13+
Deploy all required Azure resources (Azure SQL Database + Azure OpenAI) with one command:
14+
15+
```bash
16+
azd up --cwd samples/features/vector-search
17+
```
18+
19+
This provisions:
20+
- **Azure SQL Database** with native vector support
21+
- **Azure OpenAI** with `text-embedding-3-small` deployment
22+
- **Managed Identity** with appropriate role assignments
23+
24+
After deployment, create the `.env` file for the language samples:
25+
26+
```bash
27+
azd env get-values --cwd samples/features/vector-search > samples/features/vector-search/vector-search-query-typescript/.env
28+
```
29+
30+
This writes the deployment outputs (`AZURE_OPENAI_ENDPOINT`, `AZURE_OPENAI_EMBEDDING_DEPLOYMENT`, `AZURE_SQL_SERVER`, `AZURE_SQL_DATABASE`, etc.) directly into the `.env` file that the samples read at runtime.
31+
32+
## Language samples
33+
34+
| Language | Folder | Description |
35+
|----------|--------|-------------|
36+
| TypeScript | [vector-search-query-typescript/](./vector-search-query-typescript/) | Vector search with Node.js, tedious driver, and Azure OpenAI |
37+
38+
## Infrastructure only
39+
40+
The `infra/` folder contains Bicep templates that can be deployed independently:
41+
42+
```bash
43+
azd up --cwd infra # deploy infrastructure only
44+
```
45+
46+
Or used as a module in your own Bicep templates.
47+
48+
## Contributing
49+
50+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
51+
52+
## Related content
53+
54+
- [Vectors in Azure SQL and SQL Server](https://learn.microsoft.com/sql/relational-databases/vectors/vectors-sql-server)
55+
- [VECTOR_DISTANCE (Transact-SQL)](https://learn.microsoft.com/sql/t-sql/functions/vector-distance-transact-sql)
56+
- [Azure OpenAI text embeddings](https://learn.microsoft.com/azure/ai-services/openai/concepts/models#embeddings)
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
2+
3+
name: sql-vector-search-quickstart
4+
metadata:
5+
template: sql-vector-search-quickstart
6+
7+
# Infrastructure outputs (AZURE_SQL_SERVER, AZURE_OPENAI_ENDPOINT, etc.)
8+
# are defined in infra/main.bicep and automatically available via:
9+
# azd env get-values

0 commit comments

Comments
 (0)