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
Copy file name to clipboardExpand all lines: articles/search/cognitive-search-tutorial-blob-dotnet.md
+22-86Lines changed: 22 additions & 86 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ author: MarkHeff
8
8
ms.author: maheff
9
9
ms.service: cognitive-search
10
10
ms.topic: tutorial
11
-
ms.date: 02/27/2020
11
+
ms.date: 05/05/2020
12
12
---
13
13
14
14
# Tutorial: AI-generated searchable content from Azure blobs using the .NET SDK
@@ -39,7 +39,9 @@ If you don't have an Azure subscription, open a [free account](https://azure.mic
39
39
40
40
1. Open this [OneDrive folder](https://1drv.ms/f/s!As7Oy81M_gVPa-LCb5lC_3hbS-4) and on the top-left corner, click **Download** to copy the files to your computer.
41
41
42
-
1. Right-click the zip file and select **Extract All**. There are 14 files of various types. Use all of them for this tutorial.
42
+
1. Right-click the zip file and select **Extract All**. There are 14 files of various types. You'll use 7 for this exercise.
43
+
44
+
You can also download the source code for this tutorial. Source code is in the tutorial-ai-enrichment folder in the [azure-search-dotnet-samples](https://github.com/Azure-Samples/azure-search-dotnet-samples) repository.
43
45
44
46
## 1 - Create services
45
47
@@ -71,22 +73,22 @@ If possible, create both in the same region and resource group for proximity and
71
73
72
74
1. Click **Blobs** service.
73
75
74
-
1. Click **+ Container** to create a container and name it *basic-demo-data-pr*.
76
+
1. Click **+ Container** to create a container and name it *cog-search-demo*.
75
77
76
-
1. Select *basic-demo-data-pr* and then click **Upload** to open the folder where you saved the download files. Select all fourteen files and click **OK** to upload.
78
+
1. Select *cog-search-demo* and then click **Upload** to open the folder where you saved the download files. Select all fourteen files and click **OK** to upload.
1. Save the connection string to Notepad. You'll need it later when setting up the data source connection.
@@ -95,7 +97,7 @@ If possible, create both in the same region and resource group for proximity and
95
97
96
98
AI enrichment is backed by Cognitive Services, including Text Analytics and Computer Vision for natural language and image processing. If your objective was to complete an actual prototype or project, you would at this point provision Cognitive Services (in the same region as Azure Cognitive Search) so that you can attach it to indexing operations.
97
99
98
-
For this exercise, however, you can skip resource provisioning because Azure Cognitive Search can connect to Cognitive Services behind the scenes and give you 20 free transactions per indexer run. Since this tutorial uses 7 transactions, the free allocation is sufficient. For larger projects, plan on provisioning Cognitive Services at the pay-as-you-go S0 tier. For more information, see [Attach Cognitive Services](cognitive-search-attach-cognitive-services.md).
100
+
For this exercise, however, you can skip resource provisioning because Azure Cognitive Search can connect to Cognitive Services behind the scenes and give you 20 free transactions per indexer run. Since this tutorial uses 14 transactions, the free allocation is sufficient. For larger projects, plan on provisioning Cognitive Services at the pay-as-you-go S0 tier. For more information, see [Attach Cognitive Services](cognitive-search-attach-cognitive-services.md).
99
101
100
102
### Azure Cognitive Search
101
103
@@ -125,15 +127,15 @@ The [Azure Cognitive Search .NET SDK](https://aka.ms/search-sdk) consists of a f
125
127
126
128
For this project, install version 9 or later of the `Microsoft.Azure.Search` NuGet package.
127
129
128
-
1. Open the Package Manager Console. Select **Tools** > **NuGet Package Manager** > **Package Manager Console**.
129
-
130
-
1. Navigate to [Microsoft.Azure.Search NuGet package page](https://www.nuget.org/packages/Microsoft.Azure.Search).
130
+
1. In a browser, go to [Microsoft.Azure.Search NuGet package page](https://www.nuget.org/packages/Microsoft.Azure.Search).
131
131
132
132
1. Select the latest version (9 or later).
133
133
134
134
1. Copy the Package Manager command.
135
135
136
-
1. Return to the Package Manager console and run the command you copied in the previous step.
136
+
1. Open the Package Manager Console. Select **Tools** > **NuGet Package Manager** > **Package Manager Console**.
137
+
138
+
1. Paste and run the command that you copied in the previous step.
137
139
138
140
Next, install the latest `Microsoft.Extensions.Configuration.Json` NuGet package.
"AzureBlobConnectionString": "Put your Azure Blob connection string here",
164
166
}
165
167
```
166
-
168
+
167
169
Add your search service and blob storage account information. Recall that you can get this information from the service provisioning steps indicated in the previous section.
168
170
171
+
For **SearchServiceName**, enter the short service name and not the full URL.

@@ -626,33 +602,6 @@ namespace EnrichwithAI
626
602
}
627
603
```
628
604
629
-
<!-- Add the below model class definition to `DemoIndex.cs` and include it in the same namespace where you'll create the index.
630
-
631
-
```csharp
632
-
// The SerializePropertyNamesAsCamelCase attribute is defined in the Azure Cognitive Search .NET SDK.
633
-
// It ensures that Pascal-case property names in the model class are mapped to camel-case
634
-
// field names in the index.
635
-
[SerializePropertyNamesAsCamelCase]
636
-
public class DemoIndex
637
-
{
638
-
[System.ComponentModel.DataAnnotations.Key]
639
-
[IsSearchable, IsSortable]
640
-
public string Id { get; set; }
641
-
642
-
[IsSearchable]
643
-
public string Content { get; set; }
644
-
645
-
[IsSearchable]
646
-
public string LanguageCode { get; set; }
647
-
648
-
[IsSearchable]
649
-
public string[] KeyPhrases { get; set; }
650
-
651
-
[IsSearchable]
652
-
public string[] Organizations { get; set; }
653
-
}
654
-
``` -->
655
-
656
605
Now that you've defined a model class, back in `Program.cs` you can create an index definition fairly easily. The name for this index will be `demoindex`. If an index already exists with that name, it will be deleted.
657
606
658
607
```csharp
@@ -692,27 +641,14 @@ Add the following lines to `Main`.
Add the following using statement to resolve the disambiguate reference.
702
648
703
-
if (exists)
704
-
{
705
-
serviceClient.Indexes.Delete(index.Name);
706
-
}
707
-
708
-
serviceClient.Indexes.Create(index);
709
-
}
710
-
catch (Exception e)
711
-
{
712
-
// Handle exception
713
-
}
649
+
```csharp
650
+
using Index = Microsoft.Azure.Search.Models.Index;
714
651
```
715
-
-->
716
652
717
653
To learn more about defining an index, see [Create Index (Azure Cognitive Search REST API)](https://docs.microsoft.com/rest/api/searchservice/create-index).
718
654
@@ -795,7 +731,7 @@ Add the following lines to `Main`.
795
731
796
732
```csharp
797
733
// Create the indexer, map fields, and execute transformations
798
-
Console.WriteLine("Creating the indexer...");
734
+
Console.WriteLine("Creating the indexer and executing the pipeline...");
0 commit comments