Connect to private Azure Container Instance

627 views Asked by At

I've a private Azure Container instance running that is part of a Virtual network. I need to connect to that ACI from a public Azure App Service app, which I also added to the same Virtual network.

I am indeed able to connect from the App Service to the ACI via the private ip address, but this ip address changes every time the ACI is redeployed. I've searched and tried stuff like Private DNS but I still need to change the ip manually in that DNS after every redeploy of the ACI. I've searched and tried stuff like Private DNS but I still need to change the ip manually in that DNS after every redeploy of the ACI.

I just need an IP or URL to connect to the private ACI that always works without me manually editing the private ip address when it's changed because of a redeploy. I can't seem to find a solution.

2

There are 2 answers

3
GordonBy On

I'd suggest using a dedicated subnet for the ACI instance (rather than using a subnet for multiple ACI workloads). You can create a small (/29) subnet that will ensure it's not competing for addresses with other workloads.

I've tested deleting then redeploying, it results in the same private IP being used. I've also deployed and programmatically restarted and the ACI instance keeps the same private IP.

0
retrospectacus On

You can use a technique like this to update Private DNS automatically from a sidecar container in your ACI.

https://www.garyjackson.dev/posts/azure-container-instance-dns-private-ip/