Config maps for Azure Container Instances (Preview)

A config map is a property that can be used to apply container configurations similar to environment variables and secret volumes. However, unlike when using environment variables or secret volumes where restarting the pod to apply the settings is required, apply settings using a config map does not require any restarts for the changes to take effect.

Azure Container Instances can be created with or without config maps and can be updated at any point in time post creation using config maps. Updating config maps in an existing running container group can be accomplished quickly without compromising uptime of the container.

How it works

A config map can be included in the container properties or in a container group profile. Creating a container group profile with the config map settings makes applying those settings simple and easy to automate.

Create a container group profile with config map settings

Create a container group profile with config map settings using az container container-group-profile create.

az container container-group-profile create \
    --resource-group myResourceGroup \
    --name myContainerGroupProfile \
    --location WestCentralUS \
    --image nginx \
    --os-type Linux \ 
    --ip-address Public \ 
    --ports 8000 \ 
    --cpu 1 \
    --memory 1.5 \
    --restart-policy never \
    --config-map key1=value1 key2=value2

Apply config map settings using a container group profile

Applying the config map settings stored in a container group profile requires updating the container and specifying the container group profile that should be associated with the update.

Apply the config map settings stored in the container group profile using az container create.

az container create 
        --resource-group myResourceGroup \ 
        --name myContainer \ 
        --location WestCentralUS \
        --container-group-profile-id "/subscriptions/{SubscriptionID}/resourceGroups/myResourceGroup/providers/Microsoft.ContainerInstance/containerGroupProfiles/myContainerGroupProfile" \
        --container-group-profile-revision 1 

Apply config map settings without container group profile

Config map settings can also be applied directly to the instance by specifying the config map settings in the create commands.

Apply the config map settings using az container create.

az container create \
    --resource-group myResourceGroup \ 
    --name myContainer \
    --location WestCentralUS \ 
    --config-map key1=value1 key2=value2 
        

Once the update has been applied to an existing container and you will see the values mounted in the container without requiring a restart.

/mnt/configmap/<containername>/key1 with value as “value1”

/mnt/configmap/<containername>/key2 with value as “value2”

Next steps

Learn how to use config maps with standby pools to increase scale and availability