|
| 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) |
0 commit comments