in src/azure-cli/azure/cli/command_modules/appservice/custom.py [0:0]
def update_site_configs(cmd, resource_group_name, name, slot=None, number_of_workers=None, linux_fx_version=None, # pylint: disable=too-many-statements,too-many-branches
windows_fx_version=None, pre_warmed_instance_count=None, php_version=None,
python_version=None, net_framework_version=None, power_shell_version=None,
java_version=None, java_container=None, java_container_version=None, runtime=None,
remote_debugging_enabled=None, web_sockets_enabled=None,
always_on=None, auto_heal_enabled=None,
use32_bit_worker_process=None,
min_tls_version=None,
http20_enabled=None,
app_command_line=None,
ftps_state=None,
vnet_route_all_enabled=None,
generic_configurations=None,
min_replicas=None,
max_replicas=None,
acr_use_identity=None,
acr_identity=None,
min_tls_cipher_suite=None):
configs = get_site_configs(cmd, resource_group_name, name, slot)
app_settings = _generic_site_operation(cmd.cli_ctx, resource_group_name, name,
'list_application_settings', slot)
if runtime and (java_version or java_container or java_container_version or net_framework_version):
raise MutuallyExclusiveArgumentError("Cannot use --java-version or --java-container"
"or --java-container-version or --net-framework-version"
"with --runtime")
if runtime and linux_fx_version:
raise MutuallyExclusiveArgumentError("Cannot use both --runtime and --linux-fx-version")
if runtime:
runtime = _StackRuntimeHelper.remove_delimiters(runtime)
config_is_linux = False
if configs.linux_fx_version:
config_is_linux = True
helper = _StackRuntimeHelper(cmd, linux=config_is_linux, windows=not config_is_linux)
match = helper.resolve(runtime, linux=config_is_linux)
if not match:
raise ValidationError("Linux Runtime '{}' is not supported."
"Run 'az webapp list-runtimes --os-type linux' to cross check".format(runtime))
helper.get_site_config_setter(match, linux=config_is_linux)(cmd=cmd, stack=match, site_config=configs)
else:
helper = _StackRuntimeHelper(cmd, linux=config_is_linux, windows=not config_is_linux)
match = helper.resolve(runtime, linux=config_is_linux)
if not match:
raise ValidationError("Windows runtime '{}' is not supported."
"Run 'az webapp list-runtimes --os-type windows' to cross check".format(runtime))
if not ('java_version' in match.configs or 'java_container' in match.configs or 'java_container_version' in match.configs): # pylint: disable=line-too-long
setattr(configs, 'java_version', None)
setattr(configs, 'java_container', None)
setattr(configs, 'java_container_version', None)
helper.get_site_config_setter(match, linux=config_is_linux)(cmd=cmd, stack=match, site_config=configs)
language = runtime.split('|')[0]
version_used_create = '|'.join(runtime.split('|')[1:])
runtime_version = "{}|{}".format(language, version_used_create) if \
version_used_create != "-" else version_used_create
current_stack = get_current_stack_from_runtime(runtime_version) if \
get_current_stack_from_runtime(runtime_version) != "tomcat" else "java"
_update_webapp_current_stack_property_if_needed(cmd, resource_group_name, name, current_stack)
if number_of_workers is not None:
number_of_workers = validate_range_of_int_flag('--number-of-workers', number_of_workers, min_val=0, max_val=20)
if linux_fx_version:
if linux_fx_version.strip().lower().startswith('docker|'):
if ('WEBSITES_ENABLE_APP_SERVICE_STORAGE' not in app_settings.properties or
app_settings.properties['WEBSITES_ENABLE_APP_SERVICE_STORAGE'] != 'true'):
update_app_settings(cmd, resource_group_name, name, ["WEBSITES_ENABLE_APP_SERVICE_STORAGE=false"])
else:
delete_app_settings(cmd, resource_group_name, name, ["WEBSITES_ENABLE_APP_SERVICE_STORAGE"])
if pre_warmed_instance_count is not None:
pre_warmed_instance_count = validate_range_of_int_flag('--prewarmed-instance-count', pre_warmed_instance_count,
min_val=0, max_val=20)
import inspect
frame = inspect.currentframe()
bool_flags = ['remote_debugging_enabled', 'web_sockets_enabled', 'always_on',
'auto_heal_enabled', 'use32_bit_worker_process', 'http20_enabled', 'vnet_route_all_enabled']
int_flags = ['pre_warmed_instance_count', 'number_of_workers']
# note: getargvalues is used already in azure.cli.core.commands.
# and no simple functional replacement for this deprecating method for 3.5
args, _, _, values = inspect.getargvalues(frame) # pylint: disable=deprecated-method
for arg in args[3:]:
if arg in int_flags and values[arg] is not None:
values[arg] = validate_and_convert_to_int(arg, values[arg])
if arg != 'generic_configurations' and values.get(arg, None):
setattr(configs, arg, values[arg] if arg not in bool_flags else values[arg] == 'true')
generic_configurations = generic_configurations or []
# https://github.com/Azure/azure-cli/issues/14857
updating_ip_security_restrictions = False
result = {}
for s in generic_configurations:
try:
json_object = get_json_object(s)
for config_name in json_object:
if config_name.lower() == 'ip_security_restrictions':
updating_ip_security_restrictions = True
result.update(json_object)
except CLIError:
config_name, value = s.split('=', 1)
result[config_name] = value
for config_name, value in result.items():
if config_name.lower() == 'ip_security_restrictions':
updating_ip_security_restrictions = True
setattr(configs, config_name, value)
if not updating_ip_security_restrictions:
setattr(configs, 'ip_security_restrictions', None)
setattr(configs, 'scm_ip_security_restrictions', None)
if acr_identity:
if not configs.acr_use_managed_identity_creds:
setattr(configs, 'acr_use_managed_identity_creds', True)
acr_user_managed_identity_id = ''
if acr_identity.casefold() != MSI_LOCAL_ID:
if acr_identity.endswith('/'):
acr_identity = acr_identity[:len(acr_identity) - 1]
web_app = get_webapp(cmd, resource_group_name, name, slot)
webapp_identity = web_app.identity
matched_key = None
for key in webapp_identity.user_assigned_identities.keys():
if key.casefold() == acr_identity.casefold():
matched_key = key
matched_identity = None if matched_key is None else webapp_identity.user_assigned_identities[matched_key]
if not matched_identity:
raise ResourceNotFoundError("Unable to retrieve identity {}, "
"please make sure the identity resource id you provide is correct "
"and it is assigned to this webapp. "
"When seeing this error while creating webapp "
"please remove created webapp before trying again "
"or set up user managed identity used for acr manually"
.format(acr_identity))
acr_user_managed_identity_id = matched_identity.client_id
setattr(configs, 'acr_user_managed_identity_id', acr_user_managed_identity_id)
if acr_use_identity is not None:
acr_use_identity = values['acr_use_identity'].casefold() == 'true'
if not acr_use_identity:
setattr(configs, 'acr_user_managed_identity_id', "")
setattr(configs, 'acr_use_managed_identity_creds', acr_use_identity)
if is_centauri_functionapp(cmd, resource_group_name, name):
if min_replicas is not None:
setattr(configs, 'minimum_elastic_instance_count', min_replicas)
if max_replicas is not None:
setattr(configs, 'function_app_scale_limit', max_replicas)
return update_configuration_polling(cmd, resource_group_name, name, slot, configs)
return _generic_site_operation(cmd.cli_ctx, resource_group_name, name, 'update_configuration', slot, configs)