How To Figure Out IP Address For Azure Functions

How To Figure Out IP Address For Azure Functions

In this Azure tutorial, we will discuss How To Figure Out IP Address For Azure Functions. Along with this, we will also discuss a few other topics Azure Function Static Outbound IP, Azure Function Outbound IP Addresses using PowerShell and we also discussed Azure Function Whitelist IP Address, Azure Function App Storage Account Firewall, Azure IP Address, How Do I Find The IP Address Of My Azure VM?.

How To Figure Out IP Address For Azure Functions? You can find out the IP Address of the Azure Function using the Azure Portal and also, you can find the Outbound Ip Address of the Azure Functions using the Azure Resource Explorer.

Below we will discuss the steps to figure out the IP Addresses of the Azure Function App in details.

How To Figure Out IP Address For Azure Functions

Well, here we will discuss How To Figure Out IP Address For Azure Functions. Let me make you clear one thing here that when we are thinking of the IP Address for Azure Functions, It is actually the IP address of the Azure Function App, not the individual Azure Function.

When we are discussing the IP address of the Azure Function App, two categories of the IP Address are coming in to picture. InBound IP address and OutBound IP Address.

How To Figure Out InBound IP Address For Azure Functions

Ok, let’s see How to figure out inbound IP address for Azure Functions using the Azure Portal. Follow the below steps to figure out the inbound IP address for the Azure Functions using the Azure Portal.

Login to the Azure Portal (https://portal.azure.com/)

The next step is to navigate to the Azure Function App for which one you want to figure out

How To Figure Out InBound IP Address For Azure Functions

Then the next step is to click on the Properties link from the left navigation on the Azure Function App page. Now you can see the IP Address under the Virtual IP Address as highlighted below.

How To Figure Out IP Address For Azure Functions

This is how you can Figure Out InBound IP Address For Azure Functions using the Azure Portal.

How To Figure Out OutBound IP Address For Azure Functions

Above we discussed, How To Figure Out InBound IP Address For Azure Functions. Now we will discuss How To Figure Out OutBound IP Address For Azure Functions using the Azure Resource Explorer.

Azure Function Static Outbound IP

Login to the Azure Resource Explorer (https://resources.azure.com/)

Once you are logged in to the Azure Resource Explorer, The next step is to Expand the Subscription node and then select your correct Subscription.

How To Figure Out OutBound IP Address For Azure Functions

Now you need to select the Microsoft.Web and then choose Sites.

How To Figure Out OutBound IP Address of Azure Functions

Now search for the Azure Function for which one, you want to see the outboundIpAddress. You can able to see the IP Address for the outboundIpAddresses and possibleOutboundIpAddresses in the JSON panel as mentioned below.

How To Figure Out IP Address For Azure Function

This is how you can figure Out OutBound IP Address For Azure Functions.

Azure Function Outbound IP Addresses using PowerShell

You can also able to get the Outbound IP Addresses of the Azure Function using PowerShell. You can use the below PowerShell cmdlets to get the OutboundIpAddresses

(Get-AzWebApp -ResourceGroup newresgroup -name BlobTriggerAzureFunctionApp).OutboundIpAddresses

The complete script will be as below. For Tenant (Provide the tenant ID) and Subscription (Provide the Subscription ID)

Connect-AzAccount -Tenant xxxxx-0310-474d-xxxx-42df2d549228 -Subscription rttyyu-fggg-4518-9c9c-hjjkjhhhjj
(Get-AzWebApp -ResourceGroup newresgroup -name BlobTriggerAzureFunctionApp).OutboundIpAddresses

You can see the Output as below

Azure Function Outbound IP Addresses using PowerShell

You can able to retrieve the PossibleOutboundIpAddress for the Azure Functions using the below PowerShell cmdlets

(Get-AzWebApp -ResourceGroup newresgroup -name BlobTriggerAzureFunctionApp).PossibleOutboundIpAddresses

The Complete script will be as below

Connect-AzAccount -Tenant xxxxx-0310-474d-xxxx-42df2d549228 -Subscription rttyyu-fggg-4518-9c9c-hjjkjhhhjj
(Get-AzWebApp -ResourceGroup newresgroup -name BlobTriggerAzureFunctionApp).PossibleOutboundIpAddresses

You can see the OutPut as below

How retrieve Azure Function Outbound IP Addresses using PowerShell

This is how you can able to retrieve Azure Function Outbound IP Addresses using PowerShell

Azure Function Whitelist IP Address

In real-time, we will meet with the scenario where In order to Secure your Azure Function App, you need to allow some specific set range of IP addresses that are authorized by your Organisation and you need to restrict all other IP addresses that are unauthorized as per your organization. This is called whitelisting.

In order to whitelist IP address for the Azure function, Follow the below steps

Log in to the Azure Portal (https://portal.azure.com/)

Once you logged in to the Azure Portal, Navigate to the Azure Function App

Azure Function Whitelist IP Address

On the Azure Function App page, click on the Networking option from the left side navigation and then click on the Configure Access restrictions under the Access Restrictions options

How to Whitelist IPs in Azure Functions

On the Access Restrictions page, Click on the + Add rule button to add a new rule for this Azure Function App.

How to Whitelist IPs in Azure Function

Now on the Add Access Restriction page, Provide the below details

  • Name: Provide the name Add Access Restriction rule.
  • Action: Choose the Action based on your business need. You can choose the Allow or Deny option.
  • Priority: You need to provide the value as a number to set the Priority.
  • Description: This is optional. If you want you can put a description of the rule.
  • Type: You can choose the Type as IPV4.
  • IP Address Block: For this option, we need to provide the IP address value that we want to allow or deny.

Finally, click on the Add rule button to add the rule

Azure Function Whitelist IP Address

You can able to see the New rule has been added successfully.The deny all rule will be added automatically.

Azure Function Whitelist IP Address using Azure Portal

Now You can update the rule also by clicking on the rule and modify the value and Finally, click on the Update Rule button to save the changes. Now I have updated the action value from Allow to Deny.

Azure Function Whitelist IP Address  Azure Portal

Now when I am trying to access the Azure Function App from the IP mentioned above, You can able to see below, it is not allowing me to access the Azure Function and showing me Error 403 – Forbidden.

azure app service whitelist ip

This is how You can now able to secure your Azure Functions app by using the whitelisting IP address method.

Azure Function App Storage Account Firewall

When you will try to run the Azure Function App against the storage account with a firewall, then you can able to access it if your storage account and resources are in different regions, else you will get an error while trying to access it. In this scenario, the traffic goes over the external IP addresses.

But when you are trying to hit the storage account from your Azure function so since both are in the same regions. It is dealing with the internal IPs so it is not actually allowed over the firewall. The overall reason here is you are not authorized to access the internal IP address of the Azure Function.

You might get the error “500 Internal Server Error – This request is not authorized to perform this operation”.

Azure IP Address

Azure resources have their own IP address. The Public IP address helps the resources to communicate with each other, as well as the public IP address also helps to communicate with the internet and all the Public facing Azure services.

The public IP address of the Azure resources is unique for each one of the resources. Public IP addresses are created based on the IPV4 and IPV6 format.

You can associate the public IP addresses to many Azure resources like Virtual Machine, Load Balancer, Applicationgateways, etc.

In the case of Azure Virtual Machine, you can associate a public IP address via the network interface. The IP address can be static or dynamic.

In the case of a Load balancer, We can able to associate a public IP address. here also, you can make the IP address as static or dynamic.

You can able to associate a public IP address in case of a Application gateway via the front end configuration.

Download Azure IP Addresses

You can get the file from Microsoft official site that contains the Azure IP address ranges. This contains the IP related to many Azure services like SQL, Storage, etc. The file contains only IPV4 format as of now. You can download the file now.

Does virtual machine have its own IP address?

The answer is Yes, The virtual machines are like physical computers. A virtual machine can have one or more IP addresses. The IP address can be public or private. When we are talking about the IP addresses in the case of Virtual Machine, they are closely associated with the network interfaces. Again, the Network interfaces with the Network adapters.

If you are an administrator, you can configure many virtual network adapters as per your business needs. Once you will create the virtual machine with multiple virtual network adapters, the OS will treat these as network adapters as exactly the same as physical adapters and provides them with a network address. You can use IPV4 or IPV6 format. You can able to configure a static address also.

You can communicate with the virtual machine with the help of the IP address that is configured specifically to that Azure virtual machine. Even as an administrator, you can configure the Azure Virtual machine with no IP address but, there is no point in doing that. My intention here is it is Possible.

How Do I Find The IP Address Of My Azure VM?

You can find the IP Address Of your Azure Virtual machine with few clicks in the Azure Portal. Follow the below steps to find the IP of your Azure VM.

Login to the Azure Portal (https://portal.azure.com/)

Once you logged in to the Azure Portal, Search for the Virtual Machine.

How Do I Find The IP Address Of My Azure VM?

Once you will click on the search result Virtual machines, you can able to see all your virtual machines listed below. Click on the specific virtual machine for which one you want to check the IP address.

how to find ip address of azure vm

On the Virtual machine page, you can able to see the Public IP address as highlighted below.

Find ip address of azure vm

You can also click on the Networking option from the left navigation on the Virtual machine page. You can able to see the Public and private IP addresses for the virtual machine as highlighted below

Figure out ip address of azure vm

By default the IP address of the Azure Virtual machine is dynamic, if you want to change the dynamic IP of the VM to a Static IP address, you can click on the IP address as highlighted below.

azure create vm with static private ip

Now on the below window, change the Assignment option from Dynamic to Static and then click on the Save button to save the changes. Now the IP address of your Azure Virtual Machine became Static.

azure create vm with static private ip address

So this is How you can find the IP address of your Azure VM and you can also able to change the IP address of your Virtual machine from dynamic to static or static to dynamic.

How Do I Find The IP Address Of My Azure VM PowerShell?

You can also able to retrieve the IP address of your Azure Virtual Machine using PowerShell. Use the below PoweShell Script to get the IP address for your Azure VM

$vmdetailsreport = @()
$vmList = get-azurermvm
$vmnic = get-azurermnetworkinterface | ?{ $_.VirtualMachine -NE $null}
 
foreach($nic in $vmnic)
{
    $details = "" | Select VmName, ResourceGroupName, HostName, IpAddress
    $myvm = $vmList | ? -Property Id -eq $nic.VirtualMachine.id
    $details.VMName = $myvm.Name
    $details.ResourceGroupName = $myvm.ResourceGroupName
    $details.IpAddress = $nic.IpConfigurations.PrivateIpAddress
    $details.HostName = $myvm.OSProfile.ComputerName
    $vmdetailsreport+=$details
}

You can see the output as below

How Do I Find The IP Address Of My Azure VM PowerShell

This is How you can able to retrieve the IP address of your Azure VM using the above PowerShell Script.

You may also like Following the Below Articles

Wrapping UP

Well, In this article, we have discussed How To Figure Out IP Address For Azure Functions, How To Figure Out InBound IP Address For Azure Functions, How To Figure Out OutBound IP Address For Azure Functions, Azure Function Static Outbound IP and we also discussed Azure Function Outbound IP Addresses using PowerShell, Azure Function Whitelist IP Address and Does virtual machine have its own IP address?, How Do I Find The IP Address Of My Azure VM? and How Do I Find The IP Address Of My Azure VM PowerShell?. Hope you have enjoyed this article!!!

Leave a Comment