changed the public IP address Aci

brux88 0 Reputation points
2024-05-17T07:34:28.8533333+00:00

I have a container instance where a webaspnet core is hosted with a tcp server that listens on port 5010 (that's why I opted for aci) since the server apps don't allow my solution to work, now I've realized that after a while it has changed the public IP address but I don't understand why. a few days ago I published an update of my dockerized app on ACI but I had checked the IP address and it seemed that with the update it had not changed today after two days that everything was fine, I see that it has changed I would like to understand why, and if there are solutions to avoid it

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

2 answers

Sort by: Most helpful
  1. Vlad Costa 315 Reputation points
    2024-05-17T07:45:08.16+00:00

    The public IP address of an Azure Container Instance (ACI) can change when the container is restarted. This is because ACI uses dynamic IP addresses by default.

    However, there are a few ways to prevent the IP address from changing:

    1. Fully Qualified Domain Name (FQDN): You can create Azure Container Instances with a FQDN, which results in a domain name like your-aci-dns-name.westeurope.azurecontainer.io. This can be done using the Azure CLI with the --dns-name-label option⁴.
    2. Azure Application Gateway: You can expose a static IP by deploying an additional Azure Application Gateway service. This allows you to maintain the public IP that accesses from the Internet.
    3. Static IP Address for a Container Group: You can expose a static IP address for a container group.
    4. Configure a Single Public IP Address for Outbound and Inbound Traffic: You can configure a single public IP address for outbound and inbound traffic to a container group.
    5. Configure a NAT Gateway for Static IP Address for Outbound Traffic: You can configure a NAT gateway for static IP address for outbound traffic from a container group.
    6. Deploy a Container Group with Custom DNS Settings: You can deploy a container group with custom DNS settings.

    Check this similar thread: https://learn.microsoft.com/en-us/answers/questions/1285246/prevent-azure-container-instance-change-ip

    0 comments No comments

  2. Deepanshu katara 6,150 Reputation points
    2024-05-17T07:55:50.84+00:00

    Hi Brux, Welcome to MS Q&A

    By default, ACI provides dynamic public IP addresses. This means the IP address can change whenever the container instance is restarted or redeployed. This includes cases like updates to the container, node maintenance, or scaling operations and currently isn't any way to set static IP for container instances.

    But we can have a work around, 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.

    Please check these docs and images for more ref -->https://learn.microsoft.com/en-us/azure/container-instances/container-instances-overview and https://learn.microsoft.com/en-us/azure/container-instances/container-instances-application-gateway

    User's image

    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.