Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I kick off a container instance using the Azure api?

I have a container building in gitlab and registering itself with the gitlab custom registry. Inside this container is a command that runs a very long time. I would like to somehow deploy this container to azure, and only kick off this long running process inside a new container instance on demand from an administrative api service. I don't want the container running all the time, only for the time it takes to run the command.

I was thinking that this admin api could be a classic http rest api service hosted under Azure "App Services", or possibly using the new "Function Apps" feature of Azure.

In my research, I found that using the azure cli commands, I can start a container like so:

az container create \
    --resource-group myResourceGroup \
    --name mycontainer2 \
    --image microsoft/aci-wordcount:latest \
    --restart-policy OnFailure \
    --environment-variables NumWords=5 MinLength=8

https://learn.microsoft.com/en-us/azure/container-instances/container-instances-environment-variables

I would like to do this from the admin api, preferably using what looks to me like the official Azure npm package located here:

https://www.npmjs.com/package/azure

Ideally, it would be a single command to create and start the instance, being able to set the environment variables like this example at the launch of the container is important to me. I'm not interested in moving all my code over into Azure, I would like to continue using gitlab for the source code and container registry but if there is some reason I have to switch to using the Azure container registry, I need a way to somehow move the container registration over there using the gitlab ci yaml.

In all my searching, I couldn't find any way to do this but the closest documentation I found was here:

https://learn.microsoft.com/en-us/javascript/api/azure-arm-containerservice/containerserviceclient?view=azure-node-latest

like image 822
slf Avatar asked Sep 25 '18 17:09

slf


Video Answer


1 Answers

At the current time there is no way to officially do this from the api, maybe in the future there will be

like image 130
slf Avatar answered Oct 19 '22 20:10

slf