How to expose multiple ports on Azure Container Instance?

dstj picture dstj · Aug 9, 2017 · Viewed 13.7k times · Source

Is it possible to expose/open more than one port on an Azure Container Instance? I've only been able to open one port per container.

I'd like to run the equivalent of: docker run -p 80:80 -p 443:443 ...

I've unsuccessfully tried:

  • Maps only the last port: az container create ... --port 80 --port 443
  • Syntax error: az container create ... --port 80 443

But the resource JSON seems to indicate that an array is possible:

az container show -name <container-name> --resource-group <resource-group-name>

Response: 
{
  "containers": [
    {
      ...
      "name": "...",
      "ports": [
        {
          "port": 80
        }
      ...
    }
  ],
   ...
  "ipAddress": {
    "ip": "xxx.xxx.xxx.xxx",
    "ports": [
      {
        "port": 80,
        "protocol": "TCP"
      }
    ]
  },
  ...
}

Answer

jluk picture jluk · Feb 8, 2018

This can now be done via Azure CLI. Example is below:

az container create -g MyResourceGroup --name myalpine --image alpine:latest --ip-address public --ports 80 443

https://docs.microsoft.com/en-us/cli/azure/container?view=azure-cli-latest#az_container_create