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-custom-skill-form.md
+9-6Lines changed: 9 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,18 +34,21 @@ Clone the [Azure Search Power Skills](https://github.com/Azure-Samples/azure-sea
34
34
35
35
<!-- TBD you don't change those variables, you add debug env variables to the project -->
36
36
37
-
Open _AnalyzeForm.cs_ and make the following changes.
38
-
* Set the `formsRecognizerApiEndpoint` variable to your resource endpoint.
39
-
* Set `formsRecognizerApiKeySetting` to your resource's key value.
40
-
* Set `modelIdSetting` to your saved model ID.
37
+
Open _PowerSkills.sln_ in Visual Studio and locate the **AnalyzeForm** project on the left pane. Then make the following changes.
38
+
* Add project-level environment variables. Right-click the project file and select **Properties**. In the **Properties** window, click the **Debug** tab and then find the **Environment variables** field. Click **Add** to add the following variables:
39
+
*`FORMS_RECOGNIZER_ENDPOINT_URL` with the value set to your endpoint URL.
40
+
*`FORMS_RECOGNIZER_API_KEY` with the value set to your subscription key.
41
+
*`FORMS_RECOGNIZER_MODEL_ID` with the value set to the ID of the model you trained.
42
+
*`FORMS_RECOGNIZER_RETRY_DELAY` with the value set to 1000. This is the time in milliseconds that the program will wait before re-querying the service for a response.
43
+
*`FORMS_RECOGNIZER_MAX_ATTEMPTS` with the value set to 100. This is the number of times the program will query the service while attempting to get a success response.
41
44
42
-
Next, find the `fieldMappings` variable. This variable defines the list of keys you want to extract from your forms and a custom label for each key. For example, a value of `{ "Address:", "address" }, { "Invoice For:", "recipient" }` means the script will only save the values for the `Address:` and `Invoice For:` keys.
45
+
Next, open _AnalyzeForm.cs_ and find the `fieldMappings` variable, which references the field-mappings.json file. This file (and the variable that references it) defines the list of keys you want to extract from your forms and a custom label for each key. For example, a value of `{ "Address:", "address" }, { "Invoice For:", "recipient" }` means the script will only save the values for the detected `Address:` and `Invoice For:` keys, and it'll label those values with `"address"` and `"recipient"`, respectively.
43
46
44
47
Finally, note the `contentType` variable. This script runs the given Form Recognizer model on PDF files, but if you're working with a different file type, you need to change the `contentType` to the correct [MIME type](https://developer.mozilla.org/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types) for your file.
45
48
46
49
## Test the function from Visual Studio
47
50
48
-
After you've edited your script, save it and set the **AnalyzeForm** project as the startup project in Visual Studio. Then Press **F5** to run it in your local environment. Use a REST service like Postman to call the function.
51
+
After you've edited your project, save it and set the **AnalyzeForm** project as the startup project in Visual Studio. Then Press **F5** to run it in your local environment. Use a REST service like Postman to call the function.
0 commit comments