How can I open a UDP port in Azure Container Instance with Static IP address.

Alexander Lapin 60 Reputation points
2024-01-30T15:55:02.4733333+00:00

I have several containers (ACI) and several other Azure services (PostgreSQL, Azure Cache for Redis). I need two containers to have a public IP address. How can I assign these public addresses to these containers so that the UDP port is open? When the address is dynamic it works, but with a static address it doesn’t work for me since Application Gateway allows you to create rules only for HTTP and HTTPS. I really ask you to help.

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
670 questions
{count} votes

Accepted answer
  1. Anveshreddy Nimmala 3,460 Reputation points Microsoft Vendor
    2024-02-01T03:59:05.4166667+00:00

    Hello Alexander Lapin, Thankyou for reverting back here. To allow inbound traffic to a specific port on a container instance, you can use an Azure Load Balancer with an inbound NAT rule. Create an inbound NAT rule maps the public IP address and port to the private IP address and port of the container instance.

    az network lb inbound-nat-rule create --resource-group myResourceGroup \
      --lb-name myLoadBalancer \
      --name myInboundNATRule \
      --protocol udp \
      --frontend-port 1700 \
      --backend-port 1700 \
      --frontend-ip-name myFrontendIP \
      --backend-nic-name myNIC \
      --backend-address-pool myBackendPool
    

    This command creates an inbound NAT rule that maps the public IP address and port 1700 to the private IP address and port 1700 of the container instance. please refer below link to create inbound NAT rule. https://video2.skills-academy.com/en-us/azure/load-balancer/inbound-nat-rules 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. Anveshreddy Nimmala 3,460 Reputation points Microsoft Vendor
    2024-01-31T03:40:53.9866667+00:00

    Hello Alexander Lapin, Welcome to microsoft Q&A, Thankyou for posting your query here. To assign a static public IP address to a container group, you can use a NAT gateway. By configuring a NAT gateway to SNAT a subnet address range delegated to Azure Container Instances (ACI), you can identify outbound traffic from your container groups. The container group egress traffic will use the public IP address of the NAT gateway. A single NAT gateway can be used by multiple container groups deployed in the virtual network's subnet delegated to ACI. Here are the steps to configure a container group in a virtual network integrated with a NAT gateway: Create a virtual network and subnet for the container group. https://docs.microsoft.com/en-us/azure/container-instances/container-instances-vnet. Create a NAT gateway in the virtual network. Configure the NAT gateway to SNAT a subnet address range delegated to Azure Container Instances (ACI). https://docs.microsoft.com/en-us/azure/container-instances/container-instances-nat-gateway. Once you have configured the NAT gateway. you can assign the static public IP address to the container group by specifying the NAT gateway's public IP address in the container group's IP address configuration. https://docs.microsoft.com/en-us/azure/container-instances/container-instances-egress-ip-address Hope this 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!