I'd like to use Azure Container instances to run a long (10 mins) analysis test using a legacy app. When an item appears in CosmosDB, I want to trigger the launch of a new container instance.
The container will have a lightweight proxy that will pull the data from CosmosDB, write it to container file system, run the legacy app, get the output and push it back to CosmosDB.
Cosmos is just an example. Could be blob, or anything else that can store a few Mbs of data.
Is it possible to trigger the creation of new containers in this way? Any references/sample code?
You can trigger the container to run either from Logic Apps, or Azure Function. There are samples for both cases:
Event driven using function: https://github.com/Azure-Samples/aci-event-driven-worker-queue
Trigger using Logic Apps: https://github.com/Azure-Samples/aci-logicapps-integration
Another way I've found to do this:
Use an Event Grid subscription to trigger an Azure Automation runbook (by means of a webhook created on that runbook). In my case, the Event Grid reacts to a storage account event, namely blob creation. The runbook in turn starts the container group by means of a Powershell script like the following:
Select-AzureRmSubscription -SubscriptionName "yourSubscription"
Invoke-AzureRmResourceAction -ResourceGroupName yourResourceGroup -ResourceName yourContainerGroupName -Action Start -ResourceType Microsoft.ContainerInstance/containerGroups -Force
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With