Skip to content

Commit 80434e6

Browse files
author
zmssp
authored
Add remote debugging support for spring (#5453)
1 parent 4367bb5 commit 80434e6

File tree

9 files changed

+1441
-2
lines changed

9 files changed

+1441
-2
lines changed

src/spring/HISTORY.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
Release History
22
===============
3+
1.1.11
4+
---
5+
* Add command `az spring app deployment enable-remote-debugging`.
6+
* Add command `az spring app deployment disable-remote-debugging`.
7+
* Add command `az spring app deployment get-remote-debugging-config`.
8+
39
1.1.10
410
---
511
* Remove `Preview` tag for user-assigned identities of apps.

src/spring/azext_spring/_help.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,21 @@
216216
short-summary: Restart instances of the app, default to production deployment.
217217
"""
218218

219+
helps['spring app enable-remote-debugging'] = """
220+
type: command
221+
short-summary: Enable remote debugging for a deployment.
222+
"""
223+
224+
helps['spring app disable-remote-debugging'] = """
225+
type: command
226+
short-summary: Disable remote debugging for a deployment.
227+
"""
228+
229+
helps['spring app get-remote-debugging-config'] = """
230+
type: command
231+
short-summary: Get the remote debugging configuration of a deployment.
232+
"""
233+
219234
helps['spring app deploy'] = """
220235
type: command
221236
short-summary: Deploy source code or pre-built binary to an app and update related configurations.

src/spring/azext_spring/_params.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
validate_vnet, validate_vnet_required_parameters, validate_node_resource_group,
1414
validate_tracing_parameters_asc_create, validate_tracing_parameters_asc_update,
1515
validate_app_insights_parameters, validate_instance_count, validate_java_agent_parameters,
16-
validate_ingress_timeout, validate_jar, validate_ingress_send_timeout, validate_ingress_session_max_age)
16+
validate_ingress_timeout, validate_remote_debugging_port, validate_jar, validate_ingress_send_timeout,
17+
validate_ingress_session_max_age)
1718
from ._validators_enterprise import (only_support_enterprise, validate_builder_resource, validate_builder_create,
1819
validate_builder_update, validate_build_pool_size,
1920
validate_git_uri, validate_acs_patterns, validate_config_file_patterns,
@@ -287,6 +288,18 @@ def load_arguments(self, _):
287288
c.argument('deployment', options_list=[
288289
'--deployment', '-d'], help='Name of an existing deployment of the app. Default to the production deployment if not specified.', validator=fulfill_deployment_param)
289290

291+
for scope in ['spring app disable-remote-debugging', 'spring app get-remote-debugging-config']:
292+
with self.argument_context(scope) as c:
293+
c.argument('deployment', options_list=[
294+
'--deployment', '-d'], help='Name of an existing deployment of the app. Default to the production deployment if not specified.', validator=fulfill_deployment_param)
295+
296+
with self.argument_context('spring app enable-remote-debugging') as c:
297+
c.argument('deployment', options_list=[
298+
'--deployment', '-d'], help='Name of an existing deployment of the app. Default to the production deployment if not specified.', validator=fulfill_deployment_param)
299+
c.argument('remote_debugging_port', options_list=['--port', '-p'], type=int, default=5005,
300+
help='Remote debugging port, the value should be from 1024 to 65536, default value is 5005',
301+
validator=validate_remote_debugging_port)
302+
290303
with self.argument_context('spring app unset-deployment') as c:
291304
c.argument('name', name_type, help='Name of app.', validator=active_deployment_exist)
292305

src/spring/azext_spring/_validators.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ def validate_ingress_timeout(namespace):
218218
raise InvalidArgumentValueError("Invalid value: Ingress read timeout must be in the range [1,1800].")
219219

220220

221+
def validate_remote_debugging_port(namespace):
222+
if namespace.remote_debugging_port is not None and (namespace.remote_debugging_port < 1024 or
223+
namespace.remote_debugging_port > 65535):
224+
raise InvalidArgumentValueError("Invalid value: remote debugging port must be in the range [1024,65535].")
225+
226+
221227
def validate_ingress_send_timeout(namespace):
222228
if namespace.ingress_send_timeout is not None and (namespace.ingress_read_timeout < 1 or
223229
namespace.ingress_read_timeout > 1800):

src/spring/azext_spring/commands.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ def load_command_table(self, _):
149149
g.custom_command('append-persistent-storage', 'app_append_persistent_storage')
150150
g.custom_command('append-loaded-public-certificate', 'app_append_loaded_public_certificate')
151151
g.custom_command('connect', 'app_connect')
152+
g.custom_command('enable-remote-debugging', 'deployment_enable_remote_debugging', supports_no_wait=True)
153+
g.custom_command('disable-remote-debugging', 'deployment_disable_remote_debugging', supports_no_wait=True)
154+
g.custom_command('get-remote-debugging-config', 'deployment_get_remote_debugging')
152155

153156
with self.command_group('spring app identity', custom_command_type=app_managed_identity_command,
154157
exception_handler=handle_asc_exception) as g:

src/spring/azext_spring/custom.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from .vendored_sdks.appplatform.v2022_01_01_preview import models as models_20220101preview
2727
from .vendored_sdks.appplatform.v2022_05_01_preview import models as models_20220501preview
2828
from .vendored_sdks.appplatform.v2020_07_01.models import _app_platform_management_client_enums as AppPlatformEnums
29+
from .vendored_sdks.appplatform.v2022_09_01_preview import models as models_20220901preview
2930
from .vendored_sdks.appplatform.v2020_11_01_preview import (
3031
AppPlatformManagementClient as AppPlatformManagementClient_20201101preview
3132
)
@@ -315,6 +316,23 @@ def app_stop(cmd, client,
315316
resource_group, service, name, deployment.name)
316317

317318

319+
def deployment_enable_remote_debugging(cmd, client, resource_group, service, name, remote_debugging_port=None, deployment=None, no_wait=False):
320+
logger.warning("Enable remote debugging for the app '{}', deployment '{}'".format(name, deployment.name))
321+
remote_debugging_payload = models_20220901preview.RemoteDebuggingPayload(port=remote_debugging_port)
322+
return sdk_no_wait(no_wait, client.deployments.begin_enable_remote_debugging,
323+
resource_group, service, name, deployment.name, remote_debugging_payload)
324+
325+
326+
def deployment_disable_remote_debugging(cmd, client, resource_group, service, name, deployment=None, no_wait=False):
327+
logger.warning("Disable remote debugging for the app '{}', deployment '{}'".format(name, deployment.name))
328+
return sdk_no_wait(no_wait, client.deployments.begin_disable_remote_debugging,
329+
resource_group, service, name, deployment.name)
330+
331+
332+
def deployment_get_remote_debugging(cmd, client, resource_group, service, name, deployment=None):
333+
return client.deployments.get_remote_debugging_config(resource_group, service, name, deployment.name)
334+
335+
318336
def app_restart(cmd, client,
319337
resource_group,
320338
service,

0 commit comments

Comments
 (0)