Skip to content

Commit 8f7e62d

Browse files
authored
[App Service] az webapp create: Update this and similar commands to use new Site-level outboundVnetRouting property (#32634)
1 parent 74ac43d commit 8f7e62d

File tree

2 files changed

+28
-10
lines changed

2 files changed

+28
-10
lines changed

src/azure-cli/azure/cli/command_modules/appservice/custom.py

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def create_webapp(cmd, resource_group_name, name, plan, runtime=None, startup_fi
127127
role='Contributor', scope=None, vnet=None, subnet=None, https_only=False,
128128
public_network_access=None, acr_use_identity=False, acr_identity=None, basic_auth="",
129129
auto_generated_domain_name_label_scope=None):
130-
from azure.mgmt.web.models import Site
130+
from azure.mgmt.web.models import Site, OutboundVnetRouting
131131
from azure.core.exceptions import ResourceNotFoundError as _ResourceNotFoundError
132132
SiteConfig, SkuDescription, NameValuePair = cmd.get_models(
133133
'SiteConfig', 'SkuDescription', 'NameValuePair')
@@ -227,10 +227,10 @@ def create_webapp(cmd, resource_group_name, name, plan, runtime=None, startup_fi
227227
vnet_name=subnet_info["vnet_name"],
228228
subnet_name=subnet_info["subnet_name"])
229229
subnet_resource_id = subnet_info["subnet_resource_id"]
230-
vnet_route_all_enabled = True
230+
outbound_vnet_routing = OutboundVnetRouting(application_traffic=True)
231231
else:
232232
subnet_resource_id = None
233-
vnet_route_all_enabled = None
233+
outbound_vnet_routing = None
234234

235235
if using_webapp_up:
236236
https_only = using_webapp_up
@@ -240,7 +240,7 @@ def create_webapp(cmd, resource_group_name, name, plan, runtime=None, startup_fi
240240

241241
webapp_def = Site(location=location, site_config=site_config, server_farm_id=plan_info.id, tags=tags,
242242
https_only=https_only, virtual_network_subnet_id=subnet_resource_id,
243-
public_network_access=public_network_access, vnet_route_all_enabled=vnet_route_all_enabled,
243+
public_network_access=public_network_access, outbound_vnet_routing=outbound_vnet_routing,
244244
auto_generated_domain_name_label_scope=auto_generated_domain_name_label_scope)
245245
if runtime:
246246
runtime = _StackRuntimeHelper.remove_delimiters(runtime)
@@ -3161,7 +3161,7 @@ def update_site_configs(cmd, resource_group_name, name, slot=None, number_of_wor
31613161
import inspect
31623162
frame = inspect.currentframe()
31633163
bool_flags = ['remote_debugging_enabled', 'web_sockets_enabled', 'always_on',
3164-
'auto_heal_enabled', 'use32_bit_worker_process', 'http20_enabled', 'vnet_route_all_enabled']
3164+
'auto_heal_enabled', 'use32_bit_worker_process', 'http20_enabled']
31653165
int_flags = ['pre_warmed_instance_count', 'number_of_workers']
31663166
# note: getargvalues is used already in azure.cli.core.commands.
31673167
# and no simple functional replacement for this deprecating method for 3.5
@@ -3234,7 +3234,21 @@ def update_site_configs(cmd, resource_group_name, name, slot=None, number_of_wor
32343234
if max_replicas is not None:
32353235
setattr(configs, 'function_app_scale_limit', max_replicas)
32363236
return update_configuration_polling(cmd, resource_group_name, name, slot, configs)
3237-
return _generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'update_configuration', slot, configs)
3237+
3238+
# Update SiteConfig first
3239+
result = _generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'update_configuration', slot, configs)
3240+
3241+
# Handle vnet_route_all_enabled separately using Site-level outbound_vnet_routing property
3242+
# This is done after SiteConfig update to ensure the Site-level property is not overwritten
3243+
if vnet_route_all_enabled is not None:
3244+
from azure.mgmt.web.models import OutboundVnetRouting
3245+
client = web_client_factory(cmd.cli_ctx)
3246+
app = _generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'get', slot, client=client)
3247+
app.outbound_vnet_routing = OutboundVnetRouting(application_traffic=vnet_route_all_enabled == 'true')
3248+
_generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'begin_create_or_update', slot,
3249+
client=client, extra_parameter=app)
3250+
3251+
return result
32383252

32393253

32403254
def update_configuration_polling(cmd, resource_group_name, name, slot, configs):
@@ -7238,17 +7252,20 @@ def create_functionapp(cmd, resource_group_name, name, storage_account, plan=Non
72387252
subnet_name=subnet_info["subnet_name"],
72397253
subnet_service_delegation=FLEX_SUBNET_DELEGATION if flexconsumption_location else None)
72407254
subnet_resource_id = subnet_info["subnet_resource_id"]
7241-
site_config.vnet_route_all_enabled = True
7255+
from azure.mgmt.web.models import OutboundVnetRouting
7256+
outbound_vnet_routing = OutboundVnetRouting(application_traffic=True)
72427257
else:
72437258
subnet_resource_id = None
7259+
outbound_vnet_routing = None
72447260

72457261
# if this is a managed function app (Azure Functions on Azure Containers), http20_proxy_flag must be None
72467262
if environment is not None:
72477263
site_config.http20_proxy_flag = None
72487264

72497265
functionapp_def = Site(location=None, site_config=site_config, tags=tags,
72507266
virtual_network_subnet_id=subnet_resource_id, https_only=https_only,
7251-
auto_generated_domain_name_label_scope=auto_generated_domain_name_label_scope)
7267+
auto_generated_domain_name_label_scope=auto_generated_domain_name_label_scope,
7268+
outbound_vnet_routing=outbound_vnet_routing)
72527269

72537270
plan_info = None
72547271
if runtime is not None:
@@ -8822,7 +8839,8 @@ def _add_vnet_integration(cmd, name, resource_group_name, vnet, subnet, slot=Non
88228839
subnet_service_delegation=FLEX_SUBNET_DELEGATION if is_flex else None)
88238840

88248841
app.virtual_network_subnet_id = subnet_info["subnet_resource_id"]
8825-
app.site_config.vnet_route_all_enabled = True
8842+
from azure.mgmt.web.models import OutboundVnetRouting
8843+
app.outbound_vnet_routing = OutboundVnetRouting(application_traffic=True)
88268844

88278845
_generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'begin_create_or_update', slot,
88288846
client=client, extra_parameter=app)

src/azure-cli/azure/cli/command_modules/appservice/tests/latest/test_functionapp_commands.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3444,7 +3444,7 @@ def test_functionapp_elastic_premium_restricted_public_network_access_storage_vn
34443444

34453445
self.cmd('functionapp create -g {} -n {} -s {} -p {} --functions-version 4 --vnet {} --subnet {}'.format(resource_group, functionapp_name, storage_account, ep_plan_name, vnet_name, subnet_name)).assert_with_checks([
34463446
JMESPathCheck('vnetContentShareEnabled', True),
3447-
JMESPathCheck('vnetRouteAllEnabled', True),
3447+
JMESPathCheck('outboundVnetRouting.applicationTraffic', True),
34483448
JMESPathCheck('virtualNetworkSubnetId', subnet_id)
34493449
])
34503450

0 commit comments

Comments
 (0)