Is there a way to determine the outgoing IP address of a Website (not a webrole)?
I\'ve done a reverse looking up *.azurewebsites.net which returns one address, howe
You can get the "OUTBOUND IP ADDRESSES" property via PowerShell. Here is the command:
(Get-AzureRmResource -ResourceGroupName inhabit-adminservices -ResourceType Microsoft.Web/sites -ResourceName YOUR_RESOURCE_NAME).Properties.OutboundIpAddresses -Split ","
Where YOUR_RESOURCE_NAME is the name of Resource group.
Azure website can use a random IP just out of 4 IP addresses per scale unit.
For a list of IP addresses per scale unit and instructions about how to determine your site's scale unit, take a look here.
UPDATE: seems that all the scale unit's 4 IP addresses can now be found in the new Azure portal and the forum post will no longer be updated.
From July 20th, 2015 onwards, this post will no longer be updated with IP addresses. Instead this information can now be found in a web app's properties using the new portal (portal.azure.com).
To find the outbound IP addresses:
Browse to the details of your specific web app using the new portal at portal.azure.com.
Towards the top of the details for your web app, there is a link for "All settings". Click the link.
Clicking "All settings" will open up a list of web app information that you can drill into further. The specific information to drill into is "Properties". Click on the "Properties" selection.
Within the "Properties" UX, there is a textbox showing the set of Outbound IP Addresses. Using the icon to the side of the "Outbound IP Addresses" textbox you can select all of the addresses. Pressing Ctrl+C will then copy the addresses to the clipboard.
It seems Azure websites will randomly use any of the datacenter's IP addresses for outbound traffic. You can download a list of ip addresses here : http://msdn.microsoft.com/en-us/library/dn175718.aspx
Alternatively use a combination of an Azure cloud service and an Azure VPN. The VPN will ensure you get a static ip address for all outbound traffic. It's a shame they didn't forsee this for their websites service.
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
if (Request["check"] == "1")
{
Response.Clear();
Response.Write(HttpContext.Current.Request.UserHostAddress);
}
else {
Response.Write("Your IP: " + HttpContext.Current.Request.UserHostAddress + "<br />") ;
Response.Write("Server Outbound IP: " + GetOutBoundAddress()) ;
}
}
public string GetOutBoundAddress()
{
System.Net.WebClient wc = new System.Net.WebClient();
try
{
return wc.DownloadString(Request.Url + "?check=1");
}
catch (Exception)
{
return "not found";
}
}