In this exercise we create an Azure Search Skill (in the form of an Azure Function) that takes data from Azure Search and returns a structured json document representing the contents of the pdf Invoice. To get a more in depth treatment of creating an Azure Function please refer to the docs. It is assumed that a storage account has been created (as described in the first demo as well as the Form Recognizer service created in the second demo)
-
Invoice Test Set (used to test the Azure Function)
-
Postman is used to send requests to the Form Recognizer service REST API. Refer to this short primer to learn more.
-
Postman Reader Skill Request collection.
The table below describes the resources created throughout this exercise.
| Name | Type | Purpose |
|---|---|---|
| readerskillstorage | Storage Account | Storage used for Azure Function |
| readerskill | Function App | Cognitive Skill App |
| readerskill | App Insights | Adds insights to Function App |
| EastUS2LinuxDynamicPlan | App Service Plan | Consumption based plan for running Function App (this is created implicitly) |
There are three main steps:
- Run the
InvoiceReaderSkillAzure Function locally - Create resources to support the
InvoiceReaderSkillAzure Function - Run the
InvoiceReaderSkillon Azure
-
Download the InvoiceReaderSkill code found in this repo in Visual Studio Code (make sure the Azure Tools are installed).
-
Add a
local.settings.jsonfile to the folder with the following contents:
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "python",
"AzureWebJobsStorage": "{AzureWebJobsStorage}",
"FormsRecognizerEndpoint": "<YOUR_FORMS_ENDPOINT>.cognitiveservices.azure.com",
"FormsRecognizerKey": "<YOUR_FORMS_KEY>",
"ModelId": "<YOUR_TRAINED_MODEL_ID>"
}
}-
Run the
func host startcommand to start the function. -
Import the Postman Reader Skill Request collection to Postman
-
Open the
Local Forms SkillsRequest and change the Pre-request script to set thestorageAccountvariable to your storage account (in the video the variable isttinvoicestorage) and theSASValueto the appropriate Secure Access Signature to thetraincontainer. To learn how to get a Secure Access Signature, refer to our brief explanation.
pm.environment.set('storageAccount', '<YOUR STORAGE ACCOUNT>')
pm.environment.set('container', 'test')
pm.environment.set('SASValue', '<SAS>')- Verify that the
POSTuri matches the one for the Azure Function (in our running of it we usehttp://localhost:7071/api/AnalyzeInvoice) and click on Send. You should get a response similar to that below:
It is assumed that the following commands are run in the same directory as the actual Function and you have logged into the Azure CLI using az login
- Run the following Azure CLI Commands to create the appropriate resources and publish the function:
Create Function Storage
az storage account create --name {FUNCTION_STORAGE} --location {LOCATION} --resource-group {YOUR_RG} --sku Standard_LRS
Create Function App
az functionapp create --resource-group {YOUR_RG} --consumption-plan-location {LOCATION} --name {FUNCTION_NAME} --storage-account {FUNCTION_STORAGE} --runtime python --os-type linux
Publish Function
func azure functionapp publish {FUNCTION_NAME} --build remote
- Use Visual Studio Code to sync the local settings to the Azure Function by selecting the Azure button, navigating to the newly created function, right clicking on
Application Settingsand selectingUpload Local Settings(NOTE: Do not overwrite the existing variables).
- Browse to the newly created Function App in the portal to add Application Insights to the service.
- Open the
Cloud Forms SkillsRequest and change the Pre-request script to set thestorageAccountvariable to your storage account (in the video the variable isttinvoicestorage) and theSASValueto the appropriate Secure Access Signature to thetraincontainer. To learn how to get a Secure Access Signature, refer to our brief explanation.
pm.environment.set('storageAccount', '<YOUR STORAGE ACCOUNT>')
pm.environment.set('container', 'test')
pm.environment.set('SASValue', '<SAS>')- Verify that the
POSTuri matches the one for the Azure Function (should look something likehttps://<YOUR_ENDPOINT>.azurewebsites.net/api/AnalyzeInvoice) and click on Send. You should get a response similar to that below:
Learn how to tie everything together and finally build the end to end solution by continuing on to Demo 4 - Tying it all together



