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/includes/tutorial-add-search-website-load-index-copy-resource-name.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,4 +8,4 @@ ms.service: cognitive-search
8
8
Note your **Search resource name**. You'll need this to connect the Azure Function app to your search resource.
9
9
10
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.
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.
Copy file name to clipboardExpand all lines: articles/search/includes/tutorial-add-search-website-load-index-review.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,5 +13,4 @@ Once the upload completes, the search index is ready to use. Review your new ind
13
13
:::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 using the search extension.":::
14
14
15
15
1. Expand Indexes, then Documents, then `good-books`, then select a doc to see all the document-specific data.
16
-
17
16
:::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="Expandable screenshot of Visual Studio Code showing documents listed in an index.":::
Copy file name to clipboardExpand all lines: articles/search/tutorial-csharp-create-load-index.md
+15-30Lines changed: 15 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,16 +7,17 @@ author: diberry
7
7
ms.author: diberry
8
8
ms.service: cognitive-search
9
9
ms.topic: tutorial
10
-
ms.date: 08/30/2022
10
+
ms.date: 11/01/2022
11
11
ms.custom: devx-track-csharp
12
12
ms.devlang: csharp
13
13
---
14
14
15
15
# 2 - Create and load Search Index with .NET
16
16
17
17
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/).
20
21
21
22
## Create an Azure Search resource
22
23
@@ -26,7 +27,7 @@ Create a new Search resource with the [Azure Cognitive Search](https://marketpla
26
27
27
28
1. In the Side bar, **right-click on your Azure subscription** under the `Azure: Cognitive Search` area and select **Create new search service**.
28
29
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.":::
30
31
31
32
1. Follow the prompts to provide the following information:
32
33
@@ -45,9 +46,9 @@ Get your Search resource admin key with the Visual Studio Code extension.
45
46
46
47
1. In Visual Studio Code, in the Side bar, right-click on your Search resource and select **Copy Admin Key**.
47
48
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.":::
49
50
50
-
1. Keep this admin key, you will need to use it in [a later section](#prepare-the-bulk-import-script-for-search).
51
+
1. Keep this admin key, you'll need to use it in [a later section](#prepare-the-bulk-import-script-for-search).
51
52
52
53
## Prepare the bulk import script for Search
53
54
@@ -56,22 +57,22 @@ The script uses the Azure SDK for Cognitive Search:
1. In Visual Studio Code, open the `Program.cs` file in the subdirectory, `search-website/bulk-insert`, replace the following variables with your own values to authenticate with the Azure Search SDK:
60
+
1. In Visual Studio Code, open the `Program.cs` file in the subdirectory, `search-website-functions-v4/bulk-insert`, replace the following variables with your own values to authenticate with the Azure Search SDK:
1. Open an integrated terminal in Visual Studio Code for the project directory's subdirectory, `search-website/bulk-insert`, then run the following command to install the dependencies.
67
+
1. Open an integrated terminal in Visual Studio Code for the project directory's subdirectory, `search-website-functions-v4/bulk-insert`, then run the following command to install the dependencies.
67
68
68
69
```bash
69
70
dotnet restore
70
71
```
71
72
72
73
## Run the bulk import script for Search
73
74
74
-
1. Continue using the integrated terminal in Visual Studio for the project directory's subdirectory, `search-website/bulk-insert`, to run the following bash command to run the `Program.cs` script:
75
+
1. Continue using the integrated terminal in Visual Studio for the project directory's subdirectory, `search-website-functions-v4/bulk-insert`, to run the following bash command to run the `Program.cs` script:
75
76
76
77
```bash
77
78
dotnet run
@@ -82,30 +83,14 @@ The script uses the Azure SDK for Cognitive Search:
82
83
83
84
## Review the new Search Index
84
85
85
-
Once the upload completes, the Search Index is ready to use. Review your new Index.
86
-
87
-
1. In Visual Studio Code, open the Azure Cognitive Search extension and select your Search resource.
88
-
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
-
91
-
1. Expand Indexes, then Documents, then `good-books`, then select a doc to see all the document-specific data.
92
-
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
-
95
-
## Copy your Search resource name
96
-
97
-
Note your **Search resource name**. You will need this to connect the Azure Function app to your Search resource.
98
-
99
-
> [!CAUTION]
100
-
> 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.
Use the following git commandin 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.
Copy file name to clipboardExpand all lines: articles/search/tutorial-csharp-deploy-static-web-app.md
+2-106Lines changed: 2 additions & 106 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,118 +7,14 @@ author: diberry
7
7
ms.author: diberry
8
8
ms.service: cognitive-search
9
9
ms.topic: tutorial
10
-
ms.date: 08/30/2022
10
+
ms.date: 11/01/2022
11
11
ms.custom: devx-track-csharp
12
12
ms.devlang: csharp
13
13
---
14
14
15
15
# 3 - Deploy the search-enabled .NET website
16
16
17
-
Deploy the search-enabled website as an Azure Static web app. This deployment includes both the React app and the Function app.
18
-
19
-
The Static Web app pulls the information and files for deployment from GitHub using your fork of the samples repository.
20
-
21
-
## Create a Static Web App in Visual Studio Code
22
-
23
-
1. Select **Azure** from the Activity Bar, then open **Resources** from the Side bar.
24
-
25
-
1. Right-click **Static Web Apps** and then select **Create Static Web App (Advanced)**.
26
-
27
-
:::image type="content" source="media/tutorial-javascript-create-load-index/visual-studio-code-create-static-web-app-resource-advanced.png" alt-text="Right-click **Static Web Apps** and then select **Create Static Web App (Advanced)**":::
28
-
29
-
1. If you see a pop-up window in VS Code asking which branch you want to deploy from, select the default branch, usually **master** or **main**.
30
-
31
-
This setting means only changes you commit to that branch are deployed to your static web app.
32
-
33
-
1. If you see a pop-up window asking you to commit your changes, do not do this. The secrets from the bulk import step should not be committed to the repository.
34
-
35
-
To rollback the changes, in VS Code select the Source Control icon in the Activity bar, then select each changed file in the Changes list and select the **Discard changes** icon.
36
-
37
-
1. Follow the prompts to provide the following information:
38
-
39
-
|Prompt|Enter|
40
-
|--|--|
41
-
|Enter the name for the new Static Web App.|Create a unique name for your resource. For example, you can prepend your name to the repository name such as, `joansmith-azure-search-dotnet-samples`. |
42
-
|Select a resource group for new resources.|Use the resource group you created for this tutorial.|
43
-
|Select a SKU| Select the free SKU for this tutorial.|
44
-
|Choose build preset to configure default project structure.|Select **Custom**|
45
-
|Select the location of your application code|`search-website`<br><br>This is the path, from the root of the repository, to your Azure Static web app. |
46
-
|Select the location of your Azure Function code|`search-website/api`<br><br>This is the path, from the root of the repository, to your Azure Function app. |
47
-
|Enter the path of your build output...|`build`<br><br>This is the path, from your Azure Static web app, to your generated files.|
48
-
|Select a location for new resources.|Select a region close to you.|
49
-
50
-
1. The resource is created, select **Open Actions in GitHub** from the Notifications. This opens a browser window pointed to your forked repo.
51
-
52
-
The list of actions indicates your web app, both client and functions, were successfully pushed to your Azure Static Web App.
53
-
54
-
Wait until the build and deployment complete before continuing. This may take a minute or two to finish.
55
-
56
-
## Get Cognitive Search query key in Visual Studio Code
57
-
58
-
1. In Visual Studio Code, open the [Activity bar](https://code.visualstudio.com/docs/getstarted/userinterface), and select the Azure icon.
59
-
60
-
1. In the Side bar, select your Azure subscription under the **Azure: Cognitive Search** area, then right-click on your Search resource and select **Copy Query Key**.
61
-
62
-
:::image type="content" source="./media/tutorial-javascript-create-load-index/visual-studio-code-copy-query-key.png" alt-text="In the Side bar, select your Azure subscription under the **Azure: Cognitive Search** area, then right-click on your Search resource and select **Copy Query Key**.":::
63
-
64
-
1. Keep this query key, you will need to use it in the next section. The query key is able to query your Index.
65
-
66
-
## Add configuration settings in Azure portal
67
-
68
-
The Azure Function app won't return Search data until the Search secrets are in settings.
69
-
70
-
1. Select **Azure** from the Activity Bar.
71
-
1. Right-click on your Static web app resource then select **Open in Portal**.
72
-
73
-
:::image type="content" source="media/tutorial-javascript-static-web-app/open-static-web-app-in-azure-portal.png" alt-text="Right-click on your JavaScript Static web app resource then select Open in Portal.":::
74
-
75
-
1. Select **Configuration** then select **+ Add**.
76
-
77
-
:::image type="content" source="media/tutorial-javascript-static-web-app/add-new-application-setting-to-static-web-app-in-portal.png" alt-text="Select Configuration then select Add for your JavaScript app.":::
78
-
79
-
1. Add each of the following settings:
80
-
81
-
|Setting|Your Search resource value|
82
-
|--|--|
83
-
|SearchApiKey|Your Search query key|
84
-
|SearchServiceName|Your Search resource name|
85
-
|SearchIndexName|`good-books`|
86
-
|SearchFacets|`authors*,language_code`|
87
-
88
-
Azure Cognitive Search requires different syntax for filtering collections than it does for strings. Add a `*` after a field name to denote that the field is of type `Collection(Edm.String)`. This allows the Azure Function to add filters correctly to queries.
89
-
90
-
1. Select **Save** to save the settings.
91
-
92
-
:::image type="content" source="media/tutorial-javascript-static-web-app/save-new-application-setting-to-static-web-app-in-portal.png" alt-text="Select Save to save the settings for your JavaScript app..":::
93
-
94
-
1. Return to VS Code.
95
-
1. Refresh your Static web app to see the Static web app's application settings.
96
-
97
-
:::image type="content" source="media/tutorial-javascript-static-web-app/visual-studio-code-extension-fresh-resource.png" alt-text="Refresh your JavaScript Static web app to see the Static web app's application settings.":::
98
-
99
-
## Use search in your Static web app
100
-
101
-
1. In Visual Studio Code, open the [Activity bar](https://code.visualstudio.com/docs/getstarted/userinterface), and select the Azure icon.
102
-
1. In the Side bar, **right-click on your Azure subscription** under the `Static web apps` area and find the Static web app you created for this tutorial.
103
-
1. Right-click the Static Web App name and select **Browse site**.
104
-
105
-
:::image type="content" source="media/tutorial-javascript-create-load-index/visual-studio-code-browse-static-web-app.png" alt-text="Right-click the Static Web App name and select **Browse site**.":::
106
-
107
-
1. Select **Open** in the pop-up dialog.
108
-
1. In the website search bar, enter a search query such as `code`, _slowly_ so the suggest feature suggests book titles. Select a suggestion or continue entering your own query. Press enter when you've completed your search query.
109
-
1. Review the results then select one of the books to see more details.
110
-
111
-
## Clean up resources
112
-
113
-
To clean up the resources created in this tutorial, delete the resource group.
114
-
115
-
1. In Visual Studio Code, open the [Activity bar](https://code.visualstudio.com/docs/getstarted/userinterface), and select the Azure icon.
116
-
117
-
1. In the Side bar, **right-click on your Azure subscription** under the `Resource Groups` area and find the resource group you created for this tutorial.
118
-
1. Right-click the resource group name then select **Delete**.
119
-
This deletes both the Search and Static web app resources.
120
-
1. If you no longer want the GitHub fork of the sample, remember to delete that on GitHub. Go to your fork's **Settings** then delete the fork.
0 commit comments