title: What is the proper way to expose an Azure Container Instance that is inside a vnet?
body: <p>I have an ACI that is running a REST API that needs to be exposed publicly, but needs to access resources inside a vnet.</p>
  <p>For some reason, unlike normal VMs, if an ACI is inside a vnet, it cannot have a public IP address. If you try to give it a DNS name it fails.</p>
  <p>The only option seems to be to use an Application Gateway as described here:
  <a href="https://docs.microsoft.com/en-us/azure/container-instances/container-instances-application-gateway" rel="noreferrer">https://docs.microsoft.com/en-us/azure/container-instances/container-instances-application-gateway</a></p>
  <p>And also here: <a href="https://stackoverflow.com/questions/53815807/assign-static-public-address-to-azure-container-instance-deployment/53816830#53816830">Assign Static Public Address to Azure Container Instance deployment</a></p>
  <p>But this approach has a fatal flaw, as indicated in the documentation itself: &quot;If the container group is stopped, started, or restarted, the container group's private IP is subject to change. If this happens, you will need to update the application gateway configuration.&quot;</p>
  <p>The Application Gateway has the option to select a backend pool by resource name, but this is only for normal VMs. The other option is to put in the IP address directly.</p>
  <p>An ACI can easily get restarted without knowing. From experience, it happens relatively often that the host kills it and restarts it, possibly taking a different IP.</p>
  <p>What is the right approach to expose a service running on an ACI instance on the internet, and at the same time have it access resources behind a vnet? The Application Gateway approach is evidently not the right approach.</p>
  <p>I need a solution that can work easily with Azure CLI, since I am deploying my ACI through Bitbucket Pipes.</p>
  <p><strong>UPDATE:</strong></p>
  <p>Azure Container Instances are just a pile of junk. The only way to expose them from a vnet is to use an Application Gateway, which after a month running it, ends up costing more than the Container Instance itself! Moreover, Azure Container Instances are very unstable in certain regions (in West EU they keep getting killed), with support not understanding what is going on (apparently its an issue with multiple customers). So every time the instance gets restarted, it will get a different IP address, and the costly Application Gateway, which can run into over $100 per month, won't even know that the IP address changed.</p>