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
47 changes: 13 additions & 34 deletions src/azure-cli/azure/cli/command_modules/appservice/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
NETCORE_VERSIONS = ['1.0', '1.1', '2.1', '2.2']
DOTNET_VERSIONS = ['3.5', '4.7']
LINUX_SKU_DEFAULT = "P1V2"
FUNCTIONS_VERSIONS_FUNCTIONAPP = ['2', '3']
FUNCTIONS_VERSIONS = ['2', '3']
# functions version : default node version
NODE_VERSION_DEFAULT_FUNCTIONAPP = {
FUNCTIONS_VERSION_TO_DEFAULT_NODE_VERSION = {
'2': '~10',
'3': '~12'
}
# functions version -> runtime : default runtime version
RUNTIME_TO_DEFAULT_VERSION_FUNCTIONAPP = {
FUNCTIONS_VERSION_TO_DEFAULT_RUNTIME_VERSION = {
'2': {
'node': '8',
'dotnet': '2',
Expand All @@ -39,39 +39,18 @@
'java': '8'
}
}
# functions version -> runtime -> runtime version : container image
RUNTIME_TO_IMAGE_FUNCTIONAPP = {
# functions version -> runtime : runtime versions
FUNCTIONS_VERSION_TO_SUPPORTED_RUNTIME_VERSIONS = {
'2': {
'node': {
'8': 'mcr.microsoft.com/azure-functions/node:2.0-node8-appservice',
Copy link
Member

Choose a reason for hiding this comment

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

Will the values like 'mcr.microsoft.com/azure-functions/node:2.0-node8-appservice' not be used any more?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct -- the back end has been updated to know which container image to use, so it's not something we have to set here anymore

'10': 'mcr.microsoft.com/azure-functions/node:2.0-node10-appservice'
},
'python': {
'3.6': 'mcr.microsoft.com/azure-functions/python:2.0-python3.6-appservice',
'3.7': 'mcr.microsoft.com/azure-functions/python:2.0-python3.7-appservice'
},
'dotnet': {
'2': 'mcr.microsoft.com/azure-functions/dotnet:2.0-appservice'
},
'java': {
'8': 'mcr.microsoft.com/azure-functions/java:2.0-java8-appservice'
}
'node': ['8', '10'],
'python': ['3.6', '3.7'],
'dotnet': ['2'],
'java': ['8']
},
'3': {
'node': {
'10': 'mcr.microsoft.com/azure-functions/node:3.0-node10-appservice',
'12': 'mcr.microsoft.com/azure-functions/node:3.0-node12-appservice'
},
'python': {
'3.6': 'mcr.microsoft.com/azure-functions/python:3.0-python3.6-appservice',
'3.7': 'mcr.microsoft.com/azure-functions/python:3.0-python3.7-appservice',
'3.8': 'mcr.microsoft.com/azure-functions/python:3.0-python3.8-appservice'
},
'dotnet': {
'3': 'mcr.microsoft.com/azure-functions/dotnet:3.0-appservice'
},
'java': {
'8': 'mcr.microsoft.com/azure-functions/java:3.0-java8-appservice'
}
'node': ['10', '12'],
'python': ['3.6', '3.7', '3.8'],
'dotnet': ['3'],
'java': ['8']
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from azure.mgmt.web.models import DatabaseType, ConnectionStringType, BuiltInAuthenticationProvider, AzureStorageType

from ._completers import get_hostname_completion_list
from ._constants import FUNCTIONS_VERSIONS_FUNCTIONAPP, RUNTIME_TO_IMAGE_FUNCTIONAPP
from ._constants import FUNCTIONS_VERSIONS, FUNCTIONS_VERSION_TO_SUPPORTED_RUNTIME_VERSIONS
from ._validators import (validate_timeout_value, validate_site_create, validate_asp_create,
validate_add_vnet, validate_front_end_scale_factor, validate_ase_create)

Expand Down Expand Up @@ -52,9 +52,9 @@ def load_arguments(self, _):

# combine all runtime versions for all functions versions
functionapp_runtime_to_version = {}
for functions_version in RUNTIME_TO_IMAGE_FUNCTIONAPP.values():
for functions_version in FUNCTIONS_VERSION_TO_SUPPORTED_RUNTIME_VERSIONS.values():
for runtime, val in functions_version.items():
functionapp_runtime_to_version[runtime] = functionapp_runtime_to_version.get(runtime, set()).union(val.keys())
functionapp_runtime_to_version[runtime] = functionapp_runtime_to_version.get(runtime, set()).union(val)

functionapp_runtime_to_version_texts = []
for runtime, runtime_versions in functionapp_runtime_to_version.items():
Expand Down Expand Up @@ -470,7 +470,7 @@ def load_arguments(self, _):
help='Provide a string value of a Storage Account in the provided Resource Group. Or Resource ID of a Storage Account in a different Resource Group')
c.argument('consumption_plan_location', options_list=['--consumption-plan-location', '-c'],
help="Geographic location where Function App will be hosted. Use `az functionapp list-consumption-locations` to view available locations.")
c.argument('functions_version', help='The functions app version.', arg_type=get_enum_type(FUNCTIONS_VERSIONS_FUNCTIONAPP))
c.argument('functions_version', help='The functions app version.', arg_type=get_enum_type(FUNCTIONS_VERSIONS))
c.argument('runtime', help='The functions runtime stack.', arg_type=get_enum_type(set(LINUX_RUNTIMES).union(set(WINDOWS_RUNTIMES))))
c.argument('runtime_version', help='The version of the functions runtime stack. '
'Allowed values for each --runtime are: ' + ', '.join(functionapp_runtime_to_version_texts))
Expand Down
35 changes: 16 additions & 19 deletions src/azure-cli/azure/cli/command_modules/appservice/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
should_create_new_rg, set_location, does_app_already_exist, get_profile_username,
get_plan_to_use, get_lang_from_content, get_rg_to_use, get_sku_to_use,
detect_os_form_src)
from ._constants import (RUNTIME_TO_DEFAULT_VERSION_FUNCTIONAPP, NODE_VERSION_DEFAULT_FUNCTIONAPP,
RUNTIME_TO_IMAGE_FUNCTIONAPP, NODE_VERSION_DEFAULT)
from ._constants import (FUNCTIONS_VERSION_TO_DEFAULT_RUNTIME_VERSION, FUNCTIONS_VERSION_TO_DEFAULT_NODE_VERSION,
FUNCTIONS_VERSION_TO_SUPPORTED_RUNTIME_VERSIONS, NODE_VERSION_DEFAULT)

logger = get_logger(__name__)

Expand Down Expand Up @@ -2394,7 +2394,7 @@ def create_function(cmd, resource_group_name, name, storage_account, plan=None,
if runtime_version is not None:
if runtime is None:
raise CLIError('Must specify --runtime to use --runtime-version')
allowed_versions = RUNTIME_TO_IMAGE_FUNCTIONAPP[functions_version][runtime].keys()
allowed_versions = FUNCTIONS_VERSION_TO_SUPPORTED_RUNTIME_VERSIONS[functions_version][runtime]
if runtime_version not in allowed_versions:
raise CLIError('--runtime-version {} is not supported for the selected --runtime {} and '
'--functions_version {}. Supported versions are: {}'
Expand All @@ -2420,13 +2420,11 @@ def create_function(cmd, resource_group_name, name, storage_account, plan=None,
else:
site_config.app_settings.append(NameValuePair(name='WEBSITES_ENABLE_APP_SERVICE_STORAGE',
value='true'))
if runtime not in RUNTIME_TO_IMAGE_FUNCTIONAPP[functions_version].keys():
raise CLIError("An appropriate linux image for runtime:'{}' was not found".format(runtime))
if runtime not in FUNCTIONS_VERSION_TO_SUPPORTED_RUNTIME_VERSIONS[functions_version]:
raise CLIError("An appropriate linux image for runtime:'{}', "
"functions_version: '{}' was not found".format(runtime, functions_version))
if deployment_container_image_name is None:
site_config.linux_fx_version = _get_linux_fx_functionapp(is_consumption,
functions_version,
runtime,
runtime_version)
site_config.linux_fx_version = _get_linux_fx_functionapp(functions_version, runtime, runtime_version)
else:
functionapp_def.kind = 'functionapp'
# adding appsetting to site to make it a function
Expand Down Expand Up @@ -2466,8 +2464,8 @@ def create_function(cmd, resource_group_name, name, storage_account, plan=None,
functionapp = LongRunningOperation(cmd.cli_ctx)(poller)

if consumption_plan_location and is_linux:
logger.warning("Your Linux function app '%s', that uses a consumption plan has been successfully"
"created but is not active until content is published using"
logger.warning("Your Linux function app '%s', that uses a consumption plan has been successfully "
"created but is not active until content is published using "
"Azure Portal or the Functions Core Tools.", name)
else:
_set_remote_or_local_git(cmd, functionapp, resource_group_name, name, deployment_source_url,
Expand All @@ -2494,21 +2492,20 @@ def _get_extension_version_functionapp(functions_version):
return '~2'


def _get_linux_fx_functionapp(is_consumption, functions_version, runtime, runtime_version):
def _get_linux_fx_functionapp(functions_version, runtime, runtime_version):
if runtime == 'dotnet':
return runtime.upper()
if runtime_version is None:
runtime_version = RUNTIME_TO_DEFAULT_VERSION_FUNCTIONAPP[functions_version][runtime]
if is_consumption:
return '{}|{}'.format(runtime.upper(), runtime_version)
# App service or Elastic Premium
return _format_fx_version(RUNTIME_TO_IMAGE_FUNCTIONAPP[functions_version][runtime][runtime_version])
runtime_version = FUNCTIONS_VERSION_TO_DEFAULT_RUNTIME_VERSION[functions_version][runtime]
return '{}|{}'.format(runtime.upper(), runtime_version)


def _get_website_node_version_functionapp(functions_version, runtime, runtime_version):
if runtime is None or runtime != 'node':
return NODE_VERSION_DEFAULT_FUNCTIONAPP[functions_version]
return FUNCTIONS_VERSION_TO_DEFAULT_NODE_VERSION[functions_version]
if runtime_version is not None:
return '~{}'.format(runtime_version)
return NODE_VERSION_DEFAULT_FUNCTIONAPP[functions_version]
return FUNCTIONS_VERSION_TO_DEFAULT_NODE_VERSION[functions_version]


def try_create_application_insights(cmd, functionapp):
Expand Down
Loading