question

MdFarmanKhan-0117 avatar image
1 Vote"
MdFarmanKhan-0117 asked GaryJackson-5658 answered

Azure container Instance in a Vnet doesn't support static IP or DNS name

Hi,

I am deploying containers in ACI group in a private V-Net and the main problem which I am facing is that this doesn't support a DNS name label and also I can't set a static IP to it. As the IP is not static and there is no DNS name label, when we stop the containers then there is no guarantee that the private IP will remain the same when we start it again.

As the ACI group IP is required to access the apps running in the containers through an API end point and on the instance of IP change we have to change the IP everywhere again, which is not feasible.

Another disadvantage is that, as we can't set a pre-defined IP address for ACI the IP address will only be known after the ACI is started in Azure. This way we can't provide the ACI IP/URI as our environment variable in ACI YAML script which is required in our app to send the app API URI to other apps.

The above problems will be resolved if we deploy ACI publicly, but as this method has no restriction and no NSG support, we can no way afford to expose our Application APIs in the open internet.

Please suggest how to tackle this issue of absence of static IP or DNS name label in an ACI in private V-Net.

Thank You.

azure-container-instances
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

karishmatiwari-msft avatar image
0 Votes"
karishmatiwari-msft answered AdamDay-0228 edited

This can be achieved by registering the IP address of your ACI container in your DNS. Please try that and let me know if you have any questions.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

As far as i know, the issue is that once the ACI container restarts the dns record does not get update.

0 Votes 0 ·

That is correct, I'm fighting with the exact same issue. Even worst, when Microsoft does some maintenance on the underlying Kubernetes nodes, the IP can change and then you wake up in the morning and nothing works anymore.

2 Votes 2 ·

Hello @ManuelMoya-7074 ,
did you find a way to tackle with the container IP change ? and or DNS update ?

0 Votes 0 ·
AdamDay-0228 avatar image
0 Votes"
AdamDay-0228 answered GaryJackson-5658 published

The best solution we could come up for this issue with was to create a Private DNS zone, give the container's service principal or identity Private DNS Zone Contributor access, and run the following as part of the entrypoint script for the container:

 az network private-dns record-set a update --name <name> -g <resource-group> -z <zone-name> --set aRecords[0].ipv4Address=$(hostname -i)

I'd imagine a similar solution will work using other APIs or with public DNS Zones.

This is the only way that currently seems to handle the rotation of the the IPs on container startup.

Note, I'd really like to see similar functionality built into the Container Instance offering to make them more functional out of the box.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks mate, I used this approach with a slightly modification.

I didn't want to have the Azure Cli installed on my main container, so I deployed another container within the same Container group with the Azure Cli docker image.
Then I ran the commands from there.

The containers in a container group share a lifecycle

The image I used is:
https://hub.docker.com/_/microsoft-azure-cli

0 Votes 0 ·