- Challenge 5 - Deployment should be done successfuly.
Create two new Azure Functions written in Node.js, using the Azure portal. These will be triggered by Event Grid and output to Azure Cosmos DB to save the results of license plate processing done by the ProcessImage function.
-
Navigate to the function app "Events"
-
Create a function that is triggered by event grid (install extensions if prompted)
- Name : SavePlateData
-
Replace the code with the following:
module.exports = function(context, eventGridEvent) { context.log(typeof eventGridEvent); context.log(eventGridEvent); context.bindings.outputDocument = { fileName: eventGridEvent.data['fileName'], licensePlateText: eventGridEvent.data['licensePlateText'], timeStamp: eventGridEvent.data['timeStamp'], exported: false }; context.done(); };
-
Add an event grid subscription
- Name should contain "SAVE"
- Event Schema: Event Grid Schema.
- Topic Type: Event Grid Topics.
- Resource: your recently created Event Grid.
- Event Type : Add
savePlateData
- Endpoint : Leave As Is
-
Add a Cosmos DB Output to the function (install extensions if needed)
- Select the Cosmos DB account created earlier
- Database Name : LicensePlates
- Collection Name : Processed
-
Create another function that is triggered by event grid
- Name : QueuePlateForManualCheckup
-
Replace the code with the following:
module.exports = async function(context, eventGridEvent) { context.log(typeof eventGridEvent); context.log(eventGridEvent); context.bindings.outputDocument = { fileName: eventGridEvent.data['fileName'], licensePlateText: '', timeStamp: eventGridEvent.data['timeStamp'], resolved: false }; context.done(); };
-
Add an event grid subscription
- Name should contain "QUEUE"
- Event Schema: Event Grid Schema.
- Topic Type: Event Grid Topics.
- Resource: your recently created Event Grid.
- Add Event Type
queuePlateForManualCheckup
- Leave Azure Function as the Endpoint Type.
-
Add a Cosmos DB Output to the QueuePlateForManualCheckup function
- Select the Cosmos DB account connection created earlier
- Database Name : LicensePlates
- Collection Name : NeedsManualReview
- Both functions do not have any compillation errors
- Both functions have event grid subscriptions
- Both functions have Cosmos DB as their outputs
Description | Links |
Create your first function in the Azure portal | https://docs.microsoft.com/azure/azure-functions/functions-create-first-azure-function |
Store unstructured data using Azure Functions and Azure Cosmos DB | https://docs.microsoft.com/azure/azure-functions/functions-integrate-store-unstructured-data-cosmosdb |