# Application Gateway This document explains how to get started using Azure Network Service with Fog to manage Application Gateway. With this gem you can create/update/list/delete Application Gateway. ## Usage First of all, you need to require the Fog library by executing: ```ruby require 'fog/azurerm' ``` ## Create Connection Next, create a connection to the Application Gateway Service: ```ruby azure_application_gateway_service = Fog::ApplicationGateway::AzureRM.new( tenant_id: '', # Tenant id of Azure Active Directory Application client_id: '', # Client id of Azure Active Directory Application client_secret: '', # Client Secret of Azure Active Directory Application subscription_id: '', # Subscription id of an Azure Account :environment => '' # Azure cloud environment. Default is AzureCloud. ) ``` ## Check Application Gateway Existence ```ruby azure_application_gateway_service.gateways.check_application_gateway_exists(, ) ``` ## Create Application Gateway Create a new Application Gateway. ```ruby gateway = azure_application_gateway_service.gateways.create( name: '', location: 'eastus', resource_group: '', sku_name: 'Standard_Medium', sku_tier: 'Standard', sku_capacity: '2', gateway_ip_configurations: [ { name: 'gatewayIpConfigName', subnet_id: '/subscriptions//resourcegroups//providers/Microsoft.Network/virtualNetworks//subnets/' } ], frontend_ip_configurations: [ { name: 'frontendIpConfig', private_ip_allocation_method: 'Dynamic', public_ip_address_id: '/subscriptions//resourcegroups//providers/Microsoft.Network/publicIPAddresses/', private_ip_address: '10.0.1.5' } ], frontend_ports: [ { name: 'frontendPort', port: 443 } ], backend_address_pools: [ { name: 'backendAddressPool', ip_addresses: [ { ipAddress: '10.0.1.6' } ] } ], backend_http_settings_list: [ { name: 'gateway_settings', port: 80, protocol: 'Http', cookie_based_affinity: 'Enabled', request_timeout: '30' } ], http_listeners: [ { name: 'gateway_listener', frontend_ip_config_id: '/subscriptions//resourceGroups//providers/Microsoft.Network/applicationGateways//frontendIPConfigurations/frontendIpConfig', frontend_port_id: '/subscriptions//resourceGroups//providers/Microsoft.Network/applicationGateways//frontendPorts/frontendPort', protocol: 'Http', host_name: '', require_server_name_indication: 'false' } ], request_routing_rules: [ { name: 'gateway_request_route_rule', type: 'Basic', http_listener_id: '/subscriptions//resourceGroups//providers/Microsoft.Network/applicationGateways//httpListeners/gateway_listener', backend_address_pool_id: '/subscriptions//resourceGroups//providers/Microsoft.Network/applicationGateways//backendAddressPools/backendAddressPool', backend_http_settings_id: '/subscriptions//resourceGroups//providers/Microsoft.Network/applicationGateways//backendHttpSettingsCollection/gateway_settings', url_path_map: '' } ] ) ``` There can be two ways of giving `frontend_ip_configurations` while creating application gateway 1. When giving public ip, then we need to provide `public_ip_address_id` as follows `frontend_ip_configurations: [ { name: 'frontendIpConfig', private_ip_allocation_method: 'Dynamic', public_ip_address_id: '/subscriptions//resourcegroups//providers/Microsoft.Network/publicIPAddresses/', private_ip_address: '10.0.1.5' } ]` 2. When giving subnet id, then we need to provide `subnet_id` as follows `frontend_ip_configurations: [ { name: 'frontendIpConfig', private_ip_allocation_method: 'Dynamic', subnet_id: '') gateways.each do |gateway| puts "#{gateway.name}" end ``` ## Retrieve a single Application Gateway Get a single record of Application Gateway ```ruby gateway = azure_application_gateway_service .gateways .get('', '') puts "#{gateway.name}" ``` ## Update sku attributes (Name and Capacity) ```ruby ag.update_sku('Standard_Small', '1') ``` ## Update gateway ip configuration (Subnet id) ```ruby ag.update_gateway_ip_configuration("/subscriptions////providers/Microsoft.Network/virtualNetworks//subnets/") ``` ## Add/Remove SSL Certificates ```ruby ag.add_ssl_certificate( { name: '', data: 'Base-64 encoded pfx certificate', password: 'azure', public_cert_data: 'Base-64 encoded Public cert data corresponding to pfx specified in data.' } ) ag.remove_ssl_certificate( { name: '', data: 'Base-64 encoded pfx certificate', password: 'azure', public_cert_data: 'Base-64 encoded Public cert data corresponding to pfx specified in data.' } ) ``` ## Add/Remove Frontend ports ```ruby ag.add_frontend_port({name: '', port: 80}) ag.remove_frontend_port({name: '', port: 80}) ``` ## Add/Remove Probes ```ruby ag.add_probe( { name: '', protocol: 'http', host: 'localhost', path: '/fog-test', interval: 60, timeout: 300, unhealthy_threshold: 5 } ) ag.remove__probe( { name: '', protocol: 'http', host: 'localhost', path: '/fog-test', interval: 60, timeout: 300, unhealthy_threshold: 5 } ) ``` ## Destroy a single Application Gateway Get a application gateway object from the get method and then destroy that application gateway. ```ruby gateway.destroy ``` ## Support and Feedback Your feedback is highly appreciated! If you have specific issues with the fog ARM, you should file an issue via Github.