Skip to content
2 changes: 2 additions & 0 deletions src/spring/HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Release History
* Command `az spring create` has new argument "--ingress-read-timeout" to set ingress read timeout when create Azure Spring Apps.
* Command `az spring update` has new argument "--ingress-read-timeout" to update ingress read timeout for Azure Spring Apps.
* Command `az spring create` has new argument "--marketplace-plan-id" to purchase SaaS resource against given plan for Azure Spring Apps.
* Command `az spring create` and `az spring update` has new argument "--enable-log-stream-public-endpoint" to set whether assign public endpoint for log streaming in vnet injection instance.
* Command `az spring app create` and `az spring app update` has new argument "--assign_public_endpoint" to set whether assign endpoint URL which could be accessed out of virtual network for vnet injection instance app.
* Command `az spring app deploy` and `az spring app deployment create` has new argument "--build-cpu" and "--build-memory" to set cpu and memory during build process.

1.0.0
Expand Down
14 changes: 12 additions & 2 deletions src/spring/azext_spring/_app_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
from azure.cli.core.azclierror import FileOperationError, InvalidArgumentValueError
from .vendored_sdks.appplatform.v2022_01_01_preview import models
from .vendored_sdks.appplatform.v2022_03_01_preview import models as models_20220301preview
from .vendored_sdks.appplatform.v2022_05_01_preview import models as models_20220501preview
from azure.cli.core.util import get_file_json


class DefaultApp:
def format_resource(self, **kwargs):
return models.AppResource(
return models_20220501preview.AppResource(
properties=self._format_properties(**kwargs),
identity=self._format_identity(**kwargs)
)
Expand All @@ -22,7 +23,8 @@ def _format_properties(self, **kwargs):
kwargs['loaded_certificates'] = self._load_public_certificate_file(**kwargs)
kwargs['persistent_disk'] = self._load_persistent_disk(**kwargs)
kwargs['temporary_disk'] = self._load_temp_disk(**kwargs)
return models.AppResourceProperties(**kwargs)
kwargs['vnet_addons'] = self._load_vnet_addons(**kwargs)
return models_20220501preview.AppResourceProperties(**kwargs)

def _format_identity(self, system_assigned=None, user_assigned=None, **_):
target_identity_type = self._get_identity_assign_type(system_assigned, user_assigned)
Expand Down Expand Up @@ -118,6 +120,14 @@ def _load_custom_persistent_disks(self, client, resource_group, service, persist
custom_persistent_disk_properties=custom_persistent_disk_properties))
return custom_persistent_disks

def _load_vnet_addons(self, public_for_vnet=None, **_):
if public_for_vnet is not None:
return models_20220501preview.AppVNetAddons(
public_endpoint=public_for_vnet
)
else:
return None


class BasicTierApp(DefaultApp):
def _get_persistent_disk_size(self, enable_persistent_storage, **_):
Expand Down
3 changes: 3 additions & 0 deletions src/spring/azext_spring/_client_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
from .vendored_sdks.appplatform.v2020_11_01_preview import (
AppPlatformManagementClient as AppPlatformManagementClient_20201101preview
)
from .vendored_sdks.appplatform.v2022_05_01_preview import (
AppPlatformManagementClient as AppPlatformManagementClient_20220501preview
)
from .vendored_sdks.appplatform.v2022_01_01_preview import (
AppPlatformManagementClient as AppPlatformManagementClient_20220101preview
)
Expand Down
14 changes: 14 additions & 0 deletions src/spring/azext_spring/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ def load_arguments(self, _):
c.argument('service_runtime_subnet', arg_group='VNet Injection', options_list=['--service-runtime-subnet', '--svc-subnet'], help='The name or ID of an existing subnet in "vnet" into which to deploy the Spring Apps service runtime. Required when deploying into a Virtual Network.', validator=validate_vnet)
c.argument('service_runtime_network_resource_group', arg_group='VNet Injection', options_list=['--service-runtime-network-resource-group', '--svc-nrg'], help='The resource group where all network resources for Azure Spring Apps service runtime will be created in.', validator=validate_node_resource_group)
c.argument('app_network_resource_group', arg_group='VNet Injection', options_list=['--app-network-resource-group', '--app-nrg'], help='The resource group where all network resources for apps will be created in.', validator=validate_node_resource_group)
c.argument('enable_log_stream_public_endpoint',
arg_type=get_three_state_flag(),

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.

Could we use action='store_true' instead of get_three_state_flag()?

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.

Seems could not, as this parameter would be persisted as properties of a resource

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.

Got it, thanks~

options_list=['--enable-log-stream-public-endpoint', '--enable-lspa'],
help='If true, assign public endpoint for log streaming in vnet injection instance which could be accessed out of virtual network.')
c.argument('enable_java_agent',
arg_group='Application Insights',
arg_type=get_three_state_flag(),
Expand Down Expand Up @@ -186,6 +190,10 @@ def load_arguments(self, _):
c.argument('build_pool_size',
arg_type=get_enum_type(['S1', 'S2', 'S3', 'S4', 'S5']),
help='(Enterprise Tier Only) Size of build agent pool. See https://aka.ms/azure-spring-cloud-build-service-docs for size info.')
c.argument('enable_log_stream_public_endpoint',
arg_type=get_three_state_flag(),
options_list=['--enable-log-stream-public-endpoint', '--enable-lspa'],
help='If true, assign public endpoint for log streaming in vnet injection instance which could be accessed out of virtual network.')

for scope in ['spring create', 'spring update']:
with self.argument_context(scope) as c:
Expand All @@ -203,6 +211,9 @@ def load_arguments(self, _):
c.argument('assign_endpoint', arg_type=get_three_state_flag(),
help='If true, assign endpoint URL for direct access.', default=False,
options_list=['--assign-endpoint', c.deprecate(target='--is-public', redirect='--assign-endpoint', hide=True)])
c.argument('assign_public_endpoint',
arg_type=get_three_state_flag(),
help='If true, assign endpoint URL which could be accessed out of virtual network for vnet injection instance app.')
c.argument('assign_identity',
arg_type=get_three_state_flag(),
validator=validate_create_app_with_system_identity_or_warning,
Expand Down Expand Up @@ -231,6 +242,9 @@ def load_arguments(self, _):
c.argument('assign_endpoint', arg_type=get_three_state_flag(),
help='If true, assign endpoint URL for direct access.',
options_list=['--assign-endpoint', c.deprecate(target='--is-public', redirect='--assign-endpoint', hide=True)])
c.argument('assign_public_endpoint',
arg_type=get_three_state_flag(),
help='If true, assign endpoint URL which could be accessed out of virtual network for vnet injection instance app.')
c.argument('https_only', arg_type=get_three_state_flag(), help='If true, access app via https', default=False)
c.argument('enable_ingress_to_app_tls', arg_type=get_three_state_flag(),
help='If true, enable ingress to app tls',
Expand Down
6 changes: 5 additions & 1 deletion src/spring/azext_spring/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def app_create(cmd, client, resource_group, service, name,
enable_persistent_storage=None,
persistent_storage=None,
assign_endpoint=None,
assign_public_endpoint=None,
loaded_public_certificate_file=None):
'''app_create
Create app with an active deployment, deployment should be deployed with default banner
Expand Down Expand Up @@ -79,6 +80,7 @@ def app_create(cmd, client, resource_group, service, name,
'enable_persistent_storage': enable_persistent_storage,
'persistent_storage': persistent_storage,
'public': assign_endpoint,
'public_for_vnet': assign_public_endpoint,
'loaded_public_certificate_file': loaded_public_certificate_file
}
create_deployment_kwargs = {
Expand All @@ -94,6 +96,7 @@ def app_create(cmd, client, resource_group, service, name,
update_app_kwargs = {
'enable_persistent_storage': enable_persistent_storage,
'public': assign_endpoint,
'public_for_vnet': assign_public_endpoint
}

deployable = deployable_selector(**create_deployment_kwargs, **basic_kwargs)
Expand Down Expand Up @@ -128,6 +131,7 @@ def app_update(cmd, client, resource_group, service, name,
deployment=None, # set by validator
# app
assign_endpoint=None,
assign_public_endpoint=None,
enable_persistent_storage=None,
enable_ingress_to_app_tls=None,
https_only=None,
Expand Down Expand Up @@ -172,13 +176,13 @@ def app_update(cmd, client, resource_group, service, name,

app_kwargs = {
'public': assign_endpoint,
'public_for_vnet': assign_public_endpoint,
'enable_persistent_storage': enable_persistent_storage,
'persistent_storage': persistent_storage,
'loaded_public_certificate_file': loaded_public_certificate_file,
'enable_end_to_end_tls': enable_ingress_to_app_tls,
'https_only': https_only,
}

if deployment is None:
updated_deployment_kwargs = {k: v for k, v in deployment_kwargs.items() if v}
if updated_deployment_kwargs:
Expand Down
4 changes: 2 additions & 2 deletions src/spring/azext_spring/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def load_command_table(self, _):

app_command = CliCommandType(
operations_tmpl='azext_spring.app#{}',
client_factory=cf_spring_20220301preview
client_factory=cf_spring_20220501preview
)

app_managed_identity_command = CliCommandType(
Expand Down Expand Up @@ -144,7 +144,7 @@ def load_command_table(self, _):
table_transformer=transform_app_table_output)
g.custom_show_command(
'show', 'app_get', table_transformer=transform_app_table_output,
client_factory=cf_spring_20220301preview)
client_factory=cf_spring_20220501preview)
g.custom_command('start', 'app_start', supports_no_wait=True)
g.custom_command('stop', 'app_stop', supports_no_wait=True)
g.custom_command('restart', 'app_restart', supports_no_wait=True)
Expand Down
13 changes: 11 additions & 2 deletions src/spring/azext_spring/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _update_application_insights_asc_create(cmd,

def spring_update(cmd, client, resource_group, name, app_insights_key=None, app_insights=None,
disable_app_insights=None, sku=None, tags=None, build_pool_size=None,
ingress_read_timeout=None, no_wait=False):
enable_log_stream_public_endpoint=None, ingress_read_timeout=None, no_wait=False):
"""
TODO (jiec) app_insights_key, app_insights and disable_app_insights are marked as deprecated.
Will be decommissioned in future releases.
Expand All @@ -96,6 +96,7 @@ def spring_update(cmd, client, resource_group, name, app_insights_key=None, app_
updated_resource = models_20220501preview.ServiceResource()
update_service_tags = False
update_service_sku = False
update_log_stream_public_endpoint = False

# update service sku
if sku is not None:
Expand All @@ -107,6 +108,14 @@ def spring_update(cmd, client, resource_group, name, app_insights_key=None, app_
updated_resource_properties = models_20220501preview.ClusterResourceProperties()
updated_resource_properties.zone_redundant = None

if enable_log_stream_public_endpoint is not None:
updated_resource_properties.vnet_addons = models_20220501preview.ServiceVNetAddons(
log_stream_public_endpoint=enable_log_stream_public_endpoint
)
update_log_stream_public_endpoint = True
else:
updated_resource_properties.vnet_addons = None

_update_application_insights_asc_update(cmd, resource_group, name, location,
app_insights_key, app_insights, disable_app_insights, no_wait)

Expand All @@ -120,7 +129,7 @@ def spring_update(cmd, client, resource_group, name, app_insights_key=None, app_
updated_resource.tags = tags
update_service_tags = True

if update_service_tags is False and update_service_sku is False and (ingress_read_timeout is None):
if update_service_tags is False and update_service_sku is False and update_log_stream_public_endpoint is False and (ingress_read_timeout is None):
return resource

updated_resource.properties = updated_resource_properties
Expand Down
12 changes: 10 additions & 2 deletions src/spring/azext_spring/spring_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
# pylint: disable=wrong-import-order
# pylint: disable=unused-argument, logging-format-interpolation, protected-access, wrong-import-order, too-many-lines
from ._utils import (wait_till_end, _get_rg_location)
from .vendored_sdks.appplatform.v2022_01_01_preview import models
from .vendored_sdks.appplatform.v2022_05_01_preview import models
from knack.log import get_logger
from .custom import (_warn_enable_java_agent, _update_application_insights_asc_create)
from ._build_service import _update_default_build_agent_pool
from .buildpack_binding import create_default_buildpack_binding_for_application_insights
Expand Down Expand Up @@ -56,6 +54,7 @@ def create_service(self,
reserved_cidr_range=None,
service_runtime_network_resource_group=None,
app_network_resource_group=None,
enable_log_stream_public_endpoint=None,
zone_redundant=False,
sku=None,
tags=None,
Expand All @@ -66,6 +65,13 @@ def create_service(self,
zone_redundant=zone_redundant
)

if enable_log_stream_public_endpoint is not None:
properties.vnet_addons = models.ServiceVNetAddons(
log_stream_public_endpoint=enable_log_stream_public_endpoint
)
else:
properties.vnet_addons = None

if marketplace_plan_id:
properties.marketplace_resource = models.MarketplaceResource(
plan=marketplace_plan_id,
Expand Down Expand Up @@ -146,6 +152,7 @@ def spring_create(cmd, client, resource_group, name,
gateway_instance_count=None,
enable_api_portal=False,
api_portal_instance_count=None,
enable_log_stream_public_endpoint=None,
ingress_read_timeout=None,
marketplace_plan_id=None,
no_wait=False):
Expand Down Expand Up @@ -176,6 +183,7 @@ def spring_create(cmd, client, resource_group, name,
'gateway_instance_count': gateway_instance_count,
'enable_api_portal': enable_api_portal,
'api_portal_instance_count': api_portal_instance_count,
'enable_log_stream_public_endpoint': enable_log_stream_public_endpoint,
'marketplace_plan_id': marketplace_plan_id,
'no_wait': no_wait
}
Expand Down
Loading