Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Azure function IP restrictions using powershell

I'm trying to modify the IP restrictions for my Azure function app using Azure PowerShell. I'm using the method described here: Modify Azure AppService ipsecurity during release from VSTS

$r = Get-AzureRmResource -ResourceGroupName "Resoucegroup name" -ResourceType Microsoft.Web/sites/config -ResourceName resourcename -ApiVersion 2016-08-01

$p = $r.Properties
$p.ipSecurityRestrictions = @()
$restriction = @{}
$restriction.Add("ipAddress","0.0.0.0")
$restriction.Add("subnetMask","0.0.0.0")
$p.ipSecurityRestrictions+= $restriction

Set-AzureRmResource -ResourceGroupName  "Resoucegroup name" -ResourceType Microsoft.Web/sites/config -ResourceName resourcename -ApiVersion 2016-08-01 -PropertyObject $p -Force

However the Set-AzureRmResource CmdLet fails with error:

The requested resource does not support http method 'PUT'.

Any ideas?

like image 383
D Fowler Avatar asked Feb 23 '18 15:02

D Fowler


People also ask

How do I whitelist an IP address on an Azure app?

However, to configure your IP whitelist for a specific web application, navigate to Settings, Networking, <the Web App overview page>. Under IP restrictions, click Configure IP restrictions. You can add a rule by specifying an IP address, or an IP address range, and providing a subnet mask.

What two methods can you use to restrict public Internet access to a function app?

You can restrict internet access in a couple of ways: Private endpoints: Restrict inbound traffic to your function app by private link over your virtual network, effectively blocking inbound traffic from the public internet. IP restrictions: Restrict inbound traffic to your function app by IP range.

Does Azure function has static IP?

Deploying an Azure function in an App Service Environment is currently the only way to have a static inbound and outbound IP for your function. Yes, the Application Gateway v2 SKU supports static public IP addresses. You can choose Application Gateway Dynamic or Static IP during the resource creation.


1 Answers

What are you using for your resourcename? It should be yourFunctionAppName/web

Your commands work exactly as is for me replacing Resoucegroup name with my resourceGroup name, and resourcename with my-function-app-name/web

like image 119
ahmelsayed Avatar answered Oct 07 '22 00:10

ahmelsayed