terraform-provider-azurerm: Problem with IP Restriction rules in azurerm_app_service resource
Hi,
We stepped into the strange problem while working with “IP Restriction” azurerm_app_service resource functionality. There is a need to manage this IP Restriction rules externally by using PowerShell script and not with Terraform. Below are detailed steps we followed:
-
We successfully applied needed restriction rules via script.

-
Then we decided to change tags (basically any change) for app_service resource via TF. After that rules became broken and we see this:
-
I’ve tried to add IP Restriction list to Lifecycle->Ignore Changes part of the app_service resource, like this: lifecycle { ignore_changes = [ “site_config.0.scm_type”, “site_config.0.ip_restriction” ] } But this does not help whenever we change IP restriction rules externally and then apply TF, rules became broken.
-
At the same time, looks like, current implementation of azurerm_app_service resource IP Restriction part is using old Azure API 2016-08-01 instead of 2018-02-01 (https://docs.microsoft.com/en-us/azure/app-service/app-service-ip-restrictions). In old API you need just to specify 2 parameters: ip_address and subnet_mask. But for new API ip_restriction consists of the next parameters: { “ipAddress”: “131.107.159.0/24”, “action”: “Allow”, “tag”: “Default”, “priority”: 100, “name”: “allowed access” } So basically when TF Apply run against app_service resource it is using old API and this just break IP Restriction rules at all.
So I have two questions:
- How can we ignore changes for IP Restriction rules applied externally?
- What is the best way to handle such case?
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave “+1” or “me too” comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform (and AzureRM Provider) Version
Terraform v0.11.7
- provider.azurerm v1.19.0
- provider.random v2.0.0
- provider.template v1.0.0
Affected Resource(s)
- azurerm_app_service
Terraform Configuration Files
# Copy-paste your Terraform configurations here - for large Terraform configs,
# please use a service like Dropbox and share a link to the ZIP file. For
# security, you can also encrypt the files using our GPG public key: https://keybase.io/hashicorp
Debug Output
Panic Output
Expected Behavior
Actual Behavior
Steps to Reproduce
terraform apply
Important Factoids
References
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 45
- Comments: 23 (2 by maintainers)
I am running into the same issue as @mrboogiee When following the documentaton with optional params and only setting the
ip_adressi get following errorWhen adding these params as per error message with some dummy values i get the following error:
I got it working with
Is there a way to use ip_restriction with Type as ‘Virtual Network’ using Terraform?
Any chances it might be fixed anytime soon?
@JleruOHeP yes, there is just now an open PR for names and priorities 😃 https://github.com/terraform-providers/terraform-provider-azurerm/pull/6705
have just upgraded to v2.43 and tried to get this working with the documentation on https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/function_app but ran into the following issues with the below configuration:
This resulted in the following error when executing plan:
If I then add the apparently (although the documentation says otherwise) required fields with empty values like below:
I run into the following errors when executing plan:
While we wait for this to be updated the following code using azurerm templates can set the
IpSecurityRestrictionsandscmIpSecurityRestrictionsproperties on the site config on every terraform apply if added in addition to an existing app service resource deployment.No it hasn’t which is annoying as it would be really useful to label the IP addresses in the portal.
To add it as VNet restriction you use
virtual_network_subnet_id:But was there any progress on adding names and priorities?