You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can add access restrictions programmatically by doing either of the following:
194
+
You can manage access restriction programmatically, below you can find examples of how to add rules to access restrictions and how to change *Unmatched rule action* for both *Main site* and *Advanced tool site*.
You can add access restrictions rules programmatically by doing one of the following options:
199
+
200
+
### [Azure CLI](#tab/azurecli)
201
+
202
+
Run the following command in the [Cloud Shell](https://shell.azure.com). Use [the Azure CLI](/cli/azure/webapp/config/access-restriction). For example:
195
203
196
-
* Use [the Azure CLI](/cli/azure/webapp/config/access-restriction). For example:
197
-
198
204
```azurecli-interactive
199
205
az webapp config access-restriction add --resource-group ResourceGroup --name AppName \
200
206
--rule-name 'IP example rule' --action Allow --ip-address 122.133.144.0/24 --priority 100
201
207
```
202
208
203
-
* Use [Azure PowerShell](/powershell/module/Az.Websites/Add-AzWebAppAccessRestrictionRule). For example:
209
+
### [PowerShell](#tab/powershell)
204
210
211
+
To do the same with PowerShell, run the following command in the [Cloud Shell](https://shell.azure.com). Use [Azure PowerShell](/powershell/module/Az.Websites/Add-AzWebAppAccessRestrictionRule). For example:
-Name "Ip example rule" -Priority 100 -Action Allow -IpAddress 122.133.144.0/24
209
216
```
210
217
211
-
You can also set values manually by doing either of the following:
218
+
### [ARM](#tab/arm)
212
219
213
-
* Use an [Azure REST API](/rest/api/azure/) PUT operation on the app configuration in Azure Resource Manager. The location for this information in Azure Resource Manager is:
220
+
For ARM templates, modify the property `ipSecurityRestrictions`. A sample ARM template snippet is provided for you:
You can also set values manually by doing one of the following options:
257
+
258
+
Use an [Azure REST API](/rest/api/azure/) PUT operation on the app configuration in Azure Resource Manager. The location for this information in Azure Resource Manager is:
@@ -253,6 +298,186 @@ You can also set values manually by doing either of the following:
253
298
}
254
299
}
255
300
```
301
+
302
+
### Change *Unmatched rule action* for *Main site* programmatically
303
+
304
+
You can change *Unmatched rule action* for *Main site* programmatically by doing one of the following options:
305
+
306
+
### [Azure CLI](#tab/azurecli)
307
+
308
+
Run the following command in the [Cloud Shell](https://shell.azure.com). Use [the Azure CLI](https://learn.microsoft.com/cli/azure/resource?view=azure-cli-latest#az-resource-update). Accepted values for `ipSecurityRestrictionsDefaultAction` are `Allow` or `Deny`.
309
+
310
+
```azurecli-interactive
311
+
az resource update --resource-group ResourceGroup --name AppName --resource-type "Microsoft.Web/sites" \
To do the same with PowerShell, run the following command in the [Cloud Shell](https://shell.azure.com). Use [Azure PowerShell](https://learn.microsoft.com/powershell/module/az.resources/set-azresource). Accepted values for `ipSecurityRestrictionsDefaultAction` are `Allow` or `Deny`.
For ARM templates, modify the property `ipSecurityRestrictionsDefaultAction`. Accepted values for `ipSecurityRestrictionsDefaultAction` are `Allow` or `Deny`. A sample ARM template snippet is provided for you:
You can also set values manually by doing one of the following options:
374
+
375
+
* Use an [Azure REST API](/rest/api/azure/) PUT operation on the app configuration in Azure Resource Manager. The location for this information in Azure Resource Manager is:
* Use a Resource Manager template. As an example, you can use resources.azure.com and edit the `ipSecurityRestrictionsDefaultAction` property to change the required value in JSON.
380
+
381
+
The JSON syntax for the earlier example is:
382
+
383
+
```json
384
+
{
385
+
"properties": {
386
+
"ipSecurityRestrictionsDefaultAction": "Allow"
387
+
}
388
+
}
389
+
```
390
+
391
+
392
+
### Change *Unmatched rule action* for *Advanced tool site*
393
+
394
+
You can change *Unmatched rule action* for *Advanced tool site* programmatically by doing one of the following options:
395
+
396
+
### [Azure CLI](#tab/azurecli)
397
+
398
+
Run the following command in the [Cloud Shell](https://shell.azure.com). Use [the Azure CLI](https://learn.microsoft.com/cli/azure/resource?view=azure-cli-latest#az-resource-update). Accepted values for `scmIpSecurityRestrictionsDefaultAction` are `Allow` or `Deny`.
399
+
400
+
```azurecli-interactive
401
+
az resource update --resource-group ResourceGroup --name AppName --resource-type "Microsoft.Web/sites" \
To do the same with PowerShell, run the following command in the [Cloud Shell](https://shell.azure.com). Use [Azure PowerShell](https://learn.microsoft.com/powershell/module/az.resources/set-azresource). Accepted values for `scmIpSecurityRestrictionsDefaultAction` are `Allow` or `Deny`.
For ARM templates, modify the property `scmIpSecurityRestrictionsDefaultAction`. Accepted values for `scmIpSecurityRestrictionsDefaultAction` are `Allow` or `Deny`. A sample ARM template snippet is provided for you:
You can also set values manually by doing one of the following options:
465
+
466
+
* Use an [Azure REST API](/rest/api/azure/) PUT operation on the app configuration in Azure Resource Manager. The location for this information in Azure Resource Manager is:
* Use a Resource Manager template. As an example, you can use resources.azure.com and edit the `scmIpSecurityRestrictionsDefaultAction` property to change the required value in JSON.
471
+
472
+
The JSON syntax for the earlier example is:
473
+
474
+
```json
475
+
{
476
+
"properties": {
477
+
"scmIpSecurityRestrictionsDefaultAction": "Deny"
478
+
}
479
+
}
480
+
```
256
481
## Set up Azure Functions access restrictions
257
482
258
483
Access restrictions are also available for function apps with the same functionality as App Service plans. When you enable access restrictions, you also disable the Azure portal code editor for any disallowed IPs.
0 commit comments