예제 #1
0
        internal static FrontendIPConfiguration CreateFrontendIpConfig(
            string froontendPoolName,
            string subscriptionId,
            string subnetId,
            string publicIpAddressId,
            string privateIpAddress,
            IList <string> zones)
        {
            var frontendIpConfig = new FrontendIPConfiguration();

            frontendIpConfig.Name  = froontendPoolName;
            frontendIpConfig.Zones = zones;

            if (!string.IsNullOrEmpty(subnetId))
            {
                frontendIpConfig.Subnet = new Subnet(subnetId);

                if (!string.IsNullOrEmpty(privateIpAddress))
                {
                    frontendIpConfig.PrivateIPAddress          = privateIpAddress;
                    frontendIpConfig.PrivateIPAllocationMethod = LoadBalancerStrategy.Static;
                }
                else
                {
                    frontendIpConfig.PrivateIPAllocationMethod = LoadBalancerStrategy.Dynamic;
                }
            }
            else if (!string.IsNullOrEmpty(publicIpAddressId))
            {
                frontendIpConfig.PublicIPAddress = new PublicIPAddress(publicIpAddressId);
            }

            frontendIpConfig.Id =
                LoadBalancerStrategy.GetResourceNotSetId(
                    subscriptionId,
                    LoadBalancerStrategy.LoadBalancerFrontendIpConfigName,
                    frontendIpConfig.Name);

            return(frontendIpConfig);
        }
        private static ApplicationGatewaySetConfiguration GenerateConfig()
        {
            ApplicationGatewaySetConfiguration config = new ApplicationGatewaySetConfiguration();

            var frontEndIP1 = new FrontendIPConfiguration
            {
                Name = "FrontendIP1",
                Type = "Private"
            };
            var frontEndPort1 = new FrontendPort
            {
                Name = "Port1",
                Port = 80,
            };

            var probe1 = new Probe
            {
                Name               = "Probe1",
                Protocol           = "Http",
                Host               = "127.0.0.1",
                Path               = "/",
                Interval           = 45,
                Timeout            = 25,
                UnhealthyThreshold = 2
            };

            var backendServer1 = new BackendServer
            {
                IPAddress = "10.0.0.1",
            };

            var backendServer2 = new BackendServer
            {
                IPAddress = "10.0.0.2",
            };
            var backendAddressPool1 = new BackendAddressPool
            {
                Name           = "Pool1",
                BackendServers = new List <BackendServer> {
                    backendServer1, backendServer2
                },
            };

            var backendHttpSettings1 = new BackendHttpSettings
            {
                Name                = "Setting1",
                Port                = 80,
                Protocol            = Protocol.Http,
                CookieBasedAffinity = "Enabled",
                RequestTimeout      = 45,
                Probe               = "Probe1"
            };

            var httpListener1 = new AGHttpListener
            {
                Name         = "Listener1",
                FrontendPort = "Port1",
                Protocol     = Protocol.Http,
                FrontendIP   = "FrontendIP1",
                //SslCert = string.Empty,
            };

            var httpLoadBalancingRule1 = new HttpLoadBalancingRule
            {
                Name = "Rule1",
                Type = "Basic",
                BackendHttpSettings = "Setting1",
                Listener            = "Listener1",
                BackendAddressPool  = "Pool1",
            };

            config.FrontendIPConfigurations = new List <FrontendIPConfiguration> {
                frontEndIP1
            };
            config.FrontendPorts = new List <FrontendPort> {
                frontEndPort1
            };
            config.Probes = new List <Probe> {
                probe1
            };
            config.BackendAddressPools = new List <BackendAddressPool> {
                backendAddressPool1
            };
            config.BackendHttpSettingsList = new List <BackendHttpSettings> {
                backendHttpSettings1
            };
            config.HttpListeners = new List <AGHttpListener> {
                httpListener1
            };
            config.HttpLoadBalancingRules = new List <HttpLoadBalancingRule> {
                httpLoadBalancingRule1
            };

            return(config);
        }