Skip to content

Commit b304766

Browse files
committed
Cognitive Search - add search to website - .NET
1 parent 3655bb5 commit b304766

6 files changed

+68
-66
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
ms.topic: include
3+
ms.date: 10/26/2022
4+
author: HeidiSteen
5+
ms.author: heidist
6+
ms.service: cognitive-search
7+
---
8+
Note your **Search resource name**. You'll need this to connect the Azure Function app to your Search resource.
9+
10+
> [!CAUTION]
11+
> While you may be tempted to use your Search admin key in the Azure Function, that isn't following the principle of least privilege. The Azure Function will use the query key to conform to least privilege.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
ms.topic: include
3+
ms.date: 10/26/2022
4+
author: HeidiSteen
5+
ms.author: heidist
6+
ms.service: cognitive-search
7+
---
8+
9+
Once the upload completes, the Search Index is ready to use. Review your new Index.
10+
11+
1. In Visual Studio Code, open the Azure Cognitive Search extension and select your Search resource.
12+
13+
:::image type="content" source="../media/tutorial-javascript-create-load-index/visual-studio-code-search-extension-view-resource.png" alt-text="In Visual Studio Code, open the Azure Cognitive Search extension and open your Search resource.":::
14+
15+
1. Expand Indexes, then Documents, then `good-books`, then select a doc to see all the document-specific data.
16+
17+
:::image type="content" source="../media/tutorial-javascript-create-load-index/visual-studio-code-search-extension-view-docs.png" lightbox="../media/tutorial-javascript-create-load-index/visual-studio-code-search-extension-view-docs.png" alt-text="Expand Indexes, then `good-books`, then select a doc.":::
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
ms.topic: include
3+
ms.date: 10/26/2022
4+
author: HeidiSteen
5+
ms.author: heidist
6+
ms.service: cognitive-search
7+
---
8+
Use the following git command in the VS Code integrated terminal at the `bulk-insert` directory, to roll back the changes. They aren't needed to continue the tutorial and you shouldn't save or push these secrets to your repo.
9+
10+
```git
11+
git checkout .
12+
```

articles/search/tutorial-csharp-create-load-index.md

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ author: diberry
77
ms.author: diberry
88
ms.service: cognitive-search
99
ms.topic: tutorial
10-
ms.date: 08/30/2022
10+
ms.date: 11/01/2022
1111
ms.custom: devx-track-csharp
1212
ms.devlang: csharp
1313
---
1414

1515
# 2 - Create and load Search Index with .NET
1616

1717
Continue to build your Search-enabled website by:
18-
* Creating a Search resource with the VS Code extension
19-
* Creating a new index and importing data with .NET using the sample script and Azure SDK [Azure.Search.Documents](https://www.nuget.org/packages/Azure.Search.Documents/).
18+
* Create a Search resource with the VS Code extension
19+
* Create a new index
20+
* Import data with .NET using the sample script and Azure SDK [Azure.Search.Documents](https://www.nuget.org/packages/Azure.Search.Documents/).
2021

2122
## Create an Azure Search resource
2223

@@ -26,7 +27,7 @@ Create a new Search resource with the [Azure Cognitive Search](https://marketpla
2627

2728
1. In the Side bar, **right-click on your Azure subscription** under the `Azure: Cognitive Search` area and select **Create new search service**.
2829

29-
:::image type="content" source="./media/tutorial-javascript-create-load-index/visual-studio-code-create-search-resource.png" alt-text="In the Side bar, right-click on your Azure subscription under the **Azure: Cognitive Search** area and select **Create new search service**.":::
30+
:::image type="content" source="./media/tutorial-javascript-create-load-index/visual-studio-code-create-search-resource.png" alt-text="Screenshot of Visual Studio code showing the Azure explorer bar, right-click on your Azure subscription under the Azure: Cognitive Search area and select Create new search service.":::
3031

3132
1. Follow the prompts to provide the following information:
3233

@@ -45,7 +46,7 @@ Get your Search resource admin key with the Visual Studio Code extension.
4546

4647
1. In Visual Studio Code, in the Side bar, right-click on your Search resource and select **Copy Admin Key**.
4748

48-
:::image type="content" source="./media/tutorial-javascript-create-load-index/visual-studio-code-copy-admin-key.png" alt-text="In the Side bar, right-click on your Search resource and select **Copy Admin Key**.":::
49+
:::image type="content" source="./media/tutorial-javascript-create-load-index/visual-studio-code-copy-admin-key.png" alt-text="Screenshot of Visual Studio code showing the Azure explorer bar, right-click on your Search resource and select Copy Admin Key.":::
4950

5051
1. Keep this admin key, you will need to use it in [a later section](#prepare-the-bulk-import-script-for-search).
5152

@@ -86,11 +87,19 @@ Once the upload completes, the Search Index is ready to use. Review your new Ind
8687
8788
1. In Visual Studio Code, open the Azure Cognitive Search extension and select your Search resource.
8889
89-
:::image type="content" source="media/tutorial-javascript-create-load-index/visual-studio-code-search-extension-view-resource.png" alt-text="In Visual Studio Code, open the Azure Cognitive Search extension and open your Search resource.":::
90+
:::image type="content" source="media/tutorial-javascript-create-load-index/visual-studio-code-search-extension-view-resource.png" alt-text="Screenshot of Visual Studio Code, open the Azure Cognitive Search extension and open your Search resource.":::
9091
9192
1. Expand Indexes, then Documents, then `good-books`, then select a doc to see all the document-specific data.
9293
93-
:::image type="content" source="media/tutorial-javascript-create-load-index/visual-studio-code-search-extension-view-docs.png" lightbox="media/tutorial-javascript-create-load-index/visual-studio-code-search-extension-view-docs.png" alt-text="Expand Indexes, then `good-books`, then select a doc.":::
94+
:::image type="content" source="media/tutorial-javascript-create-load-index/visual-studio-code-search-extension-view-docs.png" lightbox="media/tutorial-javascript-create-load-index/visual-studio-code-search-extension-view-docs.png" alt-text="Screenshot of Visual Studio Code showing Cognitive Search resource, expand Indexes, then `good-books`, then select a doc.":::
95+
96+
## Rollback bulk import file changes
97+
98+
Use the following git command in the VS Code integrated terminal at the `bulk-insert` directory, to rollback the changes. They are not needed to continue the tutorial and you shouldn't save or push these secrets to your repo.
99+
100+
```git
101+
git checkout .
102+
```
94103

95104
## Copy your Search resource name
96105

@@ -99,13 +108,7 @@ Note your **Search resource name**. You will need this to connect the Azure Func
99108
> [!CAUTION]
100109
> While you may be tempted to use your Search admin key in the Azure Function, that isn't following the principle of least privilege. The Azure Function will use the query key to conform to least privilege.
101110
102-
## Rollback bulk import file changes
103-
104-
Use the following git command in the VS Code integrated terminal at the `bulk-insert` directory, to rollback the changes. They are not needed to continue the tutorial and you shouldn't save or push these secrets to your repo.
105111
106-
```git
107-
git checkout .
108-
```
109112
110113
## Next steps
111114

articles/search/tutorial-csharp-overview.md

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ author: diberry
77
ms.author: diberry
88
ms.service: cognitive-search
99
ms.topic: tutorial
10-
ms.date: 08/30/2022
10+
ms.date: 11/01/2022
1111
ms.custom: devx-track-csharp
1212
ms.devlang: csharp
1313
---
@@ -21,35 +21,25 @@ The application is available:
2121
* [Demo website - aka.ms/azs-good-books](https://aka.ms/azs-good-books)
2222

2323
## What does the sample do?
24-
25-
This sample website provides access to a catalog of 10,000 books. A user can search the catalog by entering text in the search bar. While the user enters text, the website uses the search index's suggest feature to complete the text. Once the query finishes, the list of books is displayed with a portion of the details. A user can select a book to see all the details, stored in the search index, of the book.
26-
27-
:::image type="content" source="./media/tutorial-javascript-overview/cognitive-search-enabled-book-website.png" alt-text="This sample website provides access to a catalog of 10,000 books. A user can search the catalog by entering text in the search bar. While the user enters text, the website uses the search index's suggest feature to complete the text. Once the search finishes, the list of books is displayed with a portion of the details. A user can select a book to see all the details, stored in the search index, of the book.":::
28-
29-
The search experience includes:
30-
31-
* Search – provides search functionality for the application.
32-
* Suggest – provides suggestions as the user is typing in the search bar.
33-
* Document Lookup – looks up a document by ID to retrieve all of its contents for the details page.
24+
[!INCLUDE [tutorial-overview](includes/tutorial-add-search-website-what-sample-does.md)]
3425

3526
## How is the sample organized?
3627

37-
The [sample](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/master/search-website) includes the following:
28+
The [sample](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/master/search-website-functions-v4) includes the following:
3829

3930
|App|Purpose|GitHub<br>Repository<br>Location|
4031
|--|--|--|
41-
|Client|React app (presentation layer) to display books, with search. It calls the Azure Function app. |[/search-website/src](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/master/search-website/src)|
42-
|Server|Azure .NET Function app (business layer) - calls the Azure Cognitive Search API using .NET SDK |[/search-website/api](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/master/search-website/api)|
43-
|Bulk insert|.NET file to create the index and add documents to it.|[/search-website/bulk-insert](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/master/search-website/bulk-insert)|
32+
|Client|React app (presentation layer) to display books, with search. It calls the Azure Function app. |[/search-website-functions-v4/](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/master/search-website-functions-v4/client)|
33+
|Server|Azure .NET Function app (business layer) - calls the Azure Cognitive Search API using .NET SDK |[/search-website-functions-v4/api](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/master/search-website-functions-v4/api)|
34+
|Bulk insert|.NET file to create the index and add documents to it.|[/search-website-functions-v4/bulk-insert](https://github.com/Azure-Samples/azure-search-dotnet-samples/tree/master/search-website-functions-v4/bulk-insert)|
4435

4536
## Set up your development environment
4637

4738
Install the following for your local development environment.
4839

49-
- [.NET 5](https://dotnet.microsoft.com/download/dotnet/5.0)
40+
- [.NET 6](https://dotnet.microsoft.com/download/dotnet/6.0)
5041
- [Git](https://git-scm.com/downloads)
5142
- [Visual Studio Code](https://code.visualstudio.com/) and the following extensions
52-
- [Azure Resources](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azureresourcegroups)
5343
- [Azure Cognitive Search 0.2.0+](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurecognitivesearch)
5444
- [Azure Static Web App](https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurestaticwebapps)
5545
- Optional:
@@ -63,27 +53,11 @@ Forking the sample repository is critical to be able to deploy the Static Web Ap
6353

6454
Complete the fork process in your web browser with your GitHub account. This tutorial uses your fork as part of the deployment to an Azure Static Web App.
6555

66-
1. At a bash terminal, download the sample application to your local computer.
67-
68-
Replace `YOUR-GITHUB-ALIAS` with your GitHub alias.
69-
70-
```bash
71-
git clone https://github.com/YOUR-GITHUB-ALIAS/azure-search-dotnet-samples
72-
```
73-
74-
1. In Visual Studio Code, open your local folder of the cloned repository. The remaining tasks are accomplished from Visual Studio Code, unless specified.
56+
[!INCLUDE [tutorial-fork-and-clone](includes/tutorial-add-search-website-fork-and-clone.md)]
7557

7658
## Create a resource group for your Azure resources
7759

78-
1. In Visual Studio Code, open the [Activity bar](https://code.visualstudio.com/docs/getstarted/userinterface), and select the Azure icon.
79-
1. In Resources, select Add (**+**), and then select **Create Resource Group**.
80-
81-
:::image type="content" source="./media/tutorial-javascript-overview/visual-studio-code-create-resource-group.png" alt-text="In Resources, select Add (**+**), and then select **Create Resource Group**.":::
82-
1. Enter a resource group name, such as `cognitive-search-website-tutorial`.
83-
1. Select a location close to you.
84-
1. When you create the Cognitive Search and Static Web App resources, later in the tutorial, use this resource group.
85-
86-
Creating a resource group gives you a logical unit to manage the resources, including deleting them when you are finished using them.
60+
[!INCLUDE [tutorial-create-resource-group](includes/tutorial-add-search-website-create-resource-group.md)]
8761

8862
## Next steps
8963

articles/search/tutorial-javascript-create-load-index.md

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -83,30 +83,15 @@ The script uses the Azure SDK for Cognitive Search:
8383
8484
## Review the new Search Index
8585
86-
Once the upload completes, the Search Index is ready to use. Review your new Index.
87-
88-
1. In Visual Studio Code, open the Azure Cognitive Search extension and select your Search resource.
89-
90-
:::image type="content" source="media/tutorial-javascript-create-load-index/visual-studio-code-search-extension-view-resource.png" alt-text="In Visual Studio Code, open the Azure Cognitive Search extension and open your Search resource.":::
91-
92-
1. Expand Indexes, then Documents, then `good-books`, then select a doc to see all the document-specific data.
93-
94-
:::image type="content" source="media/tutorial-javascript-create-load-index/visual-studio-code-search-extension-view-docs.png" lightbox="media/tutorial-javascript-create-load-index/visual-studio-code-search-extension-view-docs.png" alt-text="Expand Indexes, then `good-books`, then select a doc.":::
86+
[!INCLUDE [tutorial-load-index-review-index](includes/tutorial-add-search-website-load-index-review.md)]
9587
9688
## Rollback bulk import file changes
9789
98-
Use the following git command in the VS Code integrated terminal at the `bulk-insert` directory, to roll back the changes. They aren't needed to continue the tutorial and you shouldn't save or push these secrets to your repo.
99-
100-
```git
101-
git checkout .
102-
```
90+
[!INCLUDE [tutorial-load-index-rollback](includes/tutorial-add-search-website-load-index-rollback-changes.md)]
10391
10492
## Copy your Search resource name
10593
106-
Note your **Search resource name**. You'll need this to connect the Azure Function app to your Search resource.
107-
108-
> [!CAUTION]
109-
> While you may be tempted to use your Search admin key in the Azure Function, that isn't following the principle of least privilege. The Azure Function will use the query key to conform to least privilege.
94+
[!INCLUDE [tutorial-load-index-copy](includes/tutorial-add-search-website-load-index-copy-resource-name.md)]
11095
11196
## Next steps
11297

0 commit comments

Comments
 (0)