Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions src/azure-cli/HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ Release History
===============

**AppService**

az webapp create : Fixing issue when running the command with --runtime
* functionapp: Updated container image configuration for Linux apps

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same comments as in another PR, history.rst is automatically generated from PR titles. Pls refine PR titles and no need to change this file.


2.1.0
++++++
Expand Down
41 changes: 10 additions & 31 deletions src/azure-cli/azure/cli/command_modules/appservice/_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,39 +39,18 @@
'java': '8'
}
}
# functions version -> runtime -> runtime version : container image
RUNTIME_TO_IMAGE_FUNCTIONAPP = {
# functions version -> runtime : runtime versions
RUNTIME_TO_SUPPORTED_VERSIONS_FUNCTIONAPP = {
Comment thread
gzuber marked this conversation as resolved.
Outdated
'2': {
'node': {
'8': 'mcr.microsoft.com/azure-functions/node:2.0-node8-appservice',

Copy link
Copy Markdown
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
Copy Markdown
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'],
Comment thread
gzuber marked this conversation as resolved.
'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_FUNCTIONAPP, RUNTIME_TO_SUPPORTED_VERSIONS_FUNCTIONAPP
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 RUNTIME_TO_SUPPORTED_VERSIONS_FUNCTIONAPP.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
22 changes: 8 additions & 14 deletions src/azure-cli/azure/cli/command_modules/appservice/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
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)
RUNTIME_TO_SUPPORTED_VERSIONS_FUNCTIONAPP, 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 = RUNTIME_TO_SUPPORTED_VERSIONS_FUNCTIONAPP[functions_version][runtime]
if runtime_version not in allowed_versions:
Comment thread
gzuber marked this conversation as resolved.
raise CLIError('--runtime-version {} is not supported for the selected --runtime {} and '
'--functions_version {}. Supported versions are: {}'
Expand All @@ -2420,13 +2420,10 @@ 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():
if runtime not in RUNTIME_TO_SUPPORTED_VERSIONS_FUNCTIONAPP[functions_version]:
raise CLIError("An appropriate linux image for runtime:'{}' was not found".format(runtime))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Include runtime version in the error message

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

So if the user specifies a runtime_version, an error message will be emitted here:

raise CLIError('--runtime-version {} is not supported for the selected --runtime {} and '
'--functions_version {}. Supported versions are: {}'
.format(runtime_version, runtime, functions_version, ', '.join(allowed_versions)))

I added functions_version to this error message to make it more clear

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 +2463,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,13 +2491,10 @@ 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_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])
return '{}|{}'.format(runtime.upper(), runtime_version)
Comment thread
gzuber marked this conversation as resolved.


def _get_website_node_version_functionapp(functions_version, runtime, runtime_version):
Expand Down
Loading