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_front_door(cmd, resource_group_name, front_door_name, backend_address, friendly_name=None, tags=None, disabled=None, no_wait=False, backend_host_header=None, frontend_host_name=None, probe_path='/', probe_protocol='Https', probe_interval=30, accepted_protocols=None, patterns_to_match=None, forwarding_protocol='MatchRequest'): from azext_front_door.vendored_sdks.models import ( FrontDoor, FrontendEndpoint, BackendPool, Backend, HealthProbeSettingsModel, LoadBalancingSettingsModel, RoutingRule) # set the default names (consider making user-settable) backend_pool_name = 'DefaultBackendPool' frontend_endpoint_name = 'DefaultFrontendEndpoint' probe_setting_name = 'DefaultProbeSettings' load_balancing_settings_name = 'DefaultLoadBalancingSettings' routing_rule_name = 'DefaultRoutingRule' # get the IDs to fill the references backend_pool_id = _front_door_subresource_id(cmd, resource_group_name, front_door_name, 'backendPools', backend_pool_name) frontend_endpoint_id = _front_door_subresource_id(cmd, resource_group_name, front_door_name, 'frontendEndpoints', frontend_endpoint_name) probe_settings_id = _front_door_subresource_id(cmd, resource_group_name, front_door_name, 'healthProbeSettings', probe_setting_name) load_balancing_settings_id = _front_door_subresource_id( cmd, resource_group_name, front_door_name, 'loadBalancingSettings', load_balancing_settings_name) front_door = FrontDoor( tags=tags, location='global', friendly_name=friendly_name or front_door_name, enabled_state='Enabled' if not disabled else 'Disabled', backend_pools=[ BackendPool( name=backend_pool_name, backends=[ Backend(address=backend_address, http_port=80, https_port=443, priority=1, weight=50, backend_host_header=backend_host_header or backend_address, enabled_state='Enabled') ], health_probe_settings={'id': probe_settings_id}, load_balancing_settings={'id': load_balancing_settings_id}, resource_state='Enabled') ], health_probe_settings=[ HealthProbeSettingsModel(name=probe_setting_name, interval_in_seconds=probe_interval, path=probe_path, protocol=probe_protocol, resource_state='Enabled') ], frontend_endpoints=[ FrontendEndpoint(name=frontend_endpoint_name, host_name=frontend_host_name if frontend_host_name else '{}.azurefd.net'.format(front_door_name), session_affinity_enabled_state='Disabled', resource_state='Enabled') ], load_balancing_settings=[ LoadBalancingSettingsModel(name=load_balancing_settings_name, additional_latency_milliseconds=0, sample_size=4, successful_samples_required=2, resource_state='Enabled') ], routing_rules=[ RoutingRule(name=routing_rule_name, frontend_endpoints=[{ 'id': frontend_endpoint_id }], accepted_protocols=accepted_protocols or ['Http'], patterns_to_match=patterns_to_match or ['/*'], forwarding_protocol=forwarding_protocol, backend_pool={'id': backend_pool_id}, enabled_state='Enabled', resource_state='Enabled') ]) return sdk_no_wait(no_wait, cf_frontdoor(cmd.cli_ctx, None).create_or_update, resource_group_name, front_door_name, front_door)