Skip to content

Instantly share code, notes, and snippets.

View vkurpad's full-sized avatar

Vinod Kurpad vkurpad

View GitHub Profile
!pip install azure-ai-formrecognizer
!pip install azure-storage-blob
def train_model(form_training_client, container_sas_url, container_name):
poller = form_training_client.begin_training(
container_sas_url, use_training_labels=True, model_name=container_name
)
model = poller.result()
@vkurpad
vkurpad / Reprocessor
Last active February 12, 2020 21:49
Building an Azure Cognitive Search enrichment pipeline that supports rapid iterations
For this scenario we are going to extend the [km-aml solution accelerator](https://github.com/microsoft/solution-accelerator-km-aml) to use a custom corpus. The goal is to start with corpus of data.
1. Skim through the documents to identify a set of entities that should be recognized
2. Create a list of entities
3. Create a enrichment pipeline with a skill that takes in the list of entities and labels the text with IOB tags
4. Train a custom entity classifier on this labeled dataset
5. Update the enrichment pipeline to use the newly minted entity classifier
6. Reprocess the documents to now identify the labeled entities and other similar entities
{
"apiVersion": "2016-04-01",
"type": "Microsoft.Cache/Redis",
"name": "andersencache",
"location": "centralus",
"properties": {
"sku": {
"name": "Basic",
"family": "C",
@vkurpad
vkurpad / gist:e82f9498723bcd5b21793db5bfea9c36
Last active January 7, 2017 21:11
Azure Functions Execution Errors and Poison Queues in Azure Storage
Recently I was asked the question on how to be notified when your Azure Function pushes a message into a poison queue as a result of execution errors. My approach to the problem is a little different and I thought I'd share it here. If you've got an alternate solution, please do share and lets keep the conversation going.
In general rather than rely on the Azure Functions runtime to write the message to a poison queue, I'm checking the dequeue count of the message and at the 5th attempt, I'm ensurig a successful completion by just writing the message out to a queue I use for exception processing. The documentation (https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage) has more information on the dequeueCount and other attributes. Aagin this is not a substitute for a Try-Catch but just an additional precaution.
Here's an example C# Azure Function where I simply try to convert the message content to an int with no exception handling, if the message is a string, I'll endup with the