Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AppService] Fix #17850 - prevent duplicate rules for service endpoints #18024

Merged
merged 1 commit into from
Jun 23, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ def add_webapp_access_restriction(
subnet_id = _validate_subnet(cmd.cli_ctx, subnet, vnet_name, vnet_rg)
if not ignore_missing_vnet_service_endpoint:
_ensure_subnet_service_endpoint(cmd.cli_ctx, subnet_id)

# check for duplicates
for rule in list(access_rules):
if rule.vnet_subnet_resource_id and rule.vnet_subnet_resource_id.lower() == subnet_id.lower():
raise ArgumentUsageError('Service endpoint rule for: ' + subnet_id + ' already exists. '
'Cannot add duplicate service endpoint rules.')
rule_instance = IpSecurityRestriction(
name=rule_name, vnet_subnet_resource_id=subnet_id,
priority=priority, action=action, tag='Default', description=description)
Expand Down Expand Up @@ -113,7 +117,7 @@ def remove_webapp_access_restriction(cmd, resource_group_name, name, rule_name=N
break
elif subnet:
subnet_id = _validate_subnet(cmd.cli_ctx, subnet, vnet_name, resource_group_name)
if rule.vnet_subnet_resource_id == subnet_id and rule.action == action:
if rule.vnet_subnet_resource_id.lower() == subnet_id.lower() and rule.action == action:
if rule_name and (not rule.name or (rule.name and rule.name.lower() != rule_name.lower())):
continue
rule_instance = rule
Expand Down