Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
7 changes: 7 additions & 0 deletions src/spring/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Release History
===============
1.14.0
---
* Add new command -- `az spring application-configuration-service create --generation` to support create Application Configuration Service with different generation
* Add new command -- `az spring application-configuration-service update --generation` to support update Application Configuration Service to different generation
* Add new command -- `az spring application-configuration-service git repo add --ca-cert-name` to support bind certificate to Application Configuration Service Gen2

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
* Add new command -- `az spring application-configuration-service create --generation` to support create Application Configuration Service with different generation
* Add new command -- `az spring application-configuration-service update --generation` to support update Application Configuration Service to different generation
* Add new command -- `az spring application-configuration-service git repo add --ca-cert-name` to support bind certificate to Application Configuration Service Gen2
* Add new command -- `az spring application-configuration-service create --generation` to support creating Application Configuration Service with different generation
* Add new command -- `az spring application-configuration-service update --generation` to support updating Application Configuration Service to different generation
* Add new command -- `az spring application-configuration-service git repo add --ca-cert-name` to support binding certificate to Application Configuration Service Gen2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated


1.13.2
---
* Add argument `--build-certificates` in `az spring app deploy`.
Expand All @@ -23,6 +29,7 @@ Release History
1.12.2
---
* Add default `enabled_state` for `az spring config-server set` in Standard Counsumption tier.
>>>>>>> main
Comment thread
leonard520 marked this conversation as resolved.
Outdated

1.12.1
---
Expand Down
16 changes: 14 additions & 2 deletions src/spring/azext_spring/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
validate_acs_ssh_or_warn, validate_apm_properties, validate_apm_secrets,
validate_apm_not_exist, validate_apm_update, validate_apm_reference,
validate_apm_reference_and_enterprise_tier, validate_cert_reference,
validate_build_cert_reference)
validate_build_cert_reference, validate_acs_create)
from ._app_validator import (fulfill_deployment_param, active_deployment_exist,
ensure_not_active_deployment, validate_deloy_path, validate_deloyment_create_path,
validate_cpu, validate_build_cpu, validate_memory, validate_build_memory,
Expand All @@ -41,7 +41,7 @@
validate_app_force_set_system_identity_or_warning,
validate_app_force_set_user_identity_or_warning)
from ._utils import ApiType
from .vendored_sdks.appplatform.v2023_05_01_preview.models._app_platform_management_client_enums import (SupportedRuntimeValue, TestKeyType, BackendProtocol, SessionAffinity, ApmType, BindingType)
from .vendored_sdks.appplatform.v2023_05_01_preview.models._app_platform_management_client_enums import (ConfigurationServiceGeneration, SupportedRuntimeValue, TestKeyType, BackendProtocol, SessionAffinity, ApmType, BindingType)


name_type = CLIArgumentType(options_list=[
Expand Down Expand Up @@ -156,7 +156,14 @@ def load_arguments(self, _):
c.argument('enable_application_configuration_service',
action='store_true',
options_list=['--enable-application-configuration-service', '--enable-acs'],
arg_group="Application Configuration Service",
help='(Enterprise Tier Only) Enable Application Configuration Service.')
c.argument('application_configuration_service_generation',
arg_group="Application Configuration Service",
type=ConfigurationServiceGeneration,
options_list=['--application-configuration-service-generation', '--acs-gen'],
validator=validate_acs_create,
help='(Enterprise Tier Only) Application Configuration Service Generation to enable. Allowed values are: ' + ', '.join(list(ConfigurationServiceGeneration)))
c.argument('enable_application_live_view',
Comment on lines +161 to 167

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If this parameter has limited values, please add arg_type=get_enum_type(ConfigurationServiceGeneration) for the parameter and it is not necessay to specify the avaiable values manually in help.

Suggested change
c.argument('application_configuration_service_generation',
arg_group="Application Configuration Service",
type=ConfigurationServiceGeneration,
options_list=['--application-configuration-service-generation', '--acs-gen'],
validator=validate_acs_create,
help='(Enterprise Tier Only) Application Configuration Service Generation to enable. Allowed values are: ' + ', '.join(list(ConfigurationServiceGeneration)))
c.argument('enable_application_live_view',
c.argument('application_configuration_service_generation',
arg_group="Application Configuration Service",
arg_type=get_enum_type(ConfigurationServiceGeneration),
options_list=['--application-configuration-service-generation', '--acs-gen'],
validator=validate_acs_create,
help='(Enterprise Tier Only) Application Configuration Service Generation to enable.)
c.argument('enable_application_live_view',

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks! updated

action='store_true',
options_list=['--enable-application-live-view', '--enable-alv'],
Expand Down Expand Up @@ -810,6 +817,10 @@ def prepare_logs_argument(c):
with self.argument_context('spring application-configuration-service {}'.format(scope)) as c:
c.argument('app', app_name_type, help='Name of app.', validator=validate_app_name)

for scope in ['create', 'update']:
with self.argument_context('spring application-configuration-service {}'.format(scope)) as c:
c.argument('generation', type=ConfigurationServiceGeneration, help='Generation. Allowed values are: ' + ', '.join(list(ConfigurationServiceGeneration)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as above

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated


for scope in ['add', 'update']:
with self.argument_context('spring application-configuration-service git repo {}'.format(scope)) as c:
c.argument('patterns',
Expand All @@ -826,6 +837,7 @@ def prepare_logs_argument(c):
c.argument('host_key_algorithm', help='Host key algorithm of the added config.')
c.argument('private_key', help='Private_key of the added config.', validator=validate_acs_ssh_or_warn)
c.argument('host_key_check', help='Strict host key checking of the added config which is used in SSH authentication. If false, ignore errors with host key.')
c.argument('ca_cert_name', help='CA certificate name.')

for scope in ['add', 'update', 'remove']:
with self.argument_context('spring application-configuration-service git repo {}'.format(scope)) as c:
Expand Down
12 changes: 10 additions & 2 deletions src/spring/azext_spring/_tanzu_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from msrestazure.tools import resource_id
from .application_live_view import create as application_live_view_create
from .dev_tool_portal import create_or_update as dev_tool_portal_create

from .vendored_sdks.appplatform.v2023_05_01_preview.models._app_platform_management_client_enums import ConfigurationServiceGeneration
from .vendored_sdks.appplatform.v2023_05_01_preview import models

GATEWAY_RESOURCE_TYPE = "gateways"
Expand All @@ -32,10 +32,18 @@ def create_application_live_view(cmd, client, resource_group, service, enable_ap
return application_live_view_create(cmd, client, service, resource_group)


def create_application_configuration_service(cmd, client, resource_group, service, enable_application_configuration_service, **_):
def create_application_configuration_service(cmd, client, resource_group, service, enable_application_configuration_service, application_configuration_service_generation, **_):
if enable_application_configuration_service:
logger.warning(" - Creating Application Configuration Service ..")
acs_resource = models.ConfigurationServiceResource()
acs_resource.properties = models.ConfigurationServiceProperties()
if application_configuration_service_generation:
acs_resource.properties.generation = application_configuration_service_generation
logger.warning("Create with generation {}".format(application_configuration_service_generation))
else:
acs_resource.properties.generation = ConfigurationServiceGeneration.GEN1
logger.warning("Default generation will be Gen1")

return client.configuration_services.begin_create_or_update(resource_group, service, DEFAULT_NAME, acs_resource)


Expand Down
2 changes: 2 additions & 0 deletions src/spring/azext_spring/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ def _check_tanzu_components_not_enable(cmd, namespace):
raise ArgumentUsageError('--enable-application-live-view {}'.format(suffix))
if namespace.enable_application_accelerator:
raise ArgumentUsageError('--enable-application-accelerator {}'.format(suffix))
if namespace.application_configuration_service_generation:
raise ArgumentUsageError('--application_configuration_service_generation {}'.format(suffix))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
raise ArgumentUsageError('--application_configuration_service_generation {}'.format(suffix))
raise ArgumentUsageError('--application-configuration-service-generation {}'.format(suffix))



def validate_instance_count(namespace):
Expand Down
19 changes: 18 additions & 1 deletion src/spring/azext_spring/_validators_enterprise.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from azure.core.exceptions import ResourceNotFoundError
from knack.log import get_logger
from .vendored_sdks.appplatform.v2023_05_01_preview.models import (ApmReference, CertificateReference)
from .vendored_sdks.appplatform.v2023_05_01_preview.models._app_platform_management_client_enums import ApmType
from .vendored_sdks.appplatform.v2023_05_01_preview.models._app_platform_management_client_enums import (ApmType, ConfigurationServiceGeneration)

from ._resource_quantity import validate_cpu as validate_and_normalize_cpu
from ._resource_quantity import \
Expand Down Expand Up @@ -345,6 +345,23 @@ def _is_valid_app_and_profile_name(pattern):
return len(parts) == 2 and _is_valid_app_name(parts[0]) and _is_valid_profile_name(parts[1])


def validate_acs_create(namespace):
if namespace.application_configuration_service_generation is not None:
if namespace.enable_application_configuration_service is False:
raise ArgumentUsageError("--application_configuration_service_generation can only be set when enable application configuration service.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
raise ArgumentUsageError("--application_configuration_service_generation can only be set when enable application configuration service.")
raise ArgumentUsageError("--application-configuration-service-generation can only be set when enable application configuration service.")

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed



def validate_acs_create_or_update(namespace):
_validate_acs_generation(namespace)


def _validate_acs_generation(namespace):
if namespace.generation is None:
return
if (namespace.generation not in list(ConfigurationServiceGeneration)):
raise InvalidArgumentValueError("Allowed generation are: " + ', '.join(list(ConfigurationServiceGeneration)))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

After adding arg_type=get_enum_type() to the parameter, it is not necessary to valid the input values manually.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

updated



def validate_gateway_update(namespace):
_validate_sso(namespace)
validate_cpu(namespace)
Expand Down
46 changes: 38 additions & 8 deletions src/spring/azext_spring/application_configuration_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from azure.cli.core.util import sdk_no_wait
from knack.log import get_logger
from msrestazure.tools import resource_id

from .vendored_sdks.appplatform.v2023_05_01_preview.models._app_platform_management_client_enums import (GitImplementation, ConfigurationServiceGeneration)
from .vendored_sdks.appplatform.v2023_05_01_preview import models

APPLICATION_CONFIGURATION_SERVICE_NAME = "applicationConfigurationService"
Expand All @@ -23,8 +23,27 @@
logger = get_logger(__name__)


def application_configuration_service_create(cmd, client, service, resource_group):
acs_resource = models.ConfigurationServiceResource()
def application_configuration_service_create(cmd, client, service, resource_group,
generation=None):
if generation is None:
generation = ConfigurationServiceGeneration.GEN1

properties = models.ConfigurationServiceProperties(generation=generation)
acs_resource = models.ConfigurationServiceResource(properties=properties)
logger.warning("Create with generation {}".format(acs_resource.properties.generation))
return client.configuration_services.begin_create_or_update(resource_group, service, DEFAULT_NAME, acs_resource)


def application_configuration_service_update(cmd, client, service, resource_group,
generation=None):
acs_resource = client.configuration_services.get(resource_group, service, DEFAULT_NAME)
if generation is not None:
acs_resource.properties.generation = generation
logger.warning("Updating with generation {}".format(generation))
else:
acs_resource.properties.generation = ConfigurationServiceGeneration.GEN1
logger.warning("Default generation will be Gen1")
logger.warning(acs_resource.properties.generation)
return client.configuration_services.begin_create_or_update(resource_group, service, DEFAULT_NAME, acs_resource)


Expand All @@ -38,8 +57,8 @@ def application_configuration_service_show(cmd, client, service, resource_group)

def application_configuration_service_clear(cmd, client, service, resource_group):
logger.warn("Please make sure no patterns are used in your apps.")
properties = models.ConfigurationServiceGitProperty()
acs_resource = models.ConfigurationServiceResource(properties=properties)
acs_resource = client.configuration_services.get(resource_group, service, DEFAULT_NAME)
acs_resource.properties.settings = models.ConfigurationServiceSettings()
return client.configuration_services.begin_create_or_update(resource_group, service, DEFAULT_NAME, acs_resource)


Expand All @@ -52,9 +71,10 @@ def application_configuration_service_git_add(cmd, client, service, resource_gro
host_key_algorithm=None,
private_key=None,
host_key_check=None,
ca_cert_name=None,
no_wait=False):
repo = models.ConfigurationServiceGitRepository(name=name, patterns=patterns, uri=uri, label=label)
repo = _replace_repo_with_input(repo, patterns, uri, label, search_paths, username, password, host_key, host_key_algorithm, private_key, host_key_check)
repo = _replace_repo_with_input(repo, patterns, uri, label, search_paths, username, password, host_key, host_key_algorithm, private_key, host_key_check, _get_cert_resource_id_by_name(cmd, resource_group, service, ca_cert_name))

acs_resource = _get_or_default_acs_resource(client, resource_group, service)
repos = acs_resource.properties.settings.git_property.repositories
Expand All @@ -80,10 +100,11 @@ def application_configuration_service_git_update(cmd, client, service, resource_
host_key_algorithm=None,
private_key=None,
host_key_check=None,
ca_cert_name=None,
no_wait=False):
acs_resource = _get_or_default_acs_resource(client, resource_group, service)
repo = _get_existing_repo(acs_resource.properties.settings.git_property.repositories, name)
repo = _replace_repo_with_input(repo, patterns, uri, label, search_paths, username, password, host_key, host_key_algorithm, private_key, host_key_check)
repo = _replace_repo_with_input(repo, patterns, uri, label, search_paths, username, password, host_key, host_key_algorithm, private_key, host_key_check, _get_cert_resource_id_by_name(cmd, resource_group, service, ca_cert_name))

_validate_acs_settings(client, resource_group, service, acs_resource.properties.settings)

Expand Down Expand Up @@ -152,7 +173,15 @@ def _get_app_addon_configs_with_acs(addon_configs):
return addon_configs


def _replace_repo_with_input(repo, patterns, uri, label, search_paths, username, password, host_key, host_key_algorithm, private_key, strict_host_key_checking):
def _get_cert_resource_id_by_name(cmd, resource_group, service, ca_cert_name):
ca_cert_resource_id = None
if ca_cert_name:
subscription = get_subscription_id(cmd.cli_ctx)
ca_cert_resource_id = "/subscriptions/{}/resourceGroups/{}/providers/Microsoft.AppPlatform/Spring/{}/certificates/{}".format(subscription, resource_group, service, ca_cert_name)
return ca_cert_resource_id


def _replace_repo_with_input(repo, patterns, uri, label, search_paths, username, password, host_key, host_key_algorithm, private_key, strict_host_key_checking, ca_cert_resource_id):
if patterns:
patterns = patterns.split(",")
if search_paths:
Expand All @@ -170,6 +199,7 @@ def _replace_repo_with_input(repo, patterns, uri, label, search_paths, username,
repo.host_key_algorithm = host_key_algorithm or repo.host_key_algorithm
repo.private_key = private_key or repo.private_key
repo.strict_host_key_checking = strict_host_key_checking or repo.strict_host_key_checking
repo.ca_cert_resource_id = ca_cert_resource_id or repo.ca_cert_resource_id
return repo


Expand Down
5 changes: 3 additions & 2 deletions src/spring/azext_spring/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
transform_container_registry_output)
from ._validators import validate_app_insights_command_not_supported_tier
from ._marketplace import (transform_marketplace_plan_output)
from ._validators_enterprise import (validate_gateway_update, validate_api_portal_update, validate_dev_tool_portal, validate_customized_accelerator, validate_central_build_instance)
from ._validators_enterprise import (validate_acs_create_or_update, validate_gateway_update, validate_api_portal_update, validate_dev_tool_portal, validate_customized_accelerator, validate_central_build_instance)
from ._app_managed_identity_validator import (validate_app_identity_remove_or_warning,
validate_app_identity_assign_or_warning)

Expand Down Expand Up @@ -303,7 +303,8 @@ def load_command_table(self, _):
table_transformer=transform_application_configuration_service_output)
g.custom_command('bind', 'application_configuration_service_bind')
g.custom_command('unbind', 'application_configuration_service_unbind')
g.custom_command('create', 'application_configuration_service_create', table_transformer=transform_application_configuration_service_output)
g.custom_command('create', 'application_configuration_service_create', validator=validate_acs_create_or_update, table_transformer=transform_application_configuration_service_output)
g.custom_command('update', 'application_configuration_service_update', validator=validate_acs_create_or_update, table_transformer=transform_application_configuration_service_output)
g.custom_command('delete', 'application_configuration_service_delete', confirmation=True)

with self.command_group('spring application-configuration-service git repo',
Expand Down
2 changes: 2 additions & 0 deletions src/spring/azext_spring/spring_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def spring_create(cmd, client, resource_group, name,
registry_username=None,
registry_password=None,
enable_application_configuration_service=False,
application_configuration_service_generation=None,
enable_application_live_view=False,
enable_service_registry=False,
enable_gateway=False,
Expand Down Expand Up @@ -222,6 +223,7 @@ def spring_create(cmd, client, resource_group, name,
'registry_username': registry_username,
'registry_password': registry_password,
'enable_application_configuration_service': enable_application_configuration_service,
'application_configuration_service_generation': application_configuration_service_generation,
'enable_application_live_view': enable_application_live_view,
'enable_service_registry': enable_service_registry,
'enable_gateway': enable_gateway,
Expand Down
Loading