Static private IP for Azure Container Instance

Alexander Lapin 60 Reputation points
2024-02-22T10:12:24.7466667+00:00

Hi! I have two ACIs in private network. Both containers have private ip address from subnet. But it is dynamic ip addreses. How do I can provide network between two containers if when I restart containers it changes private IP addresses. Maybe there is a DHCP reservation or something else. We also use nat rules for the load balancer, and in order for traffic from an external IP to reach the container, I indicate the internal IP address of the container, and if it changes, then this is of course not a reliable service. Thanks for any help.

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
669 questions
0 comments No comments
{count} votes

Accepted answer
  1. Anveshreddy Nimmala 3,460 Reputation points Microsoft Vendor
    2024-02-23T05:17:14.7566667+00:00

    Hello Alexander Lapin, Welcome to microsoft Q&A, Thankyou for posting your query here. you can set up an internal Azure Load Balancer with a static private IP address to distribute traffic to your Azure Container Instances. This will allow you to ensure consistent access to the containers even if their private IP addresses change. Here are the general steps to set up an internal Azure Load Balancer with a static private IP address: 1.Create an Azure Load Balancer with a static private IP address. When you create the load balancer, be sure to specify the static private IP address that you want to use. 2.Create a backend pool for the load balancer and add your Azure Container Instances to the pool. When you add the container instances to the pool, be sure to specify the private IP addresses of the containers. 3.Create a health probe for the load balancer to monitor the health of the backend pool. 4.Create a load balancing rule for the load balancer to distribute traffic to the backend pool. When you create the rule, be sure to specify the static private IP address of the load balancer as the frontend IP address. Once you have set up the internal Azure Load Balancer with a static private IP address, you can use the IP address of the load balancer to access your Azure Container Instances. The load balancer will distribute traffic to the containers based on the load balancing rule that you created, and it will automatically update the routing as the private IP addresses of the containers change. Hope this answer helps you, please consider accepting the answer to help increase visibility of this question for other members of the Microsoft Q&A community. If not, please let us know what is still needed in the comments so the question can be answered. Thank you for helping to improve Microsoft Q&A!

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. TP 82,661 Reputation points
    2024-02-27T13:32:02.4433333+00:00

    Hi Alexander,

    What I would suggest is to have the container, upon startup, check its private IP and update the required resources (DNS, NAT rule, etc.) if needed before starting to listen for incoming connections. In this way things will not break when the private IP changes. You can enable System Managed Identity and assign necessary permissions so that the container can make changes.

    Reason I say the above is because there currently isn't any way to set static IP for container instances.

    If you need help on specifics of above please let me know more details about your configuration and I can help you work through writing/implementing the code. I'm asking for more details because I'm not 100% clear which resources need to be updated every time private IP changes in your design.

    Please click Accept Answer and upvote if the above was helpful.

    Thanks.

    -TP

    1 person found this answer helpful.
    0 comments No comments