Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Azure Container Instances be invoked using triggers?

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?

like image 355
dommer Avatar asked May 24 '18 18:05

dommer


2 Answers

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

like image 51
Anders Avatar answered Sep 24 '22 23:09

Anders


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
like image 21
Colin Catlin Avatar answered Sep 24 '22 23:09

Colin Catlin