See https://docs.microsoft.com/en-us/azure/container-instances/container-instances-quickstart
- Login into azure cli
az login
- Create a resource group
az group create --name "$ACI_GROUP" --location $LOCATION
- Create a container instance
az container create --name "$ACI_HELLO_NAME" --image microsoft/aci-helloworld --resource-group "$ACI_GROUP" --ip-address public
- Confirm creation
az container show --name "$ACI_HELLO_NAME" --resource-group "$ACI_GROUP"
- Pull container logs
az container logs --name "$ACI_HELLO_NAME" --resource-group "$ACI_GROUP"
- Cleanup the resource group
az group delete --name "$ACI_GROUP" --yes
az container delete --resource-group "$ACI_GROUP" --name "$ACI_HELLO_NAME" --yes
https://docs.microsoft.com/en-us/azure/container-instances/container-instances-tutorial-deploy-app /~https://github.com/Azure-Samples/aci-helloworld
- Set Docker Host (https://docs.docker.com/machine/reference/env/) Check in the Docker Daemon in "General" the setting "Expose daemon on tcp://localhost:2375 without TLS"
sudo apt install docker.io
export DOCKER_HOST=tcp://127.0.0.1:2375
- Create container registry https://docs.microsoft.com/en-us/azure/container-registry/container-registry-intro
REGISTRY_NAME="hellodemodz234"
az acr create --resource-group "$RESOURCE_GROUP" --name "$REGISTRY_NAME" --sku Basic --admin-enabled true
- Get login info (eval used because of the double quotation)
Get the registry login server
az acr show --name "$REGISTRY_NAME" --query loginServer
REGISTRY_URL=$(az acr show --name "$REGISTRY_NAME" --query loginServ
er)
Get the login password
az acr credential show --name "$REGISTRY_NAME" --query passwords[0].value
or automate it
REGISTRY_URL=$(az acr show --name "$REGISTRY_NAME" --query loginServer)
REGISTRY_PASSWORD=$(az acr credential show --name "$REGISTRY_NAME" --query passwords[0].value)
eval "docker login --username="$REGISTRY_NAME" --password=$REGISTRY_PASSWORD $REGISTRY_URL"
- Pull, tag and push the latest image to the registry
docker pull microsoft/aci-helloworld
eval "docker tag microsoft/aci-helloworld $REGISTRY_URL/aci-helloworld:v1"
eval "docker push $REGISTRY_URL/aci-helloworld:v1"
or
docker tag microsoft/aci-helloworld hellodemo345.azurecr.io/aci-helloworld:v1
docker push "hellodemo345.azurecr.io/aci-helloworld:v1"
- Clone the source code depot. Build the image and push it to the registry. Run it on a new container instance.
git clone /~https://github.com/Azure-Samples/aci-helloworld.git
cd aci-helloworld
less Dockerfile
docker build -t aci-tut-app .
docker images
eval "docker tag aci-tut-app $REGISTRY_URL/aci-tut-app:v1"
eval "docker push $REGISTRY_URL/aci-tut-app:v1"
CONTAINER_APP_NAME="acihelloworldapp"
az container create -g $RESOURCE_GROUP --name $CONTAINER_APP_NAME --image hellodemo345.azurecr.io/aci-tut-app:v1 --registry-password $DOCKER_PASSWORD
-
Build an image task with image name using the repo name and the build id as label
$(Build.Repository.Name):$(Build.BuildId)
Since this has to run on a private agent go for VSTS Build Agent Setup and configure one. The overall launch task is very simple:
-
Take a azure cli task from the marketplace and configure it to use your agent.
-
Configure the azure cli task to use the following arguments:
-
Configure the variables and registry password (put lock on it):
az container create --name "aci$(RegistryName)$(BUILD.BUILDID)" --image "$(RegistryUrl)/denniszielke/aci-helloworld:$(BUILD.BUILDID)" --resource-group "helloworld" --ip-address public --registry-password $(RegistryPassword)