Skip to content
Merged
Show file tree
Hide file tree
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 @@ -109,3 +109,29 @@ def __init__(self):
"RuntimeSuccessful": "Site started successfully.",
"RuntimeFailed": "Site failed to start."
}

LANGUAGE_EOL_DEPRECATION_NOTICES = {
"dotnet|3.1": "https://azure.microsoft.com/en-us/updates/extended-support-for-"
"microsoft-net-core-31-will-end-on-3-december-2022/",
"dotnet|6": "https://azure.microsoft.com/en-us/updates/dotnet6support/",
"dotnet-isolated|6": "https://azure.microsoft.com/en-us/updates/dotnet6support/",
"dotnet-isolated|7": "https://azure.microsoft.com/en-us/updates/dotnet7support/",
"python|3.6": "https://azure.microsoft.com/en-us/updates/azure-functions-support-"
"for-python-36-is-ending-on-30-september-2022/",
"python|3.7": "https://azure.microsoft.com/en-us/updates/community-support-for-"
"python-37-is-ending-on-27-june-2023/",
"python|3.8": "https://azure.microsoft.com/en-us/updates/azure-functions-support-"
"for-python-38-is-ending-on-14-october-2023-6/",
"powershell|6.2": "https://azure.microsoft.com/en-us/updates/azure-functions-support-"
"for-powershell-6-is-ending-on-30-september-2022/",
"node|6": "https://azure.microsoft.com/en-us/updates/azure-functions-support-for-"
"node-6-is-ending-on-28-february-2022/",
"node|8": "https://azure.microsoft.com/en-us/updates/azure-functions-support-for-"
"node-8-is-ending-on-28-february-2022/",
"node|10": "https://azure.microsoft.com/en-us/updates/azure-functions-support-"
"for-node-10-is-ending-on-30-september-2022/",
"node|12": "https://azure.microsoft.com/en-us/updates/node12/",
"node|14": "https://azure.microsoft.com/en-us/updates/community-support-for-node-"
"14-lts-is-ending-on-30-april-2023/",
"node|16": "https://azure.microsoft.com/en-us/updates/node16support/"
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,12 +338,12 @@ def load_command_table(self, _):
validator=validate_functionapp_on_containerapp_update)

with self.command_group('functionapp config') as g:
g.custom_command('set', 'update_site_configs', validator=validate_functionapp_on_containerapp_site_config_set, exception_handler=ex_handler_factory())
g.custom_command('set', 'update_site_configs_functionapp', validator=validate_functionapp_on_containerapp_site_config_set, exception_handler=ex_handler_factory())
g.custom_show_command('show', 'get_site_configs', validator=validate_functionapp_on_containerapp_site_config_show, exception_handler=ex_handler_factory())

with self.command_group('functionapp config appsettings') as g:
g.custom_command('list', 'get_app_settings', exception_handler=empty_on_404)
g.custom_command('set', 'update_app_settings', exception_handler=ex_handler_factory())
g.custom_command('set', 'update_app_settings_functionapp', exception_handler=ex_handler_factory())
g.custom_command('delete', 'delete_app_settings', exception_handler=ex_handler_factory())

with self.command_group('functionapp config hostname') as g:
Expand Down
113 changes: 106 additions & 7 deletions src/azure-cli/azure/cli/command_modules/appservice/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
WINDOWS_OS_NAME, LINUX_FUNCTIONAPP_GITHUB_ACTIONS_WORKFLOW_TEMPLATE_PATH,
WINDOWS_FUNCTIONAPP_GITHUB_ACTIONS_WORKFLOW_TEMPLATE_PATH, DEFAULT_CENTAURI_IMAGE,
VERSION_2022_09_01,
RUNTIME_STATUS_TEXT_MAP)
RUNTIME_STATUS_TEXT_MAP, LANGUAGE_EOL_DEPRECATION_NOTICES)
from ._github_oauth import (get_github_access_token, cache_github_token)
from ._validators import validate_and_convert_to_int, validate_range_of_int_flag

Expand Down Expand Up @@ -401,6 +401,27 @@ def parse_docker_image_name(deployment_container_image_name, environment=None):
return "https://{}".format(hostname)


def check_language_runtime(cmd, resource_group_name, name):
client = web_client_factory(cmd.cli_ctx)
app = client.web_apps.get(resource_group_name, name)
is_linux = app.reserved
if is_functionapp(app):
runtime_info = _get_functionapp_runtime_info(cmd, resource_group_name, name, None, is_linux)
runtime = runtime_info['app_runtime']
runtime_version = runtime_info['app_runtime_version']
functions_version = runtime_info['functionapp_version']
runtime_helper = _FunctionAppStackRuntimeHelper(cmd=cmd, linux=is_linux, windows=(not is_linux))
try:
runtime_helper.resolve(runtime, runtime_version, functions_version, is_linux)
except ValidationError as e:
logger.warning(e.error_msg)


def update_app_settings_functionapp(cmd, resource_group_name, name, settings=None, slot=None, slot_settings=None):
check_language_runtime(cmd, resource_group_name, name)
return update_app_settings(cmd, resource_group_name, name, settings, slot, slot_settings)


def update_app_settings(cmd, resource_group_name, name, settings=None, slot=None, slot_settings=None):
if not settings and not slot_settings:
raise MutuallyExclusiveArgumentError('Usage Error: --settings |--slot-settings')
Expand Down Expand Up @@ -550,6 +571,7 @@ def update_azure_storage_account(cmd, resource_group_name, name, custom_id, stor


def enable_zip_deploy_functionapp(cmd, resource_group_name, name, src, build_remote=False, timeout=None, slot=None):
check_language_runtime(cmd, resource_group_name, name)
client = web_client_factory(cmd.cli_ctx)
app = client.web_apps.get(resource_group_name, name)
if app is None:
Expand Down Expand Up @@ -1779,13 +1801,36 @@ def update_container_settings(cmd, resource_group_name, name, docker_registry_se
slot=slot))


def update_site_configs_functionapp(cmd, resource_group_name, name, slot=None, number_of_workers=None,
linux_fx_version=None, 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, 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):
check_language_runtime(cmd, resource_group_name, name)
return update_site_configs(cmd, resource_group_name, name, slot, number_of_workers, linux_fx_version,
windows_fx_version, pre_warmed_instance_count, php_version,
python_version, net_framework_version, power_shell_version,
java_version, java_container, java_container_version,
remote_debugging_enabled, web_sockets_enabled,
always_on, auto_heal_enabled,
use32_bit_worker_process, min_tls_version, http20_enabled, app_command_line,
ftps_state, vnet_route_all_enabled, generic_configurations, min_replicas,
max_replicas)


def update_container_settings_functionapp(cmd, resource_group_name, name, registry_server=None,
image=None, registry_username=None,
registry_password=None, slot=None, min_replicas=None, max_replicas=None,
enable_dapr=None, dapr_app_id=None, dapr_app_port=None,
dapr_http_max_request_size=None, dapr_http_read_buffer_size=None,
dapr_log_level=None, dapr_enable_api_logging=None,
workload_profile_name=None, cpu=None, memory=None):
check_language_runtime(cmd, resource_group_name, name)
if is_centauri_functionapp(cmd, resource_group_name, name):
_validate_cpu_momory_functionapp(cpu, memory)
if any([enable_dapr, dapr_app_id, dapr_app_port, dapr_http_max_request_size, dapr_http_read_buffer_size,
Expand Down Expand Up @@ -3560,11 +3605,37 @@ def to_dict(self):
d["linux_fx_version"] = self.site_config_dict.linux_fx_version
return d

class RuntimeEOL:
def __init__(self, name=None, version=None, eol=None):
self.name = name
self.version = version
self.eol = eol
self.display_name = "{}|{}".format(name, version)
self.deprecation_link = LANGUAGE_EOL_DEPRECATION_NOTICES.get(self.display_name)

def __init__(self, cmd, linux=False, windows=False):
self.disallowed_functions_versions = {"~1", "~2"}
self.KEYS = FUNCTIONS_STACKS_API_KEYS()
self.end_of_life_dates = []
super().__init__(cmd, linux=linux, windows=windows)

def validate_end_of_life_date(self, runtime, version):
from dateutil.relativedelta import relativedelta
today = datetime.datetime.now(datetime.timezone.utc)
six_months = today + relativedelta(months=+6)
runtimes_eol = [r for r in self.end_of_life_dates if runtime == r.name]
matched_runtime_eol = next((r for r in runtimes_eol if r.version == version), None)
if matched_runtime_eol:
eol = matched_runtime_eol.eol
runtime_deprecation_link = matched_runtime_eol.deprecation_link or ''

if eol < today:
raise ValidationError('{} has reached EOL on {} and is no longer supported. {}'
.format(runtime, eol.date(), runtime_deprecation_link))
Comment on lines +3632 to +3634
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check sets a time bomb and blows up the CI at exactly today - 2024-11-08 (#30289 (comment)).

if eol < six_months:
logger.warning('%s will reach EOL on %s and will no longer be supported. %s',
runtime, eol.date(), runtime_deprecation_link)

def resolve(self, runtime, version=None, functions_version=None, linux=False, disable_version_error=False):
stacks = self.stacks
runtimes = [r for r in stacks if r.linux == linux and runtime == r.name]
Expand All @@ -3575,7 +3646,12 @@ def resolve(self, runtime, version=None, functions_version=None, linux=False, di
"Run 'az functionapp list-runtimes' for more details on supported runtimes. "
.format(runtime, os, supported_runtimes))
if version is None:
return self.get_default_version(runtime, functions_version, linux)
matched_runtime_version = self.get_default_version(runtime, functions_version, linux)
self.validate_end_of_life_date(
matched_runtime_version.name,
matched_runtime_version.version
)
return matched_runtime_version
matched_runtime_version = next((r for r in runtimes if r.version == version), None)
if not matched_runtime_version:
# help convert previously acceptable versions into correct ones if match not found
Expand All @@ -3588,6 +3664,14 @@ def resolve(self, runtime, version=None, functions_version=None, linux=False, di
}
new_version = old_to_new_version.get(version)
matched_runtime_version = next((r for r in runtimes if r.version == new_version), None)
if matched_runtime_version is not None:
version = new_version

self.validate_end_of_life_date(
runtime,
version
)

if not matched_runtime_version:
versions = [r.version for r in runtimes]
if disable_version_error:
Expand Down Expand Up @@ -3645,7 +3729,10 @@ def _get_valid_function_versions(self, runtime_settings):
valid_versions.append(self._format_version_name(v))
return valid_versions

def _parse_minor_version(self, runtime_settings, major_version_name, minor_version_name, runtime_to_version):
def _parse_minor_version(self, runtime_settings, major_version_name, minor_version_name, runtime_to_version,
runtime_to_version_eol):
runtime_name = (runtime_settings.app_settings_dictionary.get(self.KEYS.FUNCTIONS_WORKER_RUNTIME) or
major_version_name)
if not runtime_settings.is_deprecated:
functions_versions = self._get_valid_function_versions(runtime_settings)
if functions_versions:
Expand All @@ -3659,11 +3746,14 @@ def _parse_minor_version(self, runtime_settings, major_version_name, minor_versi
self.KEYS.GIT_HUB_ACTION_SETTINGS: runtime_settings.git_hub_action_settings
}

runtime_name = (runtime_settings.app_settings_dictionary.get(self.KEYS.FUNCTIONS_WORKER_RUNTIME) or
major_version_name)
runtime_to_version[runtime_name] = runtime_to_version.get(runtime_name, dict())
runtime_to_version[runtime_name][minor_version_name] = runtime_version_properties

# obtain end of life date for all runtime versions
if runtime_settings.end_of_life_date is not None:
runtime_to_version_eol[runtime_name] = runtime_to_version_eol.get(runtime_name, dict())
runtime_to_version_eol[runtime_name][minor_version_name] = runtime_settings.end_of_life_date

def _create_runtime_from_properties(self, runtime_name, version_name, version_properties, linux):
supported_func_versions = version_properties[self.KEYS.SUPPORTED_EXTENSION_VERSIONS]
return self.Runtime(name=runtime_name,
Expand All @@ -3682,6 +3772,7 @@ def _parse_raw_stacks(self, stacks):
# build a map of runtime -> runtime version -> runtime version properties
runtime_to_version_linux = {}
runtime_to_version_windows = {}
runtime_to_version_end_of_life = {}
for runtime in stacks:
for major_version in runtime.major_versions:
for minor_version in major_version.minor_versions:
Expand All @@ -3693,16 +3784,19 @@ def _parse_raw_stacks(self, stacks):
self._parse_minor_version(runtime_settings=linux_settings,
major_version_name=runtime.name,
minor_version_name=runtime_version,
runtime_to_version=runtime_to_version_linux)
runtime_to_version=runtime_to_version_linux,
runtime_to_version_eol=runtime_to_version_end_of_life)

if windows_settings is not None and not windows_settings.is_hidden:
self._parse_minor_version(runtime_settings=windows_settings,
major_version_name=runtime.name,
minor_version_name=runtime_version,
runtime_to_version=runtime_to_version_windows)
runtime_to_version=runtime_to_version_windows,
runtime_to_version_eol=runtime_to_version_end_of_life)

runtime_to_version_linux = self._format_version_names(runtime_to_version_linux)
runtime_to_version_windows = self._format_version_names(runtime_to_version_windows)
runtime_to_version_end_of_life = self._format_version_names(runtime_to_version_end_of_life)

for runtime_name, versions in runtime_to_version_windows.items():
for version_name, version_properties in versions.items():
Expand All @@ -3714,6 +3808,11 @@ def _parse_raw_stacks(self, stacks):
r = self._create_runtime_from_properties(runtime_name, version_name, version_properties, linux=True)
self._stacks.append(r)

for runtime_name, versions in runtime_to_version_end_of_life.items():
for version_name, version_eol in versions.items():
r = self.RuntimeEOL(name=runtime_name, version=version_name, eol=version_eol)
self.end_of_life_dates.append(r)


def get_app_insights_key(cli_ctx, resource_group, name):
appinsights_client = get_mgmt_service_client(cli_ctx, ApplicationInsightsManagementClient)
Expand Down
Loading