Other Articles

Container Instance – Enforce Use of Private Virtual Networks

Secure Configuration Checks > Azure

This check ensures that Azure container groups run inside a private Azure virtual network and use a private IP address, instead of being exposed to the internet through a public IP address.

Check Details

  • Resource: Container Instance (Container Group)
  • Check: Enforce Use of Private Virtual Networks
  • Risk: A container group with a public IP address can be reached from the internet, which increases the risk of unauthorized access and attacks. Running it in a virtual network keeps it isolated and lets you control traffic with network security groups.

Before you start

  • The network settings of a container group cannot be changed after it is created. To fix an existing container group, create a replacement in a virtual network and then delete the old one.
  • The subnet must be delegated to Microsoft.ContainerInstance/containerGroups. A delegated subnet can contain only container groups. A subnet of at least /24 is recommended.
  • Container groups in a virtual network need a NAT gateway for outbound internet access.

Remediation via Azure Portal

  1. Log in to the Azure Portal. Azure Portal dashboard
  2. Navigate to Container instances and find the container group that uses a public IP address. Note its image, CPU, memory and other settings, because you will need them for the replacement. Azure Container instances list
  3. Click Create to create a new container instance with the same settings as the old one.
  4. On the Networking tab, set Networking type to Private.
  5. Select the Virtual network and Subnet to use. The subnet must be delegated to Azure Container Instances, or you can create a new one. Virtual network and subnet selected
  6. Click Review + create, then click Create.
  7. After the new container group is running, delete the old container group that uses the public IP address.

Remediation via Azure CLI

  1. Open Azure Cloud Shell from the Azure Portal or use a local terminal with Azure CLI installed. Azure Cloud Shell
  2. Run the following command to delegate an existing subnet to Azure Container Instances:
    az network vnet subnet update \
    --resource-group <resource-group-name> \
    --vnet-name <vnet-name> \
    --name <subnet-name> \
    --delegations Microsoft.ContainerInstance/containerGroups
    
  3. Run the following command to create the container group in the virtual network:
    az container create \
    --resource-group <resource-group-name> \
    --name <new-container-group-name> \
    --image <image> \
    --vnet <vnet-name> \
    --subnet <subnet-name>
    
  4. Run the following command to delete the old container group that uses a public IP address:
    az container delete \
    --resource-group <resource-group-name> \
    --name <old-container-group-name>
    

    Replace <resource-group-name>, <vnet-name>, <subnet-name>, <new-container-group-name>, <image> and <old-container-group-name> with your actual values.

Updated on 06 November, 2026