Assign public IP to VM on Microsoft Azure - azure

I have created a VM instance on Windows Azure is a Windows Server 2016 and I have deployed a web application on the server. When I run the web application with localhost or private IP and it's all working fine. But, when I try typing the address with the public IP address that provided by the Azure VM instance, and the page just didn't show up.
I thought the default assigned public IP should have already mapped it to the private IP address?
Please advice.
Thank you.
Updated the NSG setting with the advice. Still no luck!

Have you allow port in NSG inbound firewall settings and OS's firewall inbound rules.
Please follow this article to add port to NSG inbound rules via Azure portal.
Also you should add ports to OS firewall inbound rules.
Note:
NSG can associate to Vnet and Subnet, please check them.
Here a similar case about it.

Azure blocks all ports by default, you need to open port 80 (443 if you are using SSL) and map them to port 80 on the server
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/nsg-quickstart-portal
I think the config is on VMs > Networks > Inbound Rules

Related

AZURE SQL Server - Access trough the Azure Firewall

i have a Question about an Azure SQL Server and the Azure Firewall.
I have configured the Azure SQL Server with Private Endpoints. The Network Hub and Spoke are with peerings connected.
The Private DNS Zone is linked to both Virtual Networks.
The Public Access is disabled on the Azure SQL Server.
No i would like to Use Azure Firewall Rules to Connect from External (WWW) trough the Azure Firewall the Azure SQL Server with Management Studio.
I can find nothing to this Scenario.
I have to tried it with "DNAT / Application NAT / Network Nut" but nothing works.
is it even possible to reach the SQL Database over the Public through the Firewall when the public Access is disabled on the SQL Database?
Thanks a lot.
Regards,
Phil
I tried to reproduce to reproduce the same and tried "DNAT / Application / Network rule it work fine:
I have created a firewall rule with firewall policy like below:
Added application rule:
Network rule:
DNAT rule:
Check your source ip should be your virtual network subnet
Use destination address as the public ip of your firewall and port and translated port as 3389
Translated Address should be your virtual machine private ip address
Then, Go to virtual machine -> Networking -> click on network interface -> under setting DNS server -> custom
Add your destination server 209.244.0.3, 209.244.0.4 same like below:
Make sure to Restart your virtual machine and try to connect remote desktop with you firewall public ip.
After restart when I try to connect with my external www.google.com it works successfully like below:
You can refer my previous answer to connect sql server to access private endpoints.
The Problem is solved.
It workes only when i connect with the Azure SQL Server FQDN and it dont works with other FQDNs for Example CNAMES etc...
I must to edit my Hosts File on the local Machine and Point the FQDN from the SQL Server to the Public IP Address of the Azure Firewall.
On my DNAT Rule i check the Public IP of the Firewall and forward it to the FQDN or the Private IP from the Private Endpoint (both oft this works).
After this the DNAT Rule works and i can connect to the Firewall when i diable the public Access on the Azure SQL Server Firewall directly.
Regards,
Phil

Best practice / way to allow my Azure App Service talk to my Azure Virtual Machine

I have a Azure VM that doesn't have a public IP. It only has a internal IP and it lives in my 'development' environment virtual network on azure. Let's call this vm-dev on the virtual network vnet-dev.
My Azure VM host a Web API that runs on IIS on localhost on this virtual machine. Let's call it CoolWebApi
I have a Azure App Service that is an API that lives on the same environment, let's call it api-dev.
api-dev has a virtual IP address, lets call it 91.195.240.126
1) The only way anyone can get to vm-dev is by going through my Azure Firewall. They need a specific NAT rule to allow them access to that vm. For example, I might have a NAT rule that is like below.
Source IP, Destination IP (Firewall Public IP), Translated Address, Port.
23.44.55.66, 23.674.23.12, 91.195.240.126 (vm-dev lives here), 3389.
The problem is, I want to allow my Azure App Service (api-dev) the ability to make requests to this VM on port 8080. So I think, I'll just make another NAT rule in the firewall and use the api-dev virtual IP / outbound addresses as the source IP, that will work right? Wrong.
I also tried to create inbound rules on my vnet-dev to allow the api-dev virtual ip on port 8080, 443, that also didn't work!
What is the best practice for this? What should I be doing?
At the end of the day, api-dev should be able to make requests to CoolWebApi that lives on vm-dev running on localhost.
You need to create a DNAT rule in Azure Firewall with the Source IP as App Service outbound IPs, and destination IP as Firewall's Public IP and Destination port as "Any IP which is not used by any other service" and translated port as 8080.
You cannot use the same Destination port for 2 DNAT rules.
When you create a DNAT rule, an inbound rule is created implicitly, so you don't necessarily need to create an Network rule here.

Unable to access flask server hosted on azure VM

I have a flask server hosted on my azure vm.
if __name__ == '__main__':
app.run(debug=True, host="127.0.0.1", port=4400)
On vm, I can access the server via the address 127.0.0.1:4400
Now I want to be able to access this server from outside the vm i.e. my local computer.
I have already added the inbound security rule as below:
I have also added the same inbound rule on the VM's firewall on port 4400
Still I am unable to access the flask server via publicIP:4400 (publicIP is the public IP of my VM as displayed on the azure portal)
What could be the issue?
For your issue, there are two possible reasons.
You must listen to the IP 0.0.0.0 so that it's possible to access from the Internet. The 127.0.0.1 is just a loopback IP for the test in the localhost. So 4c74356b41 is right in this way.
If you also cannot access the app from the Internet when you change the IP into 0.0.0.0. Then it must be the rules issue. You should check your VM networking if it's the same NSG for your subnet and NIC. If not, add the rule to allow the port 4400 in both NSGs. Then you also should check if the public IP is associated directly with your VM, or it's associated with the load balancer and your VM is just in the backend of the load balancer. If it's a load balancer, you still need to add the load balancer rule to allow the port 4400.
Take a check for the two possible reasons.

Can't access Azure VM HTTP Web Site from Outside of Azure

I've setup a VM and installed IIS. I checked that the firewall rules were enabled for HTTP and HTTPS. Furthermore, in Azure Portal, I've enabled the two predefined inbound security network group rules for HTTP and HTTPS.
When in the VM, I can go to localhost and see the default Web page of IIS Default Web Site.
Inbound security rule in Network Security Group
Anybody know how to go about figuring out how to make this work?
Thx
You should add port 443 and port 80 to azure VM windows firewall inbound rules.
Are the Source port ranges on your inbound rules set to 80/443 or * (i.e. all source ports)?
Try changing them to * with only the destination ports set to 80 or 443 respectively.
Ex:
Refer How to open ports to a virtual machine with the Azure portal for more details.
There are two ways to make your site accessible from the Internet.
Use the public IP address which is associated to the virtual machine's NIC.
Configure DNS for your VM machine (e.g. web.southeastasia.cloudapp.azure.com). This DNS is bounded to the associated public IP Address.
Reference: https://learn.microsoft.com/en-us/azure/virtual-machines/windows/portal-create-fqdn
In your IIS, just configure binding to make sure the incoming request from the Internet is recognized by IIS.
You also need to make sure you have no rule in Network Security Group (NSG) blocking port 80. Or if there is a NSG, you need to create an inbound rule to allow port 80.
I Azure Windows VM, apart from configuring the NSG rule, we should also create a Windows firewall rule to allow inbound TCP connections on the required port. Just RDP into your windows VM, open Windows Defender Firewall and add the rule

open port on azure while logged onto azure vm

I want to open a port on Azure. I am logged onto Azure VM. After that how to do I open the port?
I tried opening the firewall port but that did not help. I also tried to do it thru azure-cli but it needs web login.
Can I not open a port while logged in onto that Azure VM?
For VMs in azure service management mode:
To open a particular port, say 8080 in your VM, you have to add an endpoint in azure portal, powershell or using xplat-cli. Once this is done, you have created a connectivity between external loadbalancer (I mean VIP of the VM) to the actual VM (with Internal IP address). If the VM is Linux, by default you can start using endpoint (VIP and port) it unless you restrict ports specifically.
For windows VM, for non standard ports, you have to add windows firewall inbound allow rules (say for 8080) inside your VM so that it can accept traffic forwarded from VIP
For VMs in azure resource management:
You have to first create a loadbalancer with VIP, then add NAT rules to forward traffic from VIP to VM. (use load balancing rules if same VIP port forwards traffic to multiple backend VMs)
For windows VM, again windows firewall inbound rules needs to be added
Securing ports:
The above scenario will work by default, but if you want to secure your ports, you have to follow either one of the below, not both.
Use Access control List (ACL): This works at VIP endpoint level. If we want to restrict VIP port 8080 to only few Ip and deny other IP, we can use ACL to add those IPs. This can be done in portal endpoint section/powershell/Xplat-cli
Use Network Security Group (NSG): This works at pheriphery of VM level. We have greater control here to restrict multiple VM ports, port range, etc., but we have to manage those rules. The ports needs to be secured in NSG is the VM internal port whereas in ACL it is the VIP port.
Hope this clarifies
You also need to open the port in the Endpoint settings within the Azure Portal.
Go to Azure Portal -> Your VM -> Settings -> Endpoints and add your Port.
To open a port, you have to it from the azure portal and not in the VM. You can use the NSG (Network Security Group) attached to vm and add a rule in the "Inbound security rules"

Resources