Ejemplo n.º 1
0
        public PowerShellAppGwModel.ApplicationGateway GetApplicationGateway(string gatewayName)
        {
            ApplicationGatewayGetResponse parameters = client.ApplicationGateways.Get(gatewayName);

            PowerShellAppGwModel.SubnetCollection subnets = new PowerShellAppGwModel.SubnetCollection();
            foreach (string subnet in parameters.Subnets)
            {
                subnets.Add(subnet);
            }

            PowerShellAppGwModel.VirtualIpCollection VirtualIPs = new PowerShellAppGwModel.VirtualIpCollection();
            foreach (string vip in parameters.VirtualIPs)
            {
                VirtualIPs.Add(vip);
            }

            return(new ApplicationGateway.Model.ApplicationGateway
            {
                Name = parameters.Name,
                Description = parameters.Description,
                GatewaySize = parameters.GatewaySize,
                InstanceCount = parameters.InstanceCount,
                VnetName = parameters.VnetName,
                Subnets = subnets,
                State = parameters.State,
                VirtualIPs = VirtualIPs,
                DnsName = parameters.DnsName
            });
        }
        public void CreateApplicationGateway()
        {
            using (NetworkTestClient networkTestClient = new NetworkTestClient())
            {
                ApplicationGatewayOperationResponse result = new ApplicationGatewayOperationResponse();

                //CREATE gateway
                var createParams = new CreateApplicationGatewayParameters
                {
                    Name        = gatewayName,
                    Description = gatewayDescription,
                    VnetName    = vnet,
                    Subnets     = new List <string>()
                    {
                        subnet
                    }
                };
                result = networkTestClient.ApplicationGateways.CreateApplicationGateway(createParams);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);

                //Verify gateway
                var gateway = new ApplicationGatewayGetResponse();
                gateway = networkTestClient.ApplicationGateways.GetApplicationGateway(gatewayName);
                Assert.Equal(gateway.Name, gatewayName);
                Assert.Equal(gateway.VnetName, vnet);
                Assert.Equal(gateway.Description, gatewayDescription);

                //SET gateway config
                ApplicationGatewaySetConfiguration config = GenerateConfig();
                result = networkTestClient.ApplicationGateways.SetConfigApplicationGateway(gatewayName, config);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);

                //START gateway
                result = networkTestClient.ApplicationGateways.StartApplicationGateway(gatewayName);
                Assert.Equal(result.StatusCode, HttpStatusCode.OK);

                //Verify gateway config
                var getConfig = networkTestClient.ApplicationGateways.GetConfigApplicationGateway(gatewayName);
                VerifyGetApplicationGatewayConfigDetails(config, getConfig);
            }
        }