def update_fd_routing_rules(instance, frontend_endpoints=None, accepted_protocols=None, patterns_to_match=None, custom_forwarding_path=None, forwarding_protocol=None, backend_pool=None, enabled=None, dynamic_compression=None, query_parameter_strip_directive=None): from azext_front_door.vendored_sdks.models import SubResource with UpdateContext(instance) as c: c.update_param( 'frontend_endpoints', [SubResource(id=x) for x in frontend_endpoints] if frontend_endpoints else None, False) c.update_param('accepted_protocols', accepted_protocols, False) c.update_param('patterns_to_match', patterns_to_match, False) c.update_param('custom_forwarding_path', custom_forwarding_path, False) c.update_param('forwarding_protocol', forwarding_protocol, False) c.update_param('backend_pool', SubResource(id=backend_pool) if backend_pool else None, False) c.update_param('enabled_state', enabled, False) with UpdateContext(instance.cache_configuration) as c: c.update_param('dynamic_compression', dynamic_compression, False) c.update_param('query_parameter_strip_directive', query_parameter_strip_directive, False) return instance
def create_fd_backend_pools(cmd, resource_group_name, front_door_name, item_name, load_balancing_settings, probe_settings, address, http_port=80, https_port=443, disabled=None, priority=1, weight=50, backend_host_header=None): from azext_front_door.vendored_sdks.models import BackendPool, SubResource pool = BackendPool( name=item_name, load_balancing_settings=SubResource( id=load_balancing_settings) if load_balancing_settings else None, health_probe_settings=SubResource( id=probe_settings) if probe_settings else None, resource_state='Disabled' if disabled else 'Enabled', backends=[{ 'address': address, 'http_port': http_port, 'https_port': https_port, 'enabled_state': 'Disabled' if disabled else 'Enabled', 'priority': priority, 'weight': weight, 'backend_host_header': backend_host_header or address }]) return _upsert_frontdoor_subresource(cmd, resource_group_name, front_door_name, 'backend_pools', pool, 'name')
def create_fd_routing_rules(cmd, resource_group_name, front_door_name, item_name, frontend_endpoints, backend_pool, accepted_protocols=None, patterns_to_match=None, custom_forwarding_path=None, forwarding_protocol=None, disabled=None, dynamic_compression=None, query_parameter_strip_directive=None): from azext_front_door.vendored_sdks.models import CacheConfiguration, RoutingRule, SubResource rule = RoutingRule( name=item_name, enabled_state='Disabled' if disabled else 'Enabled', frontend_endpoints=[SubResource( id=x) for x in frontend_endpoints] if frontend_endpoints else None, accepted_protocols=accepted_protocols or ['Http'], patterns_to_match=patterns_to_match or ['/*'], custom_forwarding_path=custom_forwarding_path, forwarding_protocol=forwarding_protocol, backend_pool=SubResource(id=backend_pool) if backend_pool else None, cache_configuration=CacheConfiguration( query_parameter_strip_directive=query_parameter_strip_directive, dynamic_compression=dynamic_compression)) return _upsert_frontdoor_subresource(cmd, resource_group_name, front_door_name, 'routing_rules', rule, 'name')
def update_fd_backend_pools(instance, load_balancing_settings=None, probe_settings=None): from azext_front_door.vendored_sdks.models import SubResource with UpdateContext(instance) as c: c.update_param('loadBalancingSettings', SubResource(id=load_balancing_settings) if load_balancing_settings else None, False) c.update_param('healthProbeSettings', SubResource(id=probe_settings) if probe_settings else None, False) return instance
def configure_fd_frontend_endpoint_https(cmd, resource_group_name, front_door_name, frontend_endpoint_name, disable=None, protocol=None, secret_name=None, secret_version=None, certificate_type=None, certificate_source=None, vault=None): if disable: return cf_fd_frontend_endpoints(cmd.cli_ctx, None).disable_https( resource_group_name, front_door_name, frontend_endpoint_name) # if not being disabled, then must be enabled from azext_front_door.vendored_sdks.models import CustomHttpsConfiguration, SubResource config = CustomHttpsConfiguration( certificate_source=certificate_source, protocol_type=protocol, vault=SubResource(id=vault) if vault else None, secret_name=secret_name, secret_version=secret_version, certificate_type=certificate_type) return cf_fd_frontend_endpoints(cmd.cli_ctx, None).enable_https(resource_group_name, front_door_name, frontend_endpoint_name, config)
def update_fd_frontend_endpoints(instance, host_name=None, session_affinity_enabled=None, session_affinity_ttl=None, waf_policy=None): from azext_front_door.vendored_sdks.models import SubResource with UpdateContext(instance) as c: c.update_param('hostName', host_name, False) c.update_param('sessionAffinityEnabledState', session_affinity_enabled, False) c.update_param('sessionAffinityTtlSeconds', session_affinity_ttl, False) c.update_param('webApplicationFirewallPolicyLink', SubResource(id=waf_policy) if waf_policy else None, False) return instance
def update_fd_routing_rule(parent, instance, item_name, frontend_endpoints=None, accepted_protocols=None, # pylint: disable=unused-argument patterns_to_match=None, custom_forwarding_path=None, forwarding_protocol=None, backend_pool=None, enabled=None, dynamic_compression=None, caching=None, query_parameter_strip_directive=None, redirect_type=None, redirect_protocol=None, custom_host=None, custom_path=None, custom_fragment=None, custom_query_string=None): from azext_front_door.vendored_sdks.models import SubResource if instance: if hasattr(instance.route_configuration, 'forwarding_protocol'): with UpdateContext(instance) as c: c.update_param('frontend_endpoints', [SubResource(id=x) for x in frontend_endpoints] if frontend_endpoints else None, False) c.update_param('accepted_protocols', accepted_protocols, False) c.update_param('patterns_to_match', patterns_to_match, False) c.update_param('enabled_state', enabled, False) with UpdateContext(instance.route_configuration) as c: c.update_param('custom_forwarding_path', custom_forwarding_path, False) c.update_param('forwarding_protocol', forwarding_protocol, False) c.update_param('backend_pool', SubResource(id=backend_pool) if backend_pool else None, False) if caching: with UpdateContext(instance.route_configuration.cache_configuration) as c: c.update_param('dynamic_compression', dynamic_compression, False) c.update_param('query_parameter_strip_directive', query_parameter_strip_directive, False) else: if hasattr(instance.route_configuration, 'cache_configuration'): instance.route_configuration.cache_configuration = None elif hasattr(instance.route_configuration, 'redirect_protocol'): with UpdateContext(instance) as c: c.update_param('frontend_endpoints', [SubResource(id=x) for x in frontend_endpoints] if frontend_endpoints else None, False) c.update_param('accepted_protocols', accepted_protocols, False) c.update_param('patterns_to_match', patterns_to_match, False) c.update_param('enabled_state', enabled, False) with UpdateContext(instance.route_configuration) as c: c.update_param('redirect_type', redirect_type, False) c.update_param('redirect_protocol', redirect_protocol, False) c.update_param('custom_host', custom_host, False) c.update_param('custom_path', custom_path, False) c.update_param('custom_fragment', custom_fragment, False) c.update_param('custom_query_string', custom_query_string, False) return parent
def create_fd_frontend_endpoints(cmd, resource_group_name, front_door_name, item_name, host_name, session_affinity_enabled=None, session_affinity_ttl=None, waf_policy=None): from azext_front_door.vendored_sdks.models import FrontendEndpoint, SubResource endpoint = FrontendEndpoint( name=item_name, host_name=host_name, session_affinity_enabled_state=session_affinity_enabled, session_affinity_ttl_seconds=session_affinity_ttl, web_application_firewall_policy_link=SubResource(id=waf_policy) if waf_policy else None ) return _upsert_frontdoor_subresource(cmd, resource_group_name, front_door_name, 'frontend_endpoints', endpoint, 'name')
def configure_fd_frontend_endpoint_https_keyvault(cmd, resource_group_name, front_door_name, item_name, vault_id, secret_name, secret_version): from azext_front_door.vendored_sdks.models import CustomHttpsConfiguration, SubResource config = CustomHttpsConfiguration( certificate_source="AzureKeyVault", protocol_type="ServerNameIndication", vault=SubResource(id=vault_id), secret_name=secret_name, secret_version=secret_version, certificate_type=None ) cf_fd_frontend_endpoints(cmd.cli_ctx, None).enable_https(resource_group_name, front_door_name, item_name, config) return get_fd_frontend_endpoints(cmd, resource_group_name, front_door_name, item_name)
def create_fd_routing_rules(cmd, resource_group_name, front_door_name, item_name, frontend_endpoints, route_type, backend_pool=None, accepted_protocols=None, patterns_to_match=None, custom_forwarding_path=None, forwarding_protocol=None, disabled=None, dynamic_compression=None, query_parameter_strip_directive=None, redirect_type='Moved', redirect_protocol='MatchRequest', custom_host=None, custom_path=None, custom_fragment=None, custom_query_string=None): from azext_front_door.vendored_sdks.models import (CacheConfiguration, RoutingRule, SubResource, ForwardingConfiguration, RedirectConfiguration) forwarding_usage = ('usage error: [--backend-pool BACKEND_POOL] ' '[--custom-forwarding-path CUSTOM_FORWARDING_PATH] ' '[--forwarding-protocol FORWARDING_PROTOCOL] ' '[--query-parameter-strip-directive {StripNone,StripAll}] ' '[--dynamic-compression [{Enabled,Disabled}]]') redirect_usage = ('usage error: [--redirect-type {Moved,Found,TemporaryRedirect,PermanentRedirect}]' '[--redirect-protocol {HttpOnly,HttpsOnly,MatchRequest}] ' '[--custom-host CUSTOM_HOST] [--custom-path CUSTOM_PATH] ' '[--custom-fragment CUSTOM_FRAGMENT] [--custom-query-string CUSTOM_QUERY_STRING]') # pylint: disable=line-too-long if (route_type == 'Forward' and any([custom_host, custom_path, custom_fragment, custom_query_string]) and getattr(redirect_type, 'is_default', None) and getattr(redirect_protocol, 'is_default', None)): from knack.util import CLIError raise CLIError(forwarding_usage) if route_type == 'Redirect' and any([custom_forwarding_path, forwarding_protocol, backend_pool, query_parameter_strip_directive, dynamic_compression]): from knack.util import CLIError raise CLIError(redirect_usage) if route_type == 'Forward': rule = RoutingRule( name=item_name, enabled_state='Disabled' if disabled else 'Enabled', frontend_endpoints=[SubResource(id=x) for x in frontend_endpoints] if frontend_endpoints else None, accepted_protocols=accepted_protocols or ['Http'], patterns_to_match=patterns_to_match or ['/*'], route_configuration=ForwardingConfiguration( custom_forwarding_path=custom_forwarding_path, forwarding_protocol=forwarding_protocol, backend_pool=SubResource(id=backend_pool) if backend_pool else None, cache_configuration=CacheConfiguration( query_parameter_strip_directive=query_parameter_strip_directive, dynamic_compression=dynamic_compression ) ) ) elif route_type == 'Redirect': rule = RoutingRule( name=item_name, enabled_state='Disabled' if disabled else 'Enabled', frontend_endpoints=[SubResource(id=x) for x in frontend_endpoints] if frontend_endpoints else None, accepted_protocols=accepted_protocols or ['Http'], patterns_to_match=patterns_to_match or ['/*'], route_configuration=RedirectConfiguration( redirect_type=redirect_type, redirect_protocol=redirect_protocol, custom_host=custom_host, custom_path=custom_path, custom_fragment=custom_fragment, custom_query_string=custom_query_string ) ) return _upsert_frontdoor_subresource(cmd, resource_group_name, front_door_name, 'routing_rules', rule, 'name')