Skip to content
Open
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 @@ -7768,7 +7768,7 @@ def _parse_raw_stacks(self, stacks):
continue

runtime_settings = minor_version['stackSettings']['linuxRuntimeSettings']
runtime_name = (runtime_settings['appSettingsDictionary']['FUNCTIONS_WORKER_RUNTIME'] or
runtime_name = (runtime_settings.get('appSettingsDictionary', {}).get('FUNCTIONS_WORKER_RUNTIME') or
runtime['name'])

skus = runtime_settings['Sku']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -681,3 +681,62 @@ def test_config_source_control(self,

# assert
self.assertEqual(response.git_hub_action_configuration.container_configuration.password, None)

def test_flex_parse_raw_stacks_handles_empty_app_settings_dictionary(self):
from azure.cli.command_modules.appservice.custom import _FlexFunctionAppStackRuntimeHelper

# prepare
cmd_mock = _get_test_cmd()
go_stack = {
'name': 'go',
'properties': {'majorVersions': [{'minorVersions': [{
'value': '1.0',
'stackSettings': {'linuxRuntimeSettings': {
'appSettingsDictionary': {},
'Sku': [{'skuCode': 'FC1'}],
'gitHubActionSettings': {'isSupported': True},
'appInsightsSettings': {'isSupported': True},
'isDefault': True,
}},
}]}]},
}

# action
with mock.patch.object(_FlexFunctionAppStackRuntimeHelper,
'get_flex_raw_function_app_stacks',
return_value=[go_stack]):
matched = _FlexFunctionAppStackRuntimeHelper(cmd_mock, 'westcentralus', 'go').resolve('go', '1.0')

# assert
self.assertEqual(matched.name, 'go')
self.assertEqual(matched.version, '1.0')

def test_flex_parse_raw_stacks_prefers_functions_worker_runtime_when_present(self):
# FUNCTIONS_WORKER_RUNTIME overrides runtime['name'] when set (e.g., dotnet-isolated under the dotnet stack).
from azure.cli.command_modules.appservice.custom import _FlexFunctionAppStackRuntimeHelper

# prepare
cmd_mock = _get_test_cmd()
dotnet_isolated_stack = {
'name': 'dotnet',
'properties': {'majorVersions': [{'minorVersions': [{
'value': '8.0',
'stackSettings': {'linuxRuntimeSettings': {
'appSettingsDictionary': {'FUNCTIONS_WORKER_RUNTIME': 'dotnet-isolated'},
'Sku': [{'skuCode': 'FC1'}],
'gitHubActionSettings': {'isSupported': True},
'appInsightsSettings': {'isSupported': True},
'isDefault': True,
}},
}]}]},
}

# action
with mock.patch.object(_FlexFunctionAppStackRuntimeHelper,
'get_flex_raw_function_app_stacks',
return_value=[dotnet_isolated_stack]):
matched = _FlexFunctionAppStackRuntimeHelper(
cmd_mock, 'westcentralus', 'dotnet-isolated').resolve('dotnet-isolated', '8.0')

# assert
self.assertEqual(matched.name, 'dotnet-isolated')
Loading