Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions src/azure-cli/azure/cli/command_modules/network/_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -869,6 +869,9 @@
examples:
- name: Show backend health of an application gateway.
text: az network application-gateway show-backend-health -g MyResourceGroup -n MyAppGateway
- name: Show backend health of an application gateway for given combination of backend pool and http setting.
text: |-
az network application-gateway show-backend-health -g MyResourceGroup -n MyAppGateway --host-name-from-http-settings --path /test --timeout 100 --http-settings appGatewayBackendHttpSettings --address-pool appGatewayBackendPool
"""

helps['network application-gateway ssl-cert'] = """
Expand Down
16 changes: 16 additions & 0 deletions src/azure-cli/azure/cli/command_modules/network/_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,22 @@ def load_arguments(self, _):
c.argument('trusted_client_certificates', options_list=['--trusted-client-certificates', '--trusted-client-cert'], nargs='+', help='Array of references to application gateway trusted client certificates.')
c.argument('client_auth_configuration', options_list=['--client-auth-configuration', '--client-auth-config'], help='Client authentication configuration of the application gateway resource.', choices=['True', 'False'])

with self.argument_context('network application-gateway show-backend-health') as c:
c.argument('expand', help='Expands BackendAddressPool and BackendHttpSettings referenced in backend health.')

with self.argument_context('network application-gateway show-backend-health', min_api='2019-04-01', is_preview=True, arg_group="Probe Operation") as c:
c.argument('protocol', http_protocol_type, help='The HTTP settings protocol.')
c.argument('host', help='The name of the host to send the probe.')
c.argument('path', help='The relative path of the probe. Valid paths start from "/"')
c.argument('timeout', help='The probe timeout in seconds.')
c.argument('host_name_from_http_settings', help='Use host header from HTTP settings.',
arg_type=get_three_state_flag())
c.argument('match_body', help='Body that must be contained in the health response.')
c.argument('match_status_codes', nargs='+',
help='Space-separated list of allowed ranges of healthy status codes for the health response.')
c.argument('address_pool', help='The name or ID of the backend address pool.', completer=get_ag_subresource_completion_list('backend_address_pools'))
c.argument('http_settings', help='The name or ID of the HTTP settings.', completer=get_ag_subresource_completion_list('backend_http_settings_collection'))

# endregion

# region WebApplicationFirewallPolicy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def load_command_table(self, _):
g.custom_command('list', 'list_application_gateways')
g.command('start', 'begin_start')
g.command('stop', 'begin_stop')
g.command('show-backend-health', 'begin_backend_health', min_api='2016-09-01')
g.custom_command('show-backend-health', 'show_ag_backend_health', min_api='2016-09-01', client_factory=cf_application_gateways)
g.generic_update_command('update', supports_no_wait=True, setter_name='begin_create_or_update', custom_func_name='update_application_gateway')
g.wait_command('wait')

Expand Down
51 changes: 51 additions & 0 deletions src/azure-cli/azure/cli/command_modules/network/custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,57 @@ def remove_trusted_client_certificate(cmd, resource_group_name, application_gate
application_gateway_name, appgw)


def show_ag_backend_health(cmd, client, resource_group_name, application_gateway_name, expand=None,
protocol=None, host=None, path=None, timeout=None, host_name_from_http_settings=None,
match_body=None, match_status_codes=None, address_pool=None, http_settings=None):
from azure.cli.core.commands import LongRunningOperation
on_demand_arguments = {protocol, host, path, timeout, host_name_from_http_settings, match_body, match_status_codes,
address_pool, http_settings}
if on_demand_arguments.difference({None}) and cmd.supported_api_version(min_api='2019-04-01'):
SubResource, ApplicationGatewayOnDemandProbe, ApplicationGatewayProbeHealthResponseMatch = cmd.get_models(
"SubResource", "ApplicationGatewayOnDemandProbe", "ApplicationGatewayProbeHealthResponseMatch")
probe_request = ApplicationGatewayOnDemandProbe(
protocol=protocol,
host=host,
path=path,
timeout=timeout,
pick_host_name_from_backend_http_settings=host_name_from_http_settings
)
if match_body is not None or match_status_codes is not None:
probe_request.match = ApplicationGatewayProbeHealthResponseMatch(
body=match_body,
status_codes=match_status_codes,
)
if address_pool is not None:
if not is_valid_resource_id(address_pool):
address_pool = resource_id(
subscription=get_subscription_id(cmd.cli_ctx),
resource_group=resource_group_name,
namespace='Microsoft.Network',
type='applicationGateways',
name=application_gateway_name,
child_type_1='backendAddressPools',
child_name_1=address_pool
)
probe_request.backend_address_pool = SubResource(id=address_pool)
if http_settings is not None:
if not is_valid_resource_id(http_settings):
http_settings = resource_id(
subscription=get_subscription_id(cmd.cli_ctx),
resource_group=resource_group_name,
namespace='Microsoft.Network',
type='applicationGateways',
name=application_gateway_name,
child_type_1='backendHttpSettingsCollection',
child_name_1=http_settings
)
probe_request.backend_http_settings = SubResource(id=http_settings)
return LongRunningOperation(cmd.cli_ctx)(client.begin_backend_health_on_demand(
resource_group_name, application_gateway_name, probe_request, expand))

return LongRunningOperation(cmd.cli_ctx)(client.begin_backend_health(
resource_group_name, application_gateway_name, expand))

# endregion


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ network application-gateway root-cert:
network application-gateway rule:
rule_exclusions:
- require_wait_command_if_no_wait
network application-gateway show-backend-health:
parameters:
host_name_from_http_settings:
rule_exclusions:
- option_length_too_long
network application-gateway ssl-cert:
rule_exclusions:
- require_wait_command_if_no_wait
Expand Down
Loading