You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: Find Azure AI Search demo C# code samples that use the .NET client libraries.
5
-
6
5
manager: nitinme
7
6
author: haileytap
8
7
ms.author: haileytapia
@@ -11,12 +10,12 @@ ms.custom:
11
10
- devx-track-dotnet
12
11
- ignite-2023
13
12
ms.topic: concept-article
14
-
ms.date: 10/18/2024
13
+
ms.date: 03/10/2025
15
14
---
16
15
17
16
# C# samples for Azure AI Search
18
17
19
-
You can explore C# code samples that demonstrate the functionality and workflow of an Azure AI Search solution. These samples use the [**Azure AI Search client library**](/dotnet/api/overview/azure/search) for the [**Azure SDK for .NET**](/dotnet/azure/), which you can access through the following links.
18
+
Learn about the C# code samples that demonstrate the functionality and workflow of an Azure AI Search solution. These samples use the [**Azure AI Search client library**](/dotnet/api/overview/azure/search) for the [**Azure SDK for .NET**](/dotnet/azure/), which you can explore through the following links.
20
19
21
20
| Target | Link |
22
21
|--------|------|
@@ -28,23 +27,23 @@ You can explore C# code samples that demonstrate the functionality and workflow
28
27
29
28
## SDK samples
30
29
31
-
Code samples from the Azure SDK development team demonstrate API usage. You can find [these samples on GitHub](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/).
30
+
Code samples from the Azure SDK development team demonstrate API usage. You can find these samples on [GitHub](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/).
32
31
33
32
| Sample | Description |
34
33
|---------|-------------|
35
-
|[*Hello world* - synchronous](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample01a_HelloWorld.md)| Demonstrates how to create a client, authenticate, and handle errors using synchronous methods |
36
-
|[*Hello world* - asynchronous](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample01b_HelloWorldAsync.md)| Demonstrates how to create a client, authenticate, and handle errors using asynchronous methods |
37
-
|[Service-level operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample02_Service.md)| Demonstrates how to create indexes, indexers, data sources, skillsets, and synonym maps. This sample also shows you how to get service statistics and how to query an index |
38
-
|[Index operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample03_Index.md)| Demonstrates how to perform an action on existing index, in this case getting a count of documents stored in the index |
39
-
|[FieldBuilderIgnore](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample04_FieldBuilderIgnore.md)| Demonstrates a technique for working with unsupported data types |
40
-
|[Indexing documents (push model)](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample05_IndexingDocuments.md)|*Push* model indexing, where you send a JSON payload to an index on a service |
41
-
|[Encryption key sample](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample06_EncryptedIndex.md)| Demonstrates using a customer-managed encryption key to add an extra layer of protection over sensitive content |
42
-
|[Vector search sample](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample07_VectorSearch.md)| Shows you how to index a vector field and perform vector search using the Azure SDK for .NET |
43
-
|[Semantic ranking sample](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample08_SemanticSearch.md)| Shows you how to configure semantic ranker in an index and invoke semantic queries using the Azure SDK for .NET |
34
+
|[*Hello world* - synchronous](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample01a_HelloWorld.md)| Demonstrates how to create a client, authenticate, and handle errors using synchronous methods.|
35
+
|[*Hello world* - asynchronous](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample01b_HelloWorldAsync.md)| Demonstrates how to create a client, authenticate, and handle errors using asynchronous methods.|
36
+
|[Service-level operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample02_Service.md)| Demonstrates how to create indexes, indexers, data sources, skillsets, and synonym maps. This sample also shows you how to get service statistics and how to query an index.|
37
+
|[Index operations](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample03_Index.md)| Demonstrates how to perform an action on existing index, in this case getting a count of documents stored in the index.|
38
+
|[FieldBuilderIgnore](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample04_FieldBuilderIgnore.md)| Demonstrates a technique for working with unsupported data types.|
39
+
|[Indexing documents (push model)](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample05_IndexingDocuments.md)|*Push* model indexing, where you send a JSON payload to an index on a service.|
40
+
|[Encryption key sample](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample06_EncryptedIndex.md)| Demonstrates using a customer-managed encryption key to add an extra layer of protection over sensitive content.|
41
+
|[Vector search sample](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample07_VectorSearch.md)| Shows you how to index a vector field and perform vector search using the Azure SDK for .NET.|
42
+
|[Semantic ranking sample](https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/search/Azure.Search.Documents/samples/Sample08_SemanticSearch.md)| Shows you how to configure semantic ranker in an index and invoke semantic queries using the Azure SDK for .NET.|
44
43
45
44
## Doc samples
46
45
47
-
Code samples from the Azure AI Search team demonstrate features and workflows. All 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**](https://github.com/Azure-Samples/azure-search-dotnet-samples) and in [**Azure-Samples/search-dotnet-getting-started**](https://github.com/Azure-Samples/search-dotnet-getting-started/) on GitHub.
46
+
Code samples from the Azure AI Search team demonstrate features and workflows. All 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**](https://github.com/Azure-Samples/azure-search-dotnet-samples) and [**Azure-Samples/search-dotnet-getting-started**](https://github.com/Azure-Samples/search-dotnet-getting-started/) on GitHub.
48
47
49
48
> [!TIP]
50
49
> Try the [samples browser](/samples/browse/?languages=csharp&products=azure-cognitive-search) to search for Microsoft code samples in GitHub, filtered by product, service, and language.
@@ -56,8 +55,8 @@ Code samples from the Azure AI Search team demonstrate features and workflows. A
56
55
|[quickstart-semantic-search](https://github.com/Azure-Samples/azure-search-dotnet-samples/blob/main/quickstart-semantic-search/)|[Quickstart: Semantic ranking using the Azure SDKs](search-get-started-semantic.md)| Shows the index schema and query request for invoking semantic ranker. |
57
56
|[search-website](https://github.com/Azure-Samples/azure-search-static-web-app)|[Tutorial: Add search to web apps](tutorial-csharp-overview.md)| Demonstrates an end-to-end search app that includes bulk upload using the push APIs and a rich client for hosting the app and handling search requests.|
58
57
|[tutorial-ai-enrichment](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/main/tutorial-ai-enrichment)|[Tutorial: AI-generated searchable content from Azure blobs](cognitive-search-tutorial-blob-dotnet.md)| Shows how to configure an indexer and skillset. |
59
-
|[multiple-data-sources](https://github.com/Azure-Samples/azure-search-dotnet-scale/tree/main/multiple-data-sources)|[Tutorial: Index from multiple data sources](tutorial-multiple-data-sources.md).| Merges content from two data sources into one search index. |
60
-
|[Optimize-data-indexing](https://github.com/Azure-Samples/azure-search-dotnet-scale/tree/main/optimize-data-indexing)|[Tutorial: Optimize indexing with the push API](tutorial-optimize-indexing-push-api.md).| Demonstrates optimization techniques for pushing data into a search index. |
58
+
|[multiple-data-sources](https://github.com/Azure-Samples/azure-search-dotnet-scale/tree/main/multiple-data-sources)|[Tutorial: Index from multiple data sources](tutorial-multiple-data-sources.md)| Merges content from two data sources into one search index. |
59
+
|[Optimize-data-indexing](https://github.com/Azure-Samples/azure-search-dotnet-scale/tree/main/optimize-data-indexing)|[Tutorial: Optimize indexing with the push API](tutorial-optimize-indexing-push-api.md)| Demonstrates optimization techniques for pushing data into a search index. |
61
60
|[DotNetHowTo](https://github.com/Azure-Samples/search-dotnet-getting-started/tree/master/DotNetHowTo)|[How to use the .NET client library](search-howto-dotnet-sdk.md)| Steps through the basic workflow, but in more detail and with discussion of API usage. |
62
61
|[DotNetToIndexers](https://github.com/Azure-Samples/search-dotnet-getting-started/tree/master/DotNetHowToIndexers)|[Tutorial: Index Azure SQL data](search-indexer-tutorial.md)| Shows how to configure an Azure SQL indexer that has a schedule, field mappings, and parameters. |
63
62
|[DotNetHowToEncryptionUsingCMK](https://github.com/Azure-Samples/search-dotnet-getting-started/tree/master/DotNetHowToEncryptionUsingCMK)|[How to configure customer-managed keys for data encryption](search-security-manage-encryption-keys.md)| Shows how to create objects that are encrypted with a Customer Key. |
@@ -70,28 +69,28 @@ An accelerator is an end-to-end solution that includes code and documentation th
70
69
71
70
| Samples | Repository | Description |
72
71
|---------|------------|-------------|
73
-
| Search + QnA Maker Accelerator |[search-qna-maker-accelerator](https://github.com/Azure-Samples/search-qna-maker-accelerator)| A [solution](https://techcommunity.microsoft.com/t5/azure-ai/qna-with-azure-cognitive-search/ba-p/2081381) combining the power of Search and QnA Maker. See the live [demo site](https://aka.ms/qnaWithAzureSearchDemo)|
74
-
|[Knowledge Mining Solution Accelerator](/shows/ai-show/knowledge-mining-with-azure-search)|[azure-search-knowledge-mining](https://github.com/azure-samples/azure-search-knowledge-mining/tree/main/)| Includes templates, support files, and analytical reports to help you prototype an end-to-end knowledge mining solution |
72
+
| Search + QnA Maker Accelerator |[search-qna-maker-accelerator](https://github.com/Azure-Samples/search-qna-maker-accelerator)| A [solution](https://techcommunity.microsoft.com/t5/azure-ai/qna-with-azure-cognitive-search/ba-p/2081381) combining the power of Search and QnA Maker. See the live [demo site](https://aka.ms/qnaWithAzureSearchDemo).|
73
+
|[Knowledge Mining Solution Accelerator](/shows/ai-show/knowledge-mining-with-azure-search)|[azure-search-knowledge-mining](https://github.com/azure-samples/azure-search-knowledge-mining/tree/main/)| Includes templates, support files, and analytical reports to help you prototype an end-to-end knowledge mining solution.|
75
74
76
75
## Demos
77
76
78
77
A demo repo provides proof-of-concept source code for examples or scenarios shown in demonstrations. Demo solutions aren't designed for adaptation by customers.
79
78
80
79
| Samples | Repository | Description |
81
80
|---------|------------|-------------|
82
-
| Covid-19 search app |[covid19search](https://github.com/liamca/covid19search)| Source code repository for the Azure AI Search based [Covid-19 Search App](https://covid19search.azurewebsites.net/)|
83
-
| JFK demo |[AzureSearch JFK Files](https://github.com/Microsoft/AzureSearch_JFK_Files)| Learn more about the [JFK solution](https://www.microsoft.com/ai/ai-lab-jfk-files)|
81
+
| Covid-19 search app |[covid19search](https://github.com/liamca/covid19search)| Source code repository for the Azure AI Search based [Covid-19 Search App](https://covid19search.azurewebsites.net/).|
82
+
| JFK demo |[AzureSearch JFK Files](https://github.com/Microsoft/AzureSearch_JFK_Files)| Learn more about the [JFK solution](https://www.microsoft.com/ai/ai-lab-jfk-files).|
84
83
85
84
## Other samples
86
85
87
-
The following samples are also published by the Azure AI Search team, but aren't referenced in documentation. Associated readme files provide usage instructions.
86
+
The following samples are also published by the Azure AI Search team but aren't referenced in documentation. Associated readme files provide usage instructions.
88
87
89
88
| Samples | Repository | Description |
90
89
|---------|------------|-------------|
91
-
|[Query multiple services](https://github.com/Azure-Samples/azure-search-dotnet-scale/tree/main/multiple-search-services)|[azure-search-dotnet-scale](https://github.com/Azure-Samples/azure-search-dotnet-samples)| Issue a single query across multiple search services and combine the results into a single page |
92
-
|[Check storage](https://github.com/Azure-Samples/azure-search-dotnet-utilities/blob/main/check-storage-usage/README.md)|[azure-search-dotnet-utilities](https://github.com/Azure-Samples/azure-search-dotnet-utilities)| Invokes an Azure function that checks search service storage on a schedule |
93
-
|[Export an index](https://github.com/Azure-Samples/azure-search-dotnet-utilities/blob/main/export-data/README.md)|[azure-search-dotnet-utilities](https://github.com/Azure-Samples/azure-search-dotnet-utilities)| C# console app that partitions and export a large index |
94
-
|[Backup and restore an index](https://github.com/Azure-Samples/azure-search-dotnet-utilities/blob/main/index-backup-restore/README.md)|[azure-search-dotnet-utilities](https://github.com/Azure-Samples/azure-search-dotnet-utilities)| C# console app that copies an index from one service to another, and in the process, creates JSON files on your computer with the index schema and documents |
95
-
|[Index Data Lake Gen2 using Microsoft Entra ID](https://github.com/Azure-Samples/azure-search-dotnet-utilities/blob/main/data-lake-gen2-acl-indexing/README.md)|[azure-search-dotnet-utilities](https://github.com/Azure-Samples/azure-search-dotnet-utilities)| Source code demonstrating indexer connections and indexing of Azure Data Lake Gen2 files and folders that are secured through Microsoft Entra ID and role-based access controls |
96
-
|[Search aggregations](https://github.com/Azure-Samples/azure-search-dotnet-utilities/blob/main/search-aggregations/README.md)|[azure-search-dotnet-utilities](https://github.com/Azure-Samples/azure-search-dotnet-utilities)| Proof-of-concept source code that demonstrates how to obtain aggregations from a search index and then filter by them |
97
-
|[Power Skills](https://github.com/Azure-Samples/azure-search-power-skills/blob/main/README.md)|[azure-search-power-skills](https://github.com/Azure-Samples/azure-search-power-skills)| Source code for consumable custom skills that you can incorporate in your won solutions |
90
+
|[Query multiple services](https://github.com/Azure-Samples/azure-search-dotnet-scale/tree/main/multiple-search-services)|[azure-search-dotnet-scale](https://github.com/Azure-Samples/azure-search-dotnet-samples)| Issue a single query across multiple search services and combine the results into a single page.|
91
+
|[Check storage](https://github.com/Azure-Samples/azure-search-dotnet-utilities/blob/main/check-storage-usage/README.md)|[azure-search-dotnet-utilities](https://github.com/Azure-Samples/azure-search-dotnet-utilities)| Invokes an Azure function that checks search service storage on a schedule.|
92
+
|[Export an index](https://github.com/Azure-Samples/azure-search-dotnet-utilities/blob/main/export-data/README.md)|[azure-search-dotnet-utilities](https://github.com/Azure-Samples/azure-search-dotnet-utilities)| C# console app that partitions and exports a large index.|
93
+
|[Backup and restore an index](https://github.com/Azure-Samples/azure-search-dotnet-utilities/blob/main/index-backup-restore/README.md)|[azure-search-dotnet-utilities](https://github.com/Azure-Samples/azure-search-dotnet-utilities)| C# console app that copies an index from one service to another, creating JSON files on your computer with the index schema and documents.|
94
+
|[Index Data Lake Gen2 using Microsoft Entra ID](https://github.com/Azure-Samples/azure-search-dotnet-utilities/blob/main/data-lake-gen2-acl-indexing/README.md)|[azure-search-dotnet-utilities](https://github.com/Azure-Samples/azure-search-dotnet-utilities)| Source code demonstrating indexer connections and indexing of Azure Data Lake Gen2 files and folders that are secured through Microsoft Entra ID and role-based access controls.|
95
+
|[Search aggregations](https://github.com/Azure-Samples/azure-search-dotnet-utilities/blob/main/search-aggregations/README.md)|[azure-search-dotnet-utilities](https://github.com/Azure-Samples/azure-search-dotnet-utilities)| Proof-of-concept source code that demonstrates how to obtain aggregations from a search index and then filter by them.|
96
+
|[Power Skills](https://github.com/Azure-Samples/azure-search-power-skills/blob/main/README.md)|[azure-search-power-skills](https://github.com/Azure-Samples/azure-search-power-skills)| Source code for consumable custom skills that you can incorporate in your own solutions.|
0 commit comments