Skip to content

Commit f826019

Browse files
committed
workaround for swa YML path issue
1 parent b53642c commit f826019

11 files changed

+94
-55
lines changed

articles/search/includes/tutorial-add-search-website-create-app.md

Lines changed: 60 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
ms.topic: include
3-
ms.date: 07/18/2023
3+
ms.date: 08/29/2023
44
author: HeidiSteen
55
ms.author: heidist
66
ms.service: cognitive-search
@@ -12,73 +12,108 @@ The static web app pulls the information and files for deployment from GitHub us
1212

1313
## Create a Static Web App in Visual Studio Code
1414

15-
1. Select **Azure** from the Activity Bar, then open **Resources** from the Side bar.
15+
1. In Visual Studio Code, open a folder at the repository root (`azure-search-javascript-samples`).
1616

17-
1. Right-click **Static Web Apps** and then select **Create Static Web App (Advanced)**.
17+
1. Select **Azure** from the Activity Bar, then open **Resources** from the side bar.
18+
19+
1. Right-click **Static Web Apps** and then select **Create Static Web App (Advanced)**. If you don't see this option, verify that you have the Azure Functions extension for Visual Studio Code.
1820

1921
:::image type="content" source="../media/tutorial-javascript-create-load-index/visual-studio-code-create-static-web-app-resource-advanced.png" alt-text="Screenshot of Visual Studio Code, with the Azure Static Web Apps explorer showing the option to create an advanced static web app.":::
2022

21-
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**.
23+
1. If you see a pop-up window in Visual Studio Code asking which branch you want to deploy from, select the default branch, usually **main**.
2224

2325
This setting means only changes you commit to that branch are deployed to your static web app.
2426

2527
1. If you see a pop-up window asking you to commit your changes, don't do this. The secrets from the bulk import step shouldn't be committed to the repository.
2628

27-
To roll back 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.
29+
To roll back the changes, in Visual Studio 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.
2830

29-
1. Follow the prompts to provide the following information:
31+
1. Follow the prompts to create the static web app:
3032

3133
|Prompt|Enter|
3234
|--|--|
3335
|Select a resource group for new resources.|Use the resource group you created for this tutorial.|
34-
|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`. |
36+
|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, `my-demo-static-web-app`. |
3537
|Select a SKU| Select the free SKU for this tutorial.|
3638
|Select a location for new resources.|For Node.js: Select `West US 2` during the Azure Function programming model (PM) v4 preview. For C# and Python, select a region near you.|
3739
|Choose build preset to configure default project structure.|Select **Custom**|
3840
|Select the location of your application code|`search-website-functions-v4/client-v4`<br><br>This is the path, from the root of the repository, to your static web app. |
39-
|Select the location of your Azure Functions code|`search-website-functions-v4/api-v4`<br><br>This is the path, from the root of the repository, to your static web app. |
41+
|Select the location of your Azure Functions code|`search-website-functions-v4/api-v4`<br><br>This is the path, from the root of the repository, to your static web app. If there are no other functions in the repository, you won't be prompted for the function code location. Currently, you'll need to perform extra steps to ensure the function code location is correct. These steps are performed after the resource is created and are documented in this article. |
4042
|Enter the path of your build output...|`build`<br><br>This is the path, from your static web app, to your generated files.|
4143

42-
If you get an error about an incorrect region, make sure the resource group and Static web app resource are in one of the supported regions listed in the error response.
44+
If you get an error about an incorrect region, make sure the resource group and static web app resource are in one of the supported regions listed in the error response.
45+
46+
1. When the static web app is created, a GitHub workflow YML file is also created locally and on GitHub in your fork. This workflow executes in your fork, building and deploying the static web app and functions.
47+
48+
Check the status of static web app deployment using any of these approaches:
49+
50+
* Select **Open Actions in GitHub** from the Notifications. This opens a browser window pointed to your forked repo.
51+
* Select the **Actions** tab in your forked repository. You should see a list of all workflows on your fork.
52+
* Select the **Azure: Activity Log** in Visual Code. You should see a message similar to the following screenshot.
53+
54+
:::image type="content" source="../media/tutorial-javascript-static-web-app/visual-studio-code-azure-activity-log.png" alt-text="Screenshot of the Activity Log in Visual Studio Code." border="true":::
55+
56+
1. Currently, the YML file is created with erroneous path syntax for the Azure function code. Use this workaround to correct the syntax. You can perfrom this step as soon as the YML file is created. A new workflow will launch as soon as you push the updates:
57+
58+
1. In Visual Studio Code explorer, open the `./.github/workflows/` directory.
4359

44-
1. The resource is created and a notification window appears.
60+
1. Open the YML file.
4561

46-
When the resource is created, it creates a GitHub action file on GitHub.
62+
1. Scroll to the `api-location` path (on or near line 31).
4763

48-
1. Select **Open Actions in GitHub** from the Notifications. This opens a browser window pointed to your forked repo.
64+
1. Change the path syntax to use a forward slash (only `api_location` needs editing, other locations are here for context):
4965

50-
Wait until the _workflow_ completes before continuing. This may take a minute or two to finish.
66+
```yml
67+
app_location: "search-website-functions-v4/client-v4" # App source code path
68+
api_location: "search-website-functions-v4/api-v4" # Api source code path - optional
69+
output_location: "build" # Built app content directory - optional
70+
```
5171
52-
1. Pull the new GitHub action file to your local computer by synchronizing your local fork with your remote fork:
72+
1. Save the file.
73+
74+
1. Open an integrated terminal and issue the following GitHub commands to send the updated YML to your fork:
75+
76+
```bash
77+
git add -A
78+
git commit -m "fix path"
79+
git push origin main
80+
```
81+
82+
:::image type="content" source="../media/tutorial-javascript-static-web-app/git-yml-path-workaround.png" alt-text="Screenshot of the GitHub commands in Visual Studio Code." border="true":::
83+
84+
Wait until the workflow execution completes before continuing. This may take a minute or two to finish.
85+
86+
<!-- 1. Pull the new GitHub action file to your local computer by synchronizing your local fork with your remote fork:
5387

5488
```bash
5589
git pull origin main
5690
```
5791

5892
* _origin_ refers to your forked repo.
5993
* _main_ refers to the default branch.
94+
-->
6095

61-
1. In Visual Studio file explorer, find and open the workflow file in the `./.github/workflows/` directory. The file path and name looks _something_ `.github\workflows\azure-static-web-apps-lemon-mushroom-0e1bd060f.yml`.
96+
<!-- 1. In Visual Studio file explorer, find and open the workflow file in the `./.github/workflows/` directory. The file path and name looks _something_ `.github\workflows\azure-static-web-apps-lemon-mushroom-0e1bd060f.yml`.
6297

6398
The _part_ of the YAML file relevant to the static web app is shown below:
6499

65-
:::code language="yml" source="~/azure-search-javascript-samples/search-website-functions-v4/example-github-action-v4.yml":::
100+
:::code language="yml" source="~/azure-search-javascript-samples/search-website-functions-v4/example-github-action-v4.yml"::: -->
66101

67102
## Get Cognitive Search query key in Visual Studio Code
68103

69104
1. In Visual Studio Code, open a new terminal window.
70105

71-
1. Get the Query Key with this Azure CLI command:
106+
1. Get the query API key with this Azure CLI command:
72107

73108
```azurecli
74109
az search query-key list --resource-group cognitive-search-demo-rg --service-name my-cog-search-demo-svc
75110
```
76111

77-
1. Keep this query key, you'll need to use it in the next section. The query key is able to query your Index.
112+
1. Keep this query key to use in the next section. The query key authorizes read access to a search index.
78113

79114
## Add configuration settings in Azure portal
80115

81-
The Azure Function app won't return Search data until the Search secrets are in settings.
116+
The Azure Function app won't return search data until the search secrets are in settings.
82117

83118
1. Select **Azure** from the Activity Bar.
84119
1. Right-click on your Static Web Apps resource then select **Open in Portal**.
@@ -93,8 +128,8 @@ The Azure Function app won't return Search data until the Search secrets are in
93128

94129
|Setting|Your Search resource value|
95130
|--|--|
96-
|SearchApiKey|Your Search query key|
97-
|SearchServiceName|Your Search resource name|
131+
|SearchApiKey|Your search query key|
132+
|SearchServiceName|Your search resource name|
98133
|SearchIndexName|`good-books`|
99134
|SearchFacets|`authors*,language_code`|
100135

@@ -104,10 +139,11 @@ The Azure Function app won't return Search data until the Search secrets are in
104139

105140
:::image type="content" source="../media/tutorial-javascript-static-web-app/save-new-application-setting-to-static-web-app-in-portal.png" alt-text="Screenshot of browser showing Azure portal with the button to save the settings for your app..":::
106141

107-
1. Return to VS Code.
108-
1. Refresh your static web app to see the application settings.
142+
1. Return to Visual Studio Code.
143+
144+
1. Refresh your static web app to see the application settings and functions.
109145

110-
:::image type="content" source="../media/tutorial-javascript-static-web-app/visual-studio-code-extension-fresh-resource.png" alt-text="Screenshot of Visual Studio Code showing the Azure Static Web Apps explorer with the new application settings.":::
146+
:::image type="content" source="../media/tutorial-javascript-static-web-app/visual-studio-code-extension-fresh-resource-2.png" alt-text="Screenshot of Visual Studio Code showing the Azure Static Web Apps explorer with the new application settings." border="true":::
111147

112148
## Use search in your static web app
113149

@@ -121,7 +157,6 @@ The Azure Function app won't return Search data until the Search secrets are in
121157
1. In the website search bar, enter a search query such as `code`, 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.
122158
1. Review the results then select one of the books to see more details.
123159

124-
125160
## Troubleshooting
126161

127162
[!INCLUDE [tutorial-troubleshooting](tutorial-add-search-website-troubleshooting.md)]

articles/search/includes/tutorial-add-search-website-troubleshooting.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ If the web app didn't deploy or work, use the following list to determine and fi
1010

1111
* **Did the deployment succeed?**
1212

13-
In order to determine if your deployment succeeded, you need to go to _your_ fork of the sample repo and review the success or failure of the GitHub action. There should be only 1 action and it should have static web app settings for the `app_location`, `api_location`, and `output_location`. If the action didn't deploy successfully, dive into the action logs and look for the last failure.
13+
In order to determine if your deployment succeeded, you need to go to _your_ fork of the sample repo and review the success or failure of the GitHub action. There should be only one action and it should have static web app settings for the `app_location`, `api_location`, and `output_location`. If the action didn't deploy successfully, dive into the action logs and look for the last failure.
1414

1515
* **Does the client (front-end) application work?**
1616

17-
You should be able to get to your web app and it should successfully display. If the deployment succeeded but the website doesn't display, this may be an issue with how the static web app is configured for rebuilding the app, once it is on Azure.
17+
You should be able to get to your web app and it should successfully display. If the deployment succeeded but the website doesn't display, this may be an issue with how the static web app is configured for rebuilding the app, once it is on Azure.
1818

1919
* **Does the API (serverless back-end) application work?**
2020

21-
You should be able to interact with the client app, searching for books and filtering. If the form doesn't return any values, open the browser's developer tools, and determine if the HTTP calls to the API were successful. If the calls weren't successful, the most likely reason if the static web app configurations for the API endpoint name and Search query key are incorrect.
21+
You should be able to interact with the client app, searching for books and filtering. If the form doesn't return any values, open the browser's developer tools, and determine if the HTTP calls to the API were successful. If the calls weren't successful, the most likely reason if the static web app configurations for the API endpoint name and Search query key are incorrect.
22+
23+
If the path to the Azure function code (`api_location`) isn't correct in the YML file, the application loads but won't call any of the functions that provide integration with Cognitive Search. Revisit the workaround in the deployment section for help in correcting the path.

articles/search/includes/tutorial-add-search-website-what-sample-does.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.service: cognitive-search
77
---
88
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.
99

10-
:::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.":::
10+
:::image type="content" source="../media/tutorial-javascript-overview/cognitive-search-enabled-book-website-2.png" alt-text="Screeshot of the sample app in a browser window.":::
1111

1212
The search experience includes:
1313

290 KB
Loading
30.5 KB
Loading
4.66 KB
Loading
23.8 KB
Loading

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ author: diberry
77
ms.author: diberry
88
ms.service: cognitive-search
99
ms.topic: tutorial
10-
ms.date: 07/18/2023
10+
ms.date: 08/29/2023
1111
ms.custom: devx-track-js, devx-track-azurecli, devx-track-azurepowershell
1212
ms.devlang: javascript
1313
---
1414

1515
# 2 - Create and load Search Index with JavaScript
1616

1717
Continue to build your search-enabled website by following these steps:
18+
1819
* Create a search resource
1920
* Create a new index
20-
* Import data with JavaScript using the [sample script](https://github.com/Azure-Samples/azure-search-javascript-samples/blob/main/search-website-functions-v4/bulk-insert-v4/bulk_insert_books.js) and Azure SDK [@azure/search-documents](https://www.npmjs.com/package/@azure/search-documents).
21+
* Import data with JavaScript using the [bulk_insert_books script](https://github.com/Azure-Samples/azure-search-javascript-samples/blob/main/search-website-functions-v4/bulk-insert-v4/bulk_insert_books.js) and Azure SDK [@azure/search-documents](https://www.npmjs.com/package/@azure/search-documents).
2122

2223
## Create an Azure Cognitive Search resource
2324

@@ -54,7 +55,7 @@ The ESM script uses the Azure SDK for Cognitive Search:
5455
1. As the code runs, the console displays progress.
5556
1. When the upload is complete, the last statement printed to the console is "done".
5657
57-
## Review the new Search Index
58+
## Review the new search index
5859
5960
[!INCLUDE [tutorial-load-index-review-index](includes/tutorial-add-search-website-load-index-review.md)]
6061
@@ -66,7 +67,6 @@ The ESM script uses the Azure SDK for Cognitive Search:
6667
6768
[!INCLUDE [tutorial-load-index-copy](includes/tutorial-add-search-website-load-index-copy-resource-name.md)]
6869
69-
7070
## Next steps
7171
7272
[Deploy your Static Web App](tutorial-javascript-deploy-static-web-app.md)

articles/search/tutorial-javascript-deploy-static-web-app.md

Lines changed: 2 additions & 2 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: 07/18/2023
10+
ms.date: 08/29/2023
1111
ms.custom: devx-track-js
1212
ms.devlang: javascript
1313
---
@@ -18,4 +18,4 @@ ms.devlang: javascript
1818

1919
## Next steps
2020

21-
* [Understand Search integration for the search-enabled website](tutorial-javascript-search-query-integration.md)
21+
[Explore the JavaScript search code](tutorial-javascript-search-query-integration.md)

articles/search/tutorial-javascript-overview.md

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,24 @@ author: diberry
77
ms.author: diberry
88
ms.service: cognitive-search
99
ms.topic: tutorial
10-
ms.date: 07/18/2023
10+
ms.date: 08/29/2023
1111
ms.custom: devx-track-js
1212
ms.devlang: javascript
1313
---
1414

1515
# 1 - Overview of adding search to a website
1616

17-
This tutorial builds a website to search through a catalog of books then deploys the website to an Azure Static Web Apps resource.
17+
In this Azure Cognitive Search tutorial, create a web app that searches through a catalog of books, and then deploy the website to an Azure Static Web Apps resource. This tutorial is for JavaScript developers who want to know more about creating a client app that includes user interactions like faceted navigation, typeahead, and pagination. It also demonstrates the `@azure/search-documents` library in the Azure SDK for JavaScript for calls to Azure Cognitive Search for indexing and query workflows.
1818

19-
The application is available:
20-
* [Sample](https://github.com/Azure-Samples/azure-search-javascript-samples/tree/master/search-website-functions-v4)
21-
* [Demo website - aka.ms/azs-good-books](https://aka.ms/azs-good-books)
19+
The source code is available in the [azure-search-javascript-samples](https://github.com/Azure-Samples/azure-search-javascript-samples/tree/master/search-website-functions-v4) GitHub repository.
2220

2321
## What does the sample do?
2422

2523
[!INCLUDE [tutorial-overview](includes/tutorial-add-search-website-what-sample-does.md)]
2624

2725
## How is the sample organized?
2826

29-
The [sample](https://github.com/Azure-Samples/azure-search-javascript-samples/tree/master/search-website-functions-v4) includes the following:
27+
The [sample](https://github.com/Azure-Samples/azure-search-javascript-samples/tree/master/search-website-functions-v4) includes the following components:
3028

3129
|App|Purpose|GitHub<br>Repository<br>Location|
3230
|--|--|--|
@@ -36,7 +34,7 @@ The [sample](https://github.com/Azure-Samples/azure-search-javascript-samples/tr
3634

3735
## Set up your development environment
3836

39-
Install the following for your local development environment.
37+
Install the following software in your local development environment.
4038

4139
- [Node.js LTS](https://nodejs.org/en/download)
4240
- Select latest runtime and version from this [list of supported language versions](../azure-functions/functions-versions.md?pivots=programming-language-javascript&tabs=azure-cli%2clinux%2cin-process%2cv4#languages).
@@ -69,5 +67,4 @@ Forking the sample repository is critical to be able to deploy the Static Web Ap
6967

7068
## Next steps
7169

72-
* [Create a Search Index and load with documents](tutorial-javascript-create-load-index.md)
73-
* [Deploy your Static Web App](tutorial-javascript-deploy-static-web-app.md)
70+
[Create a Search Index and load with documents](tutorial-javascript-create-load-index.md)

0 commit comments

Comments
 (0)