Skip to content

Commit

Permalink
[App Service] Fix #26736: az logicapp create: Add `--runtime-versio…
Browse files Browse the repository at this point in the history
…n` and `--functions-version` optional parameters (#26957)
  • Loading branch information
DevArjun23 committed Aug 18, 2023
1 parent f3fd323 commit e2c7b48
Show file tree
Hide file tree
Showing 18 changed files with 3,571 additions and 2,505 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
STATIC_RUNTIME_NAME = "static" # not an official supported runtime but used for CLI logic
LINUX_SKU_DEFAULT = "P1V2"
FUNCTIONS_VERSIONS = ['2', '3', '4']
LOGICAPPS_NODE_RUNTIME_VERSIONS = ['~14', '~16', '~18']
FUNCTIONS_LINUX_RUNTIME_VERSION_REGEX = r"^.*\|(.*)$"
FUNCTIONS_WINDOWS_RUNTIME_VERSION_REGEX = r"^~(.*)$"
FUNCTIONS_NO_V2_REGIONS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from azure.mgmt.web.models import DatabaseType, ConnectionStringType, BuiltInAuthenticationProvider, AzureStorageType

from ._completers import get_hostname_completion_list
from ._constants import (FUNCTIONS_VERSIONS, WINDOWS_OS_NAME, LINUX_OS_NAME)
from ._constants import (FUNCTIONS_VERSIONS, LOGICAPPS_NODE_RUNTIME_VERSIONS, WINDOWS_OS_NAME, LINUX_OS_NAME)

from ._validators import (validate_timeout_value, validate_site_create, validate_asp_create,
validate_front_end_scale_factor, validate_ase_create, validate_ip_address,
Expand Down Expand Up @@ -804,6 +804,9 @@ def load_arguments(self, _):
c.argument('docker_registry_server_user', options_list=['--docker-registry-server-user', '-d'], help='The container registry server username.')
c.argument('docker_registry_server_password', options_list=['--docker-registry-server-password', '-w'],
help='The container registry server password. Required for private registries.')
c.argument('runtime_version', help='The runtime version for logic app.', arg_type=get_enum_type(LOGICAPPS_NODE_RUNTIME_VERSIONS))
c.argument('functions_version', options_list=['--functions-version', '-v'],
help='The functions version for logic app.', arg_type=get_enum_type(FUNCTIONS_VERSIONS))

with self.argument_context('logicapp show') as c:
c.argument('name', arg_type=logicapp_name_arg_type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,41 +7,36 @@
WINDOWS_RUNTIMES = ['dotnet', 'node', 'java', 'powershell']

DEFAULT_LOGICAPP_RUNTIME = 'node'
DEFAULT_LOGICAPP_RUNTIME_VERSION = '12'
DEFAULT_LOGICAPP_FUNCTION_VERSION = '3'
# functions version : default node version
FUNCTIONS_VERSION_TO_DEFAULT_NODE_VERSION = {
'2': '~10',
'3': '~12'
}
DEFAULT_LOGICAPP_FUNCTION_VERSION = '4'

# functions version -> runtime : default runtime version
FUNCTIONS_VERSION_TO_DEFAULT_RUNTIME_VERSION = {
'2': {
'node': '8',
'dotnet': '2',
'python': '3.7',
'java': '8'
'node': '~8',
'dotnet': '2'
},
'3': {
'node': '12',
'dotnet': '3',
'python': '3.7',
'java': '8'
'node': '~16',
'dotnet': '3'
},
'4': {
'node': '~16',
'dotnet': '6'
}
}
# functions version -> runtime : runtime versions
FUNCTIONS_VERSION_TO_SUPPORTED_RUNTIME_VERSIONS = {
'2': {
'node': ['8', '10'],
'python': ['3.6', '3.7'],
'dotnet': ['2'],
'java': ['8']
'node': ['~8', '~10'],
'dotnet': ['2']
},
'3': {
'node': ['10', '12'],
'python': ['3.6', '3.7', '3.8'],
'dotnet': ['3'],
'java': ['8']
'node': ['~14', '~16', '~18'],
'dotnet': ['3']
},
'4': {
'node': ['~16', '~18'],
'dotnet': ['3', '6']
}
}
# dotnet runtime version : dotnet linuxFxVersion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
# pylint: disable=unused-argument
from binascii import hexlify
from os import urandom

from knack.log import get_logger

from msrestazure.tools import is_valid_resource_id, parse_resource_id
Expand Down Expand Up @@ -34,34 +30,31 @@

from ._constants import (DEFAULT_LOGICAPP_FUNCTION_VERSION,
DEFAULT_LOGICAPP_RUNTIME,
DEFAULT_LOGICAPP_RUNTIME_VERSION,
FUNCTIONS_VERSION_TO_DEFAULT_RUNTIME_VERSION,
DOTNET_RUNTIME_VERSION_TO_DOTNET_LINUX_FX_VERSION)

logger = get_logger(__name__)


def create_logicapp(cmd, resource_group_name, name, storage_account, plan=None,
runtime_version=None, functions_version=DEFAULT_LOGICAPP_FUNCTION_VERSION,
app_insights=None, app_insights_key=None, disable_app_insights=None,
deployment_source_url=None, deployment_source_branch='master', deployment_local_git=None,
docker_registry_server_password=None, docker_registry_server_user=None,
deployment_container_image_name=None, tags=None, https_only=False):
# pylint: disable=too-many-statements, too-many-branches, too-many-locals
functions_version = DEFAULT_LOGICAPP_FUNCTION_VERSION
runtime = None
runtime_version = None

if not deployment_container_image_name:
runtime = DEFAULT_LOGICAPP_RUNTIME
runtime_version = DEFAULT_LOGICAPP_RUNTIME_VERSION
if runtime_version is None:
runtime_version = FUNCTIONS_VERSION_TO_DEFAULT_RUNTIME_VERSION[functions_version][runtime]

if deployment_source_url and deployment_local_git:
raise MutuallyExclusiveArgumentError('usage error: --deployment-source-url <url> | --deployment-local-git')

SiteConfig, Site, NameValuePair = cmd.get_models('SiteConfig', 'Site', 'NameValuePair')

docker_registry_server_url = parse_docker_image_name(
deployment_container_image_name)
docker_registry_server_url = parse_docker_image_name(deployment_container_image_name)

site_config = SiteConfig(app_settings=[])
logicapp_def = Site(location=None, site_config=site_config, tags=tags, https_only=https_only)
Expand Down Expand Up @@ -92,14 +85,16 @@ def create_logicapp(cmd, resource_group_name, name, storage_account, plan=None,
site_config.app_settings.append(NameValuePair(
name='FUNCTIONS_WORKER_RUNTIME', value=runtime))

if runtime == DEFAULT_LOGICAPP_RUNTIME and runtime_version is not None:
site_config.app_settings.append(NameValuePair(
name='WEBSITE_NODE_DEFAULT_VERSION', value=runtime_version))

con_string = _validate_and_get_connection_string(cmd.cli_ctx, resource_group_name, storage_account)

if is_linux:
logicapp_def.kind = 'functionapp,workflowapp,linux'
logicapp_def.reserved = True

site_config.app_settings.append(NameValuePair(name='MACHINEKEY_DecryptionKey',
value=str(hexlify(urandom(32)).decode()).upper()))
if deployment_container_image_name:
logicapp_def.kind = 'functionapp,workflowapp,linux,container'
site_config.app_settings.append(NameValuePair(name='DOCKER_CUSTOM_IMAGE_NAME',
Expand Down Expand Up @@ -133,7 +128,7 @@ def create_logicapp(cmd, resource_group_name, name, storage_account, plan=None,
site_config.always_on = True

# If plan is elastic premium or windows consumption, we need these app settings
if is_plan_elastic_premium(cmd, plan_info):
if is_plan_elastic_premium(cmd, plan_info) or is_plan_workflow_standard(cmd, plan_info):
site_config.app_settings.append(NameValuePair(name='WEBSITE_CONTENTAZUREFILECONNECTIONSTRING',
value=con_string))
site_config.app_settings.append(NameValuePair(
Expand Down Expand Up @@ -205,14 +200,6 @@ def _get_linux_fx_functionapp(functions_version, runtime, runtime_version):
return '{}|{}'.format(runtime, runtime_version)


def _get_java_version_functionapp(functions_version, runtime_version):
if runtime_version is None:
runtime_version = FUNCTIONS_VERSION_TO_DEFAULT_RUNTIME_VERSION[functions_version]['java']
if runtime_version == '8':
return '1.8'
return runtime_version


def show_logicapp(cmd, resource_group_name, name):
return show_app(cmd, resource_group_name=resource_group_name, name=name)

Expand All @@ -226,6 +213,7 @@ def scale_logicapp(cmd, resource_group_name, name, minimum_instance_count=None,
minimum_elastic_instance_count=minimum_instance_count)


# pylint: disable=unused-argument
def update_logicapp_scale(cmd, resource_group_name, name, slot=None,
function_app_scale_limit=None,
minimum_elastic_instance_count=None):
Expand Down

0 comments on commit e2c7b48

Please sign in to comment.