# 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 or 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 fog_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 fog_application_gateway_service.gateways.check_application_gateway_exists('', '') ``` ## Create Application Gateway Create a new Application Gateway. ```ruby gateway = fog_application_gateway_service.gateways.create( name: '', location: '', resource_group: '', sku_name: '', sku_tier: '', sku_capacity: '', gateway_ip_configurations: [ { name: '', subnet_id: '/subscriptions//resourcegroups//providers/Microsoft.Network/virtualNetworks//subnets/' } ], frontend_ip_configurations: [ { name: '', private_ip_allocation_method: '', public_ip_address_id: '/subscriptions//resourcegroups//providers/Microsoft.Network/publicIPAddresses/', private_ip_address: '' } ], frontend_ports: [ { name: '', port: } ], backend_address_pools: [ { name: '', ip_addresses: [ { ipAddress: '' } ] } ], backend_http_settings_list: [ { name: '', port: , protocol: '', cookie_based_affinity: '', request_timeout: '' } ], http_listeners: [ { name: '', frontend_ip_config_id: '/subscriptions//resourceGroups//providers/Microsoft.Network/applicationGateways//frontendIPConfigurations/', frontend_port_id: '/subscriptions//resourceGroups//providers/Microsoft.Network/applicationGateways//frontendPorts/', protocol: '', host_name: '', require_server_name_indication: '' } ], request_routing_rules: [ { name: '', type: '', http_listener_id: '/subscriptions//resourceGroups//providers/Microsoft.Network/applicationGateways//httpListeners/', backend_address_pool_id: '/subscriptions//resourceGroups//providers/Microsoft.Network/applicationGateways//backendAddressPools/', backend_http_settings_id: '/subscriptions//resourceGroups//providers/Microsoft.Network/applicationGateways//backendHttpSettingsCollection/', url_path_map: '' } ], tags: { key1: 'value1', key2: 'value2', keyN: 'valueN' } # [Optional] ) ``` 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 ```ruby frontend_ip_configurations: [ { name: '', private_ip_allocation_method: '', public_ip_address_id: '/subscriptions//resourcegroups//providers/Microsoft.Network/publicIPAddresses/', private_ip_address: '' } ] 2. When giving subnet id, then we need to provide `subnet_id` as follows ```ruby frontend_ip_configurations: [ { name: '', private_ip_allocation_method: '', subnet_id: '', private_ip_address: '' } ] ## List Application Gateways List all application gateways in a resource group ```ruby gateways = fog_application_gateway_service.gateways(resource_group: '') gateways.each do |gateway| puts "#{gateway.name}" end ``` ## Retrieve a single Application Gateway Get a single record of Application Gateway ```ruby gateway = fog_application_gateway_service .gateways .get('', '') puts "#{gateway.name}" ``` ## Update SKU attributes (Name and Capacity) ```ruby ag.update_sku('', '') ``` ## 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: '', password: '', public_cert_data: '' } ) ag.remove_ssl_certificate( { name: '', data: '', password: '', public_cert_data: '' } ) ``` ## Add/ Remove Frontend ports ```ruby ag.add_frontend_port({name: '', port: }) ag.remove_frontend_port({name: '', port: }) ``` ## Add/ Remove Probes ```ruby ag.add_probe( { name: '', protocol: '', host: '', path: '', interval: , timeout: , unhealthy_threshold: } ) ag.remove__probe( { name: '', protocol: '', host: '', path: '', interval: , timeout: , unhealthy_threshold: } ) ``` ## 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.