Ejemplo n.º 1
0
        public PowerShellAppGwModel.ApplicationGatewayConfigContext GetApplicationGatewayConfig(string gatewayName)
        {
            ApplicationGatewayGetConfiguration hydraConfig = client.ApplicationGateways.GetConfig(gatewayName);

            PowerShellAppGwModel.ApplicationGatewayConfiguration psConfig = PowerShellConfigFromHydraConfig(hydraConfig);

            return(new PowerShellAppGwModel.ApplicationGatewayConfigContext
            {
                OperationDescription = "Get-ApplicationGatewayConfig",
                OperationId = hydraConfig.RequestId,
                OperationStatus = hydraConfig.StatusCode.ToString(),
                Config = psConfig,
                XMLConfiguration = PowerShellAppGwModel.ApplicationGatewayConfiguration.Print(psConfig)
            });
        }
Ejemplo n.º 2
0
        private PowerShellAppGwModel.ApplicationGatewayConfiguration PowerShellConfigFromHydraConfig(ApplicationGatewayGetConfiguration config)
        {
            PowerShellAppGwModel.ApplicationGatewayConfiguration outConfig = new PowerShellAppGwModel.ApplicationGatewayConfiguration();

            //Frontend IPs
            List <PowerShellAppGwModel.FrontendIPConfiguration> fips = new List <PowerShellAppGwModel.FrontendIPConfiguration>();

            //Config without Frontend IPs is also valid
            if (null != config.FrontendIPConfigurations)
            {
                foreach (FrontendIPConfiguration fip in config.FrontendIPConfigurations)
                {
                    fips.Add(new PowerShellAppGwModel.FrontendIPConfiguration
                    {
                        Name            = fip.Name,
                        Type            = fip.Type,
                        StaticIPAddress = fip.StaticIPAddress
                    });
                }
            }

            //Frontend Port
            List <PowerShellAppGwModel.FrontendPort> fps = new List <PowerShellAppGwModel.FrontendPort>();

            foreach (FrontendPort fp in config.FrontendPorts)
            {
                fps.Add(new PowerShellAppGwModel.FrontendPort
                {
                    Name = fp.Name,
                    Port = fp.Port
                });
            }

            //Backend Address Pools
            List <PowerShellAppGwModel.BackendAddressPool> pools = new List <PowerShellAppGwModel.BackendAddressPool>();

            foreach (BackendAddressPool pool in config.BackendAddressPools)
            {
                PowerShellAppGwModel.BackendServerCollection servers = new PowerShellAppGwModel.BackendServerCollection();
                foreach (BackendServer server in pool.BackendServers)
                {
                    servers.Add(server.IPAddress);
                }

                pools.Add(new PowerShellAppGwModel.BackendAddressPool
                {
                    Name           = pool.Name,
                    BackendServers = servers
                });
            }

            //Backend Http Settings List
            List <PowerShellAppGwModel.BackendHttpSettings> settings = new List <PowerShellAppGwModel.BackendHttpSettings>();

            foreach (BackendHttpSettings setting in config.BackendHttpSettingsList)
            {
                settings.Add(new PowerShellAppGwModel.BackendHttpSettings
                {
                    Name                = setting.Name,
                    Port                = setting.Port,
                    Protocol            = (PowerShellAppGwModel.Protocol)setting.Protocol,
                    CookieBasedAffinity = setting.CookieBasedAffinity
                });
            }

            //Http Listeners
            List <PowerShellAppGwModel.HttpListener> listeners = new List <PowerShellAppGwModel.HttpListener>();

            foreach (AGHttpListener listener in config.HttpListeners)
            {
                listeners.Add(new PowerShellAppGwModel.HttpListener
                {
                    Name         = listener.Name,
                    FrontendIP   = listener.FrontendIP,
                    FrontendPort = listener.FrontendPort,
                    Protocol     = (PowerShellAppGwModel.Protocol)listener.Protocol,
                    SslCert      = listener.SslCert
                });
            }

            //Http Load Balancing Rules
            List <PowerShellAppGwModel.HttpLoadBalancingRule> rules = new List <PowerShellAppGwModel.HttpLoadBalancingRule>();

            foreach (HttpLoadBalancingRule rule in config.HttpLoadBalancingRules)
            {
                rules.Add(new PowerShellAppGwModel.HttpLoadBalancingRule
                {
                    Name = rule.Name,
                    Type = rule.Type,
                    BackendHttpSettings = rule.BackendHttpSettings,
                    Listener            = rule.Listener,
                    BackendAddressPool  = rule.BackendAddressPool
                });
            }

            outConfig.FrontendIPConfigurations = fips;
            outConfig.FrontendPorts            = fps;
            outConfig.BackendAddressPools      = pools;
            outConfig.BackendHttpSettingsList  = settings;
            outConfig.HttpListeners            = listeners;
            outConfig.HttpLoadBalancingRules   = rules;

            return(outConfig);
        }
Ejemplo n.º 3
0
        private ApplicationGatewaySetConfiguration HydraConfigFromPowerShellConfig(PowerShellAppGwModel.ApplicationGatewayConfiguration config)
        {
            ApplicationGatewaySetConfiguration outConfig = new ApplicationGatewaySetConfiguration();

            //Frontend IPs
            outConfig.FrontendIPConfigurations = new List <FrontendIPConfiguration>();

            //Config without Frontend IPs is also valid
            if (null != config.FrontendIPConfigurations)
            {
                foreach (PowerShellAppGwModel.FrontendIPConfiguration fip in config.FrontendIPConfigurations)
                {
                    outConfig.FrontendIPConfigurations.Add(new FrontendIPConfiguration
                    {
                        Name            = fip.Name,
                        Type            = fip.Type,
                        StaticIPAddress = fip.StaticIPAddress
                    });
                }
            }

            //Frontend Port
            outConfig.FrontendPorts = new List <FrontendPort>();
            foreach (PowerShellAppGwModel.FrontendPort fp in config.FrontendPorts)
            {
                outConfig.FrontendPorts.Add(new FrontendPort
                {
                    Name = fp.Name,
                    Port = fp.Port
                });
            }

            //Backend Address Pools
            outConfig.BackendAddressPools = new List <BackendAddressPool>();
            foreach (PowerShellAppGwModel.BackendAddressPool pool in config.BackendAddressPools)
            {
                List <BackendServer> servers = new List <BackendServer>();
                foreach (string server in pool.BackendServers)
                {
                    servers.Add(new BackendServer
                    {
                        IPAddress = server
                    });
                }

                outConfig.BackendAddressPools.Add(new BackendAddressPool
                {
                    Name           = pool.Name,
                    BackendServers = servers
                });
            }

            //Backend Http Settings List
            outConfig.BackendHttpSettingsList = new List <BackendHttpSettings>();
            foreach (PowerShellAppGwModel.BackendHttpSettings setting in config.BackendHttpSettingsList)
            {
                outConfig.BackendHttpSettingsList.Add(new BackendHttpSettings
                {
                    Name                = setting.Name,
                    Port                = setting.Port,
                    Protocol            = (Protocol)setting.Protocol,
                    CookieBasedAffinity = setting.CookieBasedAffinity
                });
            }

            //Http Listeners
            outConfig.HttpListeners = new List <AGHttpListener>();
            foreach (PowerShellAppGwModel.HttpListener listener in config.HttpListeners)
            {
                outConfig.HttpListeners.Add(new AGHttpListener
                {
                    Name         = listener.Name,
                    FrontendIP   = listener.FrontendIP,
                    FrontendPort = listener.FrontendPort,
                    Protocol     = (Protocol)listener.Protocol,
                    SslCert      = listener.SslCert
                });
            }

            //Http Load Balancing Rules
            outConfig.HttpLoadBalancingRules = new List <HttpLoadBalancingRule>();
            foreach (PowerShellAppGwModel.HttpLoadBalancingRule rule in config.HttpLoadBalancingRules)
            {
                outConfig.HttpLoadBalancingRules.Add(new HttpLoadBalancingRule
                {
                    Name = rule.Name,
                    Type = rule.Type,
                    BackendHttpSettings = rule.BackendHttpSettings,
                    Listener            = rule.Listener,
                    BackendAddressPool  = rule.BackendAddressPool
                });
            }

            return(outConfig);
        }
Ejemplo n.º 4
0
 public ApplicationGatewayOperationResponse SetApplicationGatewayConfig(string gatewayName, PowerShellAppGwModel.ApplicationGatewayConfiguration config)
 {
     return(client.ApplicationGateways.SetConfig(gatewayName, HydraConfigFromPowerShellConfig(config)));
 }