'How to create a private VM on azure with internet access

I want to provision a VM which has no public ip so it can only be connected from other VM who have public ip. Now i can create a VM without public ip but then it does not have a internet access.

Now is there a way on Azure like on AWS where i can provision a NAT gateway or NAT instance on public subnet and let the private instances have internet connection

I also tried using NAT Gateway on Azure but it doesn't work unless i assign public ip to VM which is not what i want

I have two subnets lets say public_subnet & private_subnet , now i can ssh to my private vm from a jump but the thing is when i login to my private vm i cant install any package or even not able to ping or curl to any website. Both subnets were created using terraform so the configuration of subnets are all same there is no change is subnet configuration



Solution 1:[1]

Azure VMs have internet access by default, you dont have to do anything for them to have outbound access. It just works. Even without the public IP

Solution 2:[2]

There's two possibilities:

First one, under the same Vnet, you provision you VM without a public ip adress and then access it using Azure Bastion. You can find more details here.

Second one, is to provision two or more VMs in the same subnet one with public IP and the other without a public IP. and then access the one with private IP from the one with public IP.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Makram