Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Learn about C# code samples that demonstrate the functionality and workflow of an Azure AI Search solution. These samples use the Azure AI Search client library for the Azure SDK for .NET, which you can explore through the following links.
| Target | Link |
|---|---|
| Package download | nuget.org/packages/Azure.Search.Documents/ |
| API reference | Azure.Search.Documents |
| API test cases | github.com/Azure/azure-sdk-for-net/tree/main/sdk/search/Azure.Search.Documents/tests |
| Source code | github.com/Azure/azure-sdk-for-net/tree/main/sdk/search/Azure.Search.Documents/src |
| Change log | https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/CHANGELOG.md |
SDK samples
Code samples from the Azure SDK development team demonstrate API usage. You can find these samples on GitHub.
| Sample | Description |
|---|---|
| Hello world (synchronous) | Create a client, authenticate, and handle errors using synchronous methods. |
| Hello world (asynchronous) | Create a client, authenticate, and handle errors using asynchronous methods. |
| Service-level operations | Get service statistics and create multiple search objects, including an index, indexer, data source, skillset, and synonym map. Finally, you query the index. |
| Index operations | Get a count of documents stored in an index. |
| FieldBuilderIgnore | Use an attribute to work with unsupported data types. |
| Indexing documents (push model) | Use the push model to index documents by sending a JSON payload to an index. |
| Customer-managed encryption keys | Use a customer-managed encryption key to protect sensitive content. |
| Vector search | Index a vector field and perform vector search. |
| Semantic ranking | Configure semantic ranker in an index and run semantic queries. |
Doc samples
Code samples from the Azure AI Search team demonstrate features and workflows. Many of the following samples are referenced in tutorials, quickstarts, and how-to articles that explain the code in detail. You can find these samples in Azure-Samples/azure-search-dotnet-samples and Azure-Samples/search-dotnet-getting-started on GitHub.
| Sample | Description |
|---|---|
| quickstart | Source code for the C# portion of Quickstart: Full-text search. Create, load, and query an index using sample data. |
| quickstart-rag | Source code for the C# portion of Quickstart: Generative search (RAG). Use grounding data from Azure AI Search with a chat completion model from Azure OpenAI. |
| quickstart-semantic-search | Source code for the C# portion of Quickstart: Semantic ranking. Add semantic ranking to an index schema and run semantic queries. |
| quickstart-vector-search | Source code for the C# portion of Quickstart: Vector search. Index and query vector content. |
| create-mvc-app | Source code for Tutorial: Add search to an ASP.NET Core (MVC) app. Add basic search, pagination, and other server-side behaviors to an MVC web app, unlike the console applications used in most samples. |
| search-website | Source code for Tutorial: Add search to web apps. Build an end-to-end search app that uses the push API for bulk upload and a rich client for hosting the app and handling search requests. |
| tutorial-ai-enrichment | Source code for Tutorial: AI-generated searchable content from Azure blobs. Create a skillset that iterates over Azure blobs to extract information and infer structure. |
| multiple-data-sources | Source code for Tutorial: Index from multiple data sources. Merge content from two data sources into one index. |
| optimize-data-indexing | Source code for Tutorial: Optimize indexing with the push API. Use optimization techniques for pushing data into an index. |
| DotNetHowTo | Source code for Use the .NET client library. Create and manage multiple search objects while learning about the APIs. |
| DotNetToIndexers | Source code for Tutorial: Index Azure SQL data. Configure an Azure SQL indexer with a schedule, field mappings, and parameters. |
| DotNetHowToEncryptionUsingCMK | Source code for Configure customer-managed keys for data encryption. Create objects that are encrypted with a customer-managed key. |
| DotNetVectorDemo | Create, load, and query a vector index. |
| DotNetIntegratedVectorizationDemo | Extend the vector workflow to include skills-based automation for data chunking and embedding. |
Accelerators
An accelerator is an end-to-end solution that includes code and documentation you can adapt for your own implementation of a specific scenario.
| Sample | Description |
|---|---|
| search-qna-maker-accelerator | Solution that combines Azure AI Search and QnA Maker. See the live demo site. |
Demos
A demo repo provides proof-of-concept source code for examples or scenarios shown in demonstrations. Unlike accelerators, demo solutions aren't designed for adaptation.
| Sample | Description |
|---|---|
| covid19search | Source code repo for the Azure AI Search-based Covid-19 search app. |
| AzureSearch_JFK_Files | Source code repo for the Azure AI Search-based JFK files solution. |
Other samples
The following samples are also published by the Azure AI Search team but aren't referenced in documentation. Associated README files provide usage instructions.
| Sample | Description |
|---|---|
| check-storage-usage | Check search service storage on a schedule using an Azure function. |
| export-data | Partition and export a large index using a C# console app. |
| index-backup-restore | Copy an index from one service to another, creating JSON files with the index schema and documents. |
| data-lake-gen2-acl-indexing | Index Azure Data Lake Gen2 files and folders secured with Microsoft Entra ID and role-based access control. |
| multiple-search-services | Query multiple search services and combine results into a single page. |
| search-aggregations | Obtain and filter aggregations from an index. |
| azure-search-power-skills | Incorporate consumable custom skills into your own solutions. |