public void StartStop()
        {
            using (var context = FluentMockContext.Start(GetType().FullName))
            {
                var    azure  = TestHelper.CreateRollupClient();
                string rgName = SdkContext.RandomResourceName("rg", 13);
                Region region = Region.USEast;
                string name   = SdkContext.RandomResourceName("ag", 15);
                IApplicationGateway appGateway = azure.ApplicationGateways.Define(name)
                                                 .WithRegion(region)
                                                 .WithNewResourceGroup(rgName)

                                                 // Request routing rules
                                                 .DefineRequestRoutingRule("rule1")
                                                 .FromPrivateFrontend()
                                                 .FromFrontendHttpPort(80)
                                                 .ToBackendHttpPort(8080)
                                                 .ToBackendIPAddress("11.1.1.1")
                                                 .ToBackendIPAddress("11.1.1.2")
                                                 .Attach()
                                                 .Create();

                // Test stop/start
                appGateway.Stop();
                Assert.Equal(ApplicationGatewayOperationalState.Stopped, appGateway.OperationalState);
                appGateway.Start();
                Assert.Equal(ApplicationGatewayOperationalState.Running, appGateway.OperationalState);
                azure.ResourceGroups.BeginDeleteByName(rgName);
            }
        }
Example #2
0
 ///GENMHASH:B9A8F99DA807CD48CCF5ADBB6DB5C1C4:6D152F32C433E4139EE4F5562A275A64
 public NicIPConfigurationImpl WithExistingApplicationGatewayBackend(IApplicationGateway appGateway, string backendName)
 {
     if (appGateway != null)
     {
         var pool = appGateway.Inner.BackendAddressPools.FirstOrDefault(o => o.Name.Equals(backendName, StringComparison.OrdinalIgnoreCase));
         if (pool != null)
         {
             EnsureAppGatewayBackendAddressPools().Add(pool);
             return(this);
         }
         else
         {
             throw new InvalidOperationException("Application gateway backend not found.");
         }
     }
     else
     {
         throw new InvalidOperationException("Missing application gateway reference.");
     }
 }
        /**
         * Azure network sample for managing application gateways.
         *
         *  - CREATE an application gateway for load balancing
         *    HTTP/HTTPS requests to backend server pools of virtual machines
         *
         *    This application gateway serves traffic for multiple
         *    domain names
         *
         *    Routing Rule 1
         *    Hostname 1 = None
         *    Backend server pool 1 = 4 virtual machines with IP addresses
         *    Backend server pool 1 settings = HTTP:8080
         *    Front end port 1 = HTTP:80
         *    Listener 1 = HTTP
         *    Routing rule 1 = HTTP listener 1 => backend server pool 1
         *    (round-robin load distribution)
         *
         *    Routing Rule 2
         *    Hostname 2 = None
         *    Backend server pool 2 = 4 virtual machines with IP addresses
         *    Backend server pool 2 settings = HTTP:8080
         *    Front end port 2 = HTTPS:443
         *    Listener 2 = HTTPS
         *    Routing rule 2 = HTTPS listener 2 => backend server pool 2
         *    (round-robin load distribution)
         *
         *  - MODIFY the application gateway - re-configure the Routing Rule 1 for SSL offload and
         *    add a host name, www.Contoso.Com
         *
         *    Change listener 1 from HTTP to HTTPS
         *    Add SSL certificate to the listener
         *    Update front end port 1 to HTTPS:1443
         *    Add a host name, www.Contoso.Com
         *    Enable cookie-based affinity
         *
         *    Modified Routing Rule 1
         *    Hostname 1 = www.Contoso.Com
         *    Backend server pool 1 = 4 virtual machines with IP addresses
         *    Backend server pool 1 settings = HTTP:8080
         *    Front end port 1 = HTTPS:1443
         *    Listener 1 = HTTPS
         *    Routing rule 1 = HTTPS listener 1 => backend server pool 1
         *    (round-robin load distribution)
         *
         */
        public static void RunSample(IAzure azure)
        {
            string rgName  = SdkContext.RandomResourceName("rgNEAG", 15);
            string pipName = SdkContext.RandomResourceName("pip" + "-", 18);

            try
            {
                //=============================================================
                // Create a resource group (Where all resources get created)
                //
                var resourceGroup = azure.ResourceGroups
                                    .Define(rgName)
                                    .WithRegion(Region.USEast)
                                    .Create();

                Utilities.Log("Created a new resource group - " + resourceGroup.Id);

                //=============================================================
                // Create a public IP address for the Application Gateway
                Utilities.Log("Creating a public IP address for the application gateway ...");

                var publicIPAddress = azure.PublicIPAddresses.Define(pipName)
                                      .WithRegion(Region.USEast)
                                      .WithExistingResourceGroup(rgName)
                                      .Create().Refresh();

                Utilities.Log("Created a public IP address");

                // Print the public IP details
                Utilities.PrintIPAddress(publicIPAddress);

                //=============================================================
                // Create backend pools

                // Prepare a batch of Creatable definitions
                var creatableVirtualMachines = new List <ICreatable <IVirtualMachine> >();

                for (var i = 0; i < BackendPools; i++)
                {
                    //=============================================================
                    // Create 1 network creatable per region
                    // Prepare Creatable Network definition (Where all the virtual machines get added to)
                    var networkName = SdkContext.RandomResourceName("vnetNEAG-", 20);

                    var networkCreatable = azure.Networks
                                           .Define(networkName)
                                           .WithRegion(Regions[i])
                                           .WithExistingResourceGroup(resourceGroup)
                                           .WithAddressSpace(AddressSpaces[i]);

                    //=============================================================
                    // Create 1 storage creatable per region (For storing VMs disk)
                    var storageAccountName      = SdkContext.RandomResourceName("stgneag", 20);
                    var storageAccountCreatable = azure.StorageAccounts
                                                  .Define(storageAccountName)
                                                  .WithRegion(Regions[i])
                                                  .WithExistingResourceGroup(resourceGroup);

                    var linuxVMNamePrefix = SdkContext.RandomResourceName("vm-", 15);

                    for (int j = 0; j < VMCountInAPool; j++)
                    {
                        //=============================================================
                        // Create 1 public IP address creatable
                        var publicIPAddressCreatable = azure.PublicIPAddresses
                                                       .Define(string.Format("{0}-{1}", linuxVMNamePrefix, j))
                                                       .WithRegion(Regions[i])
                                                       .WithExistingResourceGroup(resourceGroup)
                                                       .WithLeafDomainLabel(string.Format("{0}-{1}", linuxVMNamePrefix, j));

                        PublicIpCreatableKeys[i, j] = publicIPAddressCreatable.Key;

                        //=============================================================
                        // Create 1 virtual machine creatable
                        var virtualMachineCreatable = azure.VirtualMachines.Define(string.Format("{0}-{1}", linuxVMNamePrefix, j))
                                                      .WithRegion(Regions[i])
                                                      .WithExistingResourceGroup(resourceGroup)
                                                      .WithNewPrimaryNetwork(networkCreatable)
                                                      .WithPrimaryPrivateIPAddressDynamic()
                                                      .WithNewPrimaryPublicIPAddress(publicIPAddressCreatable)
                                                      .WithPopularLinuxImage(KnownLinuxVirtualMachineImage.UbuntuServer16_04_Lts)
                                                      .WithRootUsername(UserName)
                                                      .WithSsh(SshKey)
                                                      .WithSize(VirtualMachineSizeTypes.StandardD3V2)
                                                      .WithNewStorageAccount(storageAccountCreatable);
                        creatableVirtualMachines.Add(virtualMachineCreatable);
                    }
                }


                //=============================================================
                // Create two backend pools of virtual machines

                Stopwatch t = Stopwatch.StartNew();
                Utilities.Log("Creating virtual machines (two backend pools)");

                var virtualMachines = azure.VirtualMachines.Create(creatableVirtualMachines.ToArray());

                t.Stop();
                Utilities.Log("Created virtual machines (two backend pools)");

                foreach (var virtualMachine in virtualMachines)
                {
                    Utilities.Log(virtualMachine.Id);
                }

                Utilities.Log("Virtual machines created: (took " + (t.ElapsedMilliseconds / 1000) + " seconds) to create == " + virtualMachines.Count()
                              + " == virtual machines (4 virtual machines per backend pool)");


                //=======================================================================
                // Get IP addresses from created resources

                Utilities.Log("IP Addresses in the backend pools are - ");
                for (var i = 0; i < BackendPools; i++)
                {
                    for (var j = 0; j < VMCountInAPool; j++)
                    {
                        var pip = (IPublicIPAddress)virtualMachines
                                  .CreatedRelatedResource(PublicIpCreatableKeys[i, j]);
                        pip.Refresh();
                        IPAddresses[i, j] = pip.IPAddress;
                        Utilities.Log("[backend pool ="
                                      + i
                                      + "][vm = "
                                      + j
                                      + "] = "
                                      + IPAddresses[i, j]);
                    }

                    Utilities.Log("======");
                }

                //=======================================================================
                // Create an application gateway

                Utilities.Log("================= CREATE ======================");
                Utilities.Log("Creating an application gateway... (this can take about 20 min)");
                t = Stopwatch.StartNew();

                IApplicationGateway applicationGateway = azure.ApplicationGateways.Define("myFirstAppGateway")
                                                         .WithRegion(Region.USEast)
                                                         .WithExistingResourceGroup(resourceGroup)

                                                         // Request routing rule for HTTP from public 80 to public 8080
                                                         .DefineRequestRoutingRule("HTTP-80-to-8080")
                                                         .FromPublicFrontend()
                                                         .FromFrontendHttpPort(80)
                                                         .ToBackendHttpPort(8080)
                                                         .ToBackendIPAddress(IPAddresses[0, 0])
                                                         .ToBackendIPAddress(IPAddresses[0, 1])
                                                         .ToBackendIPAddress(IPAddresses[0, 2])
                                                         .ToBackendIPAddress(IPAddresses[0, 3])
                                                         .Attach()

                                                         // Request routing rule for HTTPS from public 443 to public 8080
                                                         .DefineRequestRoutingRule("HTTPs-443-to-8080")
                                                         .FromPublicFrontend()
                                                         .FromFrontendHttpsPort(443)
                                                         .WithSslCertificateFromPfxFile(
                    new FileInfo(
                        Utilities.GetCertificatePath(SslCertificatePfxPath)))
                                                         .WithSslCertificatePassword("Abc123")
                                                         .ToBackendHttpPort(8080)
                                                         .ToBackendIPAddress(IPAddresses[1, 0])
                                                         .ToBackendIPAddress(IPAddresses[1, 1])
                                                         .ToBackendIPAddress(IPAddresses[1, 2])
                                                         .ToBackendIPAddress(IPAddresses[1, 3])
                                                         .Attach()
                                                         .WithExistingPublicIPAddress(publicIPAddress)
                                                         .Create();

                t.Stop();

                Utilities.Log("Application gateway created: (took " + (t.ElapsedMilliseconds / 1000) + " seconds)");
                Utilities.PrintAppGateway(applicationGateway);


                //=======================================================================
                // Update an application gateway
                // configure the first routing rule for SSL offload

                Utilities.Log("================= UPDATE ======================");
                Utilities.Log("Updating the application gateway");

                t = Stopwatch.StartNew();

                applicationGateway.Update()
                .WithoutRequestRoutingRule("HTTP-80-to-8080")
                .DefineRequestRoutingRule("HTTPs-1443-to-8080")
                .FromPublicFrontend()
                .FromFrontendHttpsPort(1443)
                .WithSslCertificateFromPfxFile(
                    new FileInfo(
                        Utilities.GetCertificatePath(SslCertificatePfxPath2)))
                .WithSslCertificatePassword("Abc123")
                .ToBackendHttpPort(8080)
                .ToBackendIPAddress(IPAddresses[0, 0])
                .ToBackendIPAddress(IPAddresses[0, 1])
                .ToBackendIPAddress(IPAddresses[0, 2])
                .ToBackendIPAddress(IPAddresses[0, 3])
                .WithHostName("www.contoso.com")
                .WithCookieBasedAffinity()
                .Attach()
                .Apply();

                t.Stop();

                Utilities.Log("Application gateway updated: (took " + (t.ElapsedMilliseconds / 1000) + " seconds)");
                Utilities.PrintAppGateway(applicationGateway);
            }
            finally
            {
                try
                {
                    Utilities.Log("Deleting Resource Group: " + rgName);
                    azure.ResourceGroups.DeleteByName(rgName);
                    Utilities.Log("Deleted Resource Group: " + rgName);
                }
                catch (NullReferenceException)
                {
                    Utilities.Log("Did not create any resources in Azure. No clean up is necessary");
                }
                catch (Exception e)
                {
                    Utilities.Log(e.StackTrace);
                }
            }
        }
        /**
         * Azure network sample for managing application gateways.
         *
         *  - CREATE an application gateway for load balancing
         *    HTTP/HTTPS requests to backend server pools of virtual machines
         *
         *    This application gateway serves traffic for multiple
         *    domain names
         *
         *    Routing Rule 1
         *    Hostname 1 = None
         *    Backend server pool 1 = 4 virtual machines with IP addresses
         *    Backend server pool 1 settings = HTTP:8080
         *    Front end port 1 = HTTP:80
         *    Listener 1 = HTTP
         *    Routing rule 1 = HTTP listener 1 => backend server pool 1
         *    (round-robin load distribution)
         *
         *  - MODIFY the application gateway - re-configure the Routing Rule 1 for SSL offload &
         *    add a host name, www.contoso.com
         *
         *    Change listener 1 from HTTP to HTTPS
         *    Add SSL certificate to the listener
         *    Update front end port 1 to HTTPS:1443
         *    Add a host name, www.contoso.com
         *    Enable cookie-based affinity
         *
         *    Modified Routing Rule 1
         *    Hostname 1 = www.contoso.com
         *    Backend server pool 1 = 4 virtual machines with IP addresses
         *    Backend server pool 1 settings = HTTP:8080
         *    Front end port 1 = HTTPS:1443
         *    Listener 1 = HTTPS
         *    Routing rule 1 = HTTPS listener 1 => backend server pool 1
         *    (round-robin load distribution)
         *
         */
        public static void RunSample(IAzure azure)
        {
            string rgName  = SdkContext.RandomResourceName("rgNEAGS", 15);
            string pipName = SdkContext.RandomResourceName("pip" + "-", 18);

            try
            {
                //=======================================================================
                // Create an application gateway

                Utilities.Log("================= CREATE ======================");
                Utilities.Log("Creating an application gateway... (this can take about 20 min)");
                Stopwatch t = Stopwatch.StartNew();

                IApplicationGateway applicationGateway = azure.ApplicationGateways.Define("myFirstAppGateway")
                                                         .WithRegion(Region.USEast)
                                                         .WithNewResourceGroup(rgName)
                                                         // Request routing rule for HTTP from public 80 to public 8080
                                                         .DefineRequestRoutingRule("HTTP-80-to-8080")
                                                         .FromPublicFrontend()
                                                         .FromFrontendHttpPort(80)
                                                         .ToBackendHttpPort(8080)
                                                         .ToBackendIPAddress("11.1.1.1")
                                                         .ToBackendIPAddress("11.1.1.2")
                                                         .ToBackendIPAddress("11.1.1.3")
                                                         .ToBackendIPAddress("11.1.1.4")
                                                         .Attach()
                                                         .WithNewPublicIPAddress()
                                                         .Create();

                t.Stop();

                Utilities.Log("Application gateway created: (took " + (t.ElapsedMilliseconds / 1000) + " seconds)");
                Utilities.PrintAppGateway(applicationGateway);


                //=======================================================================
                // Update an application gateway
                // configure the first routing rule for SSL offload

                Utilities.Log("================= UPDATE ======================");
                Utilities.Log("Updating the application gateway");

                t = Stopwatch.StartNew();

                applicationGateway.Update()
                .WithoutRequestRoutingRule("HTTP-80-to-8080")
                .DefineRequestRoutingRule("HTTPs-1443-to-8080")
                .FromPublicFrontend()
                .FromFrontendHttpsPort(1443)
                .WithSslCertificateFromPfxFile(
                    new FileInfo(
                        Utilities.GetCertificatePath("NetworkTestCertificate1.pfx")))
                .WithSslCertificatePassword("Abc123")
                .ToBackendHttpPort(8080)
                .ToBackendIPAddress("11.1.1.1")
                .ToBackendIPAddress("11.1.1.2")
                .ToBackendIPAddress("11.1.1.3")
                .ToBackendIPAddress("11.1.1.4")
                .WithHostName("www.contoso.com")
                .WithCookieBasedAffinity()
                .Attach()
                .Apply();

                t.Stop();

                Utilities.Log("Application gateway updated: (took " + (t.ElapsedMilliseconds / 1000) + " seconds)");
                Utilities.PrintAppGateway(applicationGateway);
            }
            finally
            {
                try
                {
                    Utilities.Log("Deleting Resource Group: " + rgName);
                    azure.ResourceGroups.DeleteByName(rgName);
                    Utilities.Log("Deleted Resource Group: " + rgName);
                }
                catch (NullReferenceException)
                {
                    Utilities.Log("Did not create any resources in Azure. No clean up is necessary");
                }
                catch (Exception e)
                {
                    Utilities.Log(e.Message);
                    Utilities.Log(e.StackTrace);
                }
            }
        }
Example #5
0
        public static void PrintAppGateway(IApplicationGateway resource)
        {
            var info = new StringBuilder();

            info.Append("App gateway: ").Append(resource.Id)
            .Append("Name: ").Append(resource.Name)
            .Append("\n\tResource group: ").Append(resource.ResourceGroupName)
            .Append("\n\tRegion: ").Append(resource.Region)
            .Append("\n\tTags: ").Append(resource.Tags.ToString())
            .Append("\n\tSKU: ").Append(resource.Sku.ToString())
            .Append("\n\tOperational state: ").Append(resource.OperationalState)
            .Append("\n\tInternet-facing? ").Append(resource.IsPublic)
            .Append("\n\tInternal? ").Append(resource.IsPrivate)
            .Append("\n\tDefault private IP address: ").Append(resource.PrivateIPAddress)
            .Append("\n\tPrivate IP address allocation method: ").Append(resource.PrivateIPAllocationMethod)
            .Append("\n\tDisabled SSL protocols: ").Append(resource.DisabledSslProtocols);

            // Show IP configs
            var ipConfigs = resource.IPConfigurations;

            info.Append("\n\tIP configurations: ").Append(ipConfigs.Count);
            foreach (var ipConfig in ipConfigs.Values)
            {
                info.Append("\n\t\tName: ").Append(ipConfig.Name)
                .Append("\n\t\t\tNetwork id: ").Append(ipConfig.NetworkId)
                .Append("\n\t\t\tSubnet name: ").Append(ipConfig.SubnetName);
            }

            // Show frontends
            var frontends = resource.Frontends;

            info.Append("\n\tFrontends: ").Append(frontends.Count);
            foreach (var frontend in frontends.Values)
            {
                info.Append("\n\t\tName: ").Append(frontend.Name)
                .Append("\n\t\t\tPublic? ").Append(frontend.IsPublic);

                if (frontend.IsPublic)
                {
                    // Show public frontend info
                    info.Append("\n\t\t\tPublic IP address ID: ").Append(frontend.PublicIPAddressId);
                }

                if (frontend.IsPrivate)
                {
                    // Show private frontend info
                    info.Append("\n\t\t\tPrivate IP address: ").Append(frontend.PrivateIPAddress)
                    .Append("\n\t\t\tPrivate IP allocation method: ").Append(frontend.PrivateIPAllocationMethod)
                    .Append("\n\t\t\tSubnet name: ").Append(frontend.SubnetName)
                    .Append("\n\t\t\tVirtual network ID: ").Append(frontend.NetworkId);
                }
            }

            // Show backends
            var backends = resource.Backends;

            info.Append("\n\tBackends: ").Append(backends.Count);
            foreach (var backend in backends.Values)
            {
                info.Append("\n\t\tName: ").Append(backend.Name)
                .Append("\n\t\t\tAssociated NIC IP configuration IDs: ").Append(string.Join(", ", backend.BackendNicIPConfigurationNames.Keys.ToArray()));

                // Show addresses
                var addresses = backend.Addresses;
                info.Append("\n\t\t\tAddresses: ").Append(addresses.Count);
                foreach (var address in addresses)
                {
                    info.Append("\n\t\t\t\tFQDN: ").Append(address.Fqdn)
                    .Append("\n\t\t\t\tIP: ").Append(address.IpAddress);
                }
            }

            // Show backend HTTP configurations
            var httpConfigs = resource.BackendHttpConfigurations;

            info.Append("\n\tHTTP Configurations: ").Append(httpConfigs.Count);
            foreach (var httpConfig in httpConfigs.Values)
            {
                info.Append("\n\t\tName: ").Append(httpConfig.Name)
                .Append("\n\t\t\tCookie based affinity: ").Append(httpConfig.CookieBasedAffinity)
                .Append("\n\t\t\tPort: ").Append(httpConfig.Port)
                .Append("\n\t\t\tRequest timeout in seconds: ").Append(httpConfig.RequestTimeout)
                .Append("\n\t\t\tProtocol: ").Append(httpConfig.Protocol.ToString())
                .Append("\n\t\tHost header: ").Append(httpConfig.HostHeader)
                .Append("\n\t\tHost header comes from backend? ").Append(httpConfig.IsHostHeaderFromBackend)
                .Append("\n\t\tConnection draining timeout in seconds: ").Append(httpConfig.ConnectionDrainingTimeoutInSeconds)
                .Append("\n\t\tAffinity cookie name: ").Append(httpConfig.AffinityCookieName)
                .Append("\n\t\tPath: ").Append(httpConfig.Path);

                var probe = httpConfig.Probe;
                if (probe != null)
                {
                    info.Append("\n\t\tProbe: " + probe.Name);
                }
            }

            // Show SSL certificates
            var sslCerts = resource.SslCertificates;

            info.Append("\n\tSSL certificates: ").Append(sslCerts.Count);
            foreach (var cert in sslCerts.Values)
            {
                info.Append("\n\t\tName: ").Append(cert.Name)
                .Append("\n\t\t\tCert data: ").Append(cert.PublicData);
            }

            // Show redirect configurations
            var redirects = resource.RedirectConfigurations;

            info.Append("\n\tRedirect configurations: ").Append(redirects.Count);
            foreach (IApplicationGatewayRedirectConfiguration redirect in redirects.Values)
            {
                info.Append("\n\t\tName: ").Append(redirect.Name)
                .Append("\n\t\tTarget URL: ").Append(redirect.Type)
                .Append("\n\t\tTarget URL: ").Append(redirect.TargetUrl)
                .Append("\n\t\tTarget listener: ").Append(redirect.TargetListener?.Name)
                .Append("\n\t\tIs path included? ").Append(redirect.IsPathIncluded)
                .Append("\n\t\tIs query string included? ").Append(redirect.IsQueryStringIncluded)
                .Append("\n\t\tReferencing request routing rules: ").Append(string.Join(", ", redirect.RequestRoutingRules.Keys.ToArray()));
            }

            // Show HTTP listeners
            var listeners = resource.Listeners;

            info.Append("\n\tHTTP listeners: ").Append(listeners.Count);
            foreach (var listener in listeners.Values)
            {
                info.Append("\n\t\tName: ").Append(listener.Name)
                .Append("\n\t\t\tHost name: ").Append(listener.HostName)
                .Append("\n\t\t\tServer name indication required? ").Append(listener.RequiresServerNameIndication)
                .Append("\n\t\t\tAssociated frontend name: ").Append(listener.Frontend.Name)
                .Append("\n\t\t\tFrontend port name: ").Append(listener.FrontendPortName)
                .Append("\n\t\t\tFrontend port number: ").Append(listener.FrontendPortNumber)
                .Append("\n\t\t\tProtocol: ").Append(listener.Protocol.ToString());
                if (listener.SslCertificate != null)
                {
                    info.Append("\n\t\t\tAssociated SSL certificate: ").Append(listener.SslCertificate.Name);
                }
            }

            // Show request routing rules
            var rules = resource.RequestRoutingRules;

            info.Append("\n\tRequest routing rules: ").Append(rules.Count);
            foreach (var rule in rules.Values)
            {
                info.Append("\n\t\tName: ").Append(rule.Name)
                .Append("\n\t\t\tType: ").Append(rule.RuleType.ToString())
                .Append("\n\t\t\tPublic IP address ID: ").Append(rule.PublicIPAddressId)
                .Append("\n\t\t\tHost name: ").Append(rule.HostName)
                .Append("\n\t\t\tServer name indication required? ").Append(rule.RequiresServerNameIndication)
                .Append("\n\t\t\tFrontend port: ").Append(rule.FrontendPort)
                .Append("\n\t\t\tFrontend protocol: ").Append(rule.FrontendProtocol.ToString())
                .Append("\n\t\t\tBackend port: ").Append(rule.BackendPort)
                .Append("\n\t\t\tCookie based affinity enabled? ").Append(rule.CookieBasedAffinity)
                .Append("\n\t\tRedirect configuration: ").Append(rule.RedirectConfiguration?.Name ?? "(none)");

                // Show backend addresses
                var addresses = rule.BackendAddresses;
                info.Append("\n\t\t\tBackend addresses: ").Append(addresses.Count);
                foreach (var address in addresses)
                {
                    info.Append("\n\t\t\t\t")
                    .Append(address.Fqdn)
                    .Append(" [").Append(address.IpAddress).Append("]");
                }


                info
                // Show SSL cert
                .Append("\n\t\t\tSSL certificate name: ").Append(rule.SslCertificate?.Name ?? "(none)")

                // Show backend
                .Append("\n\t\t\tAssociated backend address pool: ").Append(rule.Backend?.Name ?? "(none)")

                // Show backend HTTP settings config
                .Append("\n\t\t\tAssociated backend HTTP settings configuration: ").Append(rule.BackendHttpConfiguration?.Name ?? "(none)")

                // Show frontend listener
                .Append("\n\t\t\tAssociated frontend listener: ").Append(rule.Listener?.Name ?? "(none)");
            }

            // Show probes
            var probes = resource.Probes;

            info.Append("\n\tProbes: ").Append(probes.Count);
            foreach (var probe in probes.Values)
            {
                info.Append("\n\t\tName: ").Append(probe.Name)
                .Append("\n\t\tProtocol:").Append(probe.Protocol.ToString())
                .Append("\n\t\tInterval in seconds: ").Append(probe.TimeBetweenProbesInSeconds)
                .Append("\n\t\tRetries: ").Append(probe.RetriesBeforeUnhealthy)
                .Append("\n\t\tTimeout: ").Append(probe.TimeoutInSeconds)
                .Append("\n\t\tHost: ").Append(probe.Host)
                .Append("\n\t\tHealthy HTTP response status code ranges: ").Append(probe.HealthyHttpResponseStatusCodeRanges)
                .Append("\n\t\tHealthy HTTP response body contents: ").Append(probe.HealthyHttpResponseBodyContents);
            }

            Console.WriteLine(info.ToString());
        }
        public void BackendHealthCheck()
        {
            using (var context = FluentMockContext.Start(GetType().FullName))
            {
                var    testId         = TestUtilities.GenerateName("");
                Region region         = Region.USEast;
                string name           = "ag" + testId;
                var    networkManager = TestHelper.CreateNetworkManager();
                var    computeManager = TestHelper.CreateComputeManager();

                string password = SdkContext.RandomResourceName("Abc.123", 12);
                string vnetName = "net" + testId;
                string rgName   = "rg" + testId;

                // Create a vnet
                INetwork network = networkManager.Networks.Define(vnetName)
                                   .WithRegion(region)
                                   .WithNewResourceGroup(rgName)
                                   .WithAddressSpace("10.0.0.0/28")
                                   .WithSubnet("subnet1", "10.0.0.0/29")
                                   .WithSubnet("subnet2", "10.0.0.8/29")
                                   .Create();

                // Create VMs for the backend in the network to connect to
                List <ICreatable <IVirtualMachine> > vmsDefinitions = new List <ICreatable <IVirtualMachine> >();
                for (int i = 0; i < 2; i++)
                {
                    vmsDefinitions.Add(computeManager.VirtualMachines.Define("vm" + i + testId)
                                       .WithRegion(region)
                                       .WithExistingResourceGroup(rgName)
                                       .WithExistingPrimaryNetwork(network)
                                       .WithSubnet("subnet2")
                                       .WithPrimaryPrivateIPAddressDynamic()
                                       .WithoutPrimaryPublicIPAddress()
                                       .WithPopularLinuxImage(KnownLinuxVirtualMachineImage.UbuntuServer16_04_Lts)
                                       .WithRootUsername("tester")
                                       .WithRootPassword(password));
                }

                var createdVms        = computeManager.VirtualMachines.Create(vmsDefinitions);
                IVirtualMachine[] vms = new IVirtualMachine[createdVms.Count()];
                for (int i = 0; i < vmsDefinitions.Count; i++)
                {
                    vms[i] = createdVms.FirstOrDefault(o => o.Key == vmsDefinitions[i].Key);
                }

                string[] ipAddresses = new string[vms.Count()];
                for (int i = 0; i < vms.Count(); i++)
                {
                    ipAddresses[i] = vms[i].GetPrimaryNetworkInterface().PrimaryPrivateIP;
                }

                // Create the app gateway in the other subnet of the same vnet and point the backend at the VMs
                IApplicationGateway appGateway = networkManager.ApplicationGateways.Define(name)
                                                 .WithRegion(region)
                                                 .WithExistingResourceGroup(rgName)
                                                 .DefineRequestRoutingRule("rule1")
                                                 .FromPrivateFrontend()
                                                 .FromFrontendHttpPort(80)
                                                 .ToBackendHttpPort(8080)
                                                 .ToBackendIPAddresses(ipAddresses) // Connect the VMs via IP addresses
                                                 .Attach()
                                                 .DefineRequestRoutingRule("rule2")
                                                 .FromPrivateFrontend()
                                                 .FromFrontendHttpPort(25)
                                                 .ToBackendHttpPort(22)
                                                 .ToBackend("nicBackend")
                                                 .Attach()
                                                 .WithExistingSubnet(network.Subnets["subnet1"]) // Backend for connecting the VMs via NICs
                                                 .Create();

                // Connect the 1st VM via NIC IP config
                var nic = vms[0].GetPrimaryNetworkInterface();
                Assert.NotNull(nic);
                var appGatewayBackend = appGateway.Backends["nicBackend"];
                Assert.NotNull(appGatewayBackend);
                nic.Update().UpdateIPConfiguration(nic.PrimaryIPConfiguration.Name)
                .WithExistingApplicationGatewayBackend(appGateway, appGatewayBackend.Name)
                .Parent()
                .Apply();

                // Get the health of the VMs
                appGateway.Refresh();
                var backendHealths = appGateway.CheckBackendHealth();

                StringBuilder info = new StringBuilder();
                info.Append("\nApplication gateway backend healths: ").Append(backendHealths.Count);
                foreach (var backendHealth in backendHealths.Values)
                {
                    info.Append("\n\tApplication gateway backend name: ").Append(backendHealth.Name)
                    .Append("\n\t\tHTTP configuration healths: ").Append(backendHealth.HttpConfigurationHealths.Count);
                    Assert.NotNull(backendHealth.Backend);
                    foreach (var backendConfigHealth in backendHealth.HttpConfigurationHealths.Values)
                    {
                        info.Append("\n\t\t\tHTTP configuration name: ").Append(backendConfigHealth.Name)
                        .Append("\n\t\t\tServers: ").Append(backendConfigHealth.Inner.Servers.Count);
                        Assert.NotNull(backendConfigHealth.BackendHttpConfiguration);
                        foreach (var sh in backendConfigHealth.ServerHealths.Values)
                        {
                            var ipConfig = sh.GetNetworkInterfaceIPConfiguration();
                            if (ipConfig != null)
                            {
                                info.Append("\n\t\t\t\tServer NIC ID: ").Append(ipConfig.Parent.Id)
                                .Append("\n\t\t\t\tIP Config name: ").Append(ipConfig.Name);
                            }
                            else
                            {
                                info.Append("\n\t\t\t\tServer IP: " + sh.IPAddress);
                            }
                            info.Append("\n\t\t\t\tHealth status: ").Append(sh.Status.ToString());
                        }
                    }
                }

                TestHelper.WriteLine(info.ToString());

                // Verify app gateway
                Assert.Equal(2, appGateway.Backends.Count);
                var rule1    = appGateway.RequestRoutingRules["rule1"];
                var backend1 = rule1.Backend;
                Assert.NotNull(backend1);
                var rule2    = appGateway.RequestRoutingRules["rule2"];
                var backend2 = rule2.Backend;
                Assert.NotNull(backend2);

                Assert.Equal(2, backendHealths.Count);

                // Verify first backend (IP address-based)
                var backendHealth1 = backendHealths[backend1.Name];
                Assert.NotNull(backendHealth1.Backend);
                for (int i = 0; i < ipAddresses.Length; i++)
                {
                    Assert.True(backend1.ContainsIPAddress(ipAddresses[i]));
                }

                // Verify second backend (NIC based)
                var backendHealth2 = backendHealths[backend2.Name];
                Assert.NotNull(backendHealth2);
                Assert.NotNull(backendHealth2.Backend);
                Assert.Equal(backend2.Name, backendHealth2.Name, true);
                Assert.Single(backendHealth2.HttpConfigurationHealths);
                var httpConfigHealth2 = backendHealth2.HttpConfigurationHealths.Values.FirstOrDefault();
                Assert.NotNull(httpConfigHealth2);
                Assert.NotNull(httpConfigHealth2.BackendHttpConfiguration);
                Assert.Single(httpConfigHealth2.ServerHealths);
                var serverHealth = httpConfigHealth2.ServerHealths.Values.FirstOrDefault();
                Assert.NotNull(serverHealth);
                var ipConfig2 = serverHealth.GetNetworkInterfaceIPConfiguration();
                Assert.Equal(nic.PrimaryIPConfiguration.Name, ipConfig2.Name, true);

                // Cleanup
                networkManager.ResourceManager.ResourceGroups.BeginDeleteByName(rgName);
            }
        }
Example #7
0
        /// <summary>
        /// Gets current load metrics based on the scenario description. Used for simulation during development
        /// </summary>
        /// <returns>The fake concurrent connection count app gw.</returns>
        /// <param name="appGW">App gw.</param>
        /// <param name="azureClient">Azure client.</param>
        /// <param name="secondsIn">Seconds in.</param>
        /// <param name="log">Log.</param>
        public static ConnectionInfo GetFakeConnectionMetrics(IApplicationGateway appGW, IAzure azureClient, int secondsIn, ILogger log)
        {
            ConnectionInfo ret = new ConnectionInfo();

            // try to mimic the load profile we are trying to get to.

            // first section does 5 rps for 90 seconds (0-90)
            // gap of 60 seconds with no load (90-150)
            // 60 second rampup to 150 rps (150-210)
            // 300 seconds at 150 rps (210-510)
            // gap of 60 seconds with no load (510-570)
            // 75 second rampup to 450 rps (570-645)
            // 285 seconds at 450 rps (645-930)
            // gap of 60 seconds with no load (930-990)
            // 360 seconds at 60 (990-1350)

            if (secondsIn <= 90)
            {
                log.LogInformation($"Fake Load Phase 1 {secondsIn} of 90");
                ret.ResponseStatus = 5 * 60;
            }
            else if (secondsIn > 90 && secondsIn <= 150)
            {
                // gap
                log.LogInformation($"Gap after Phase 1 {secondsIn} between 90 and 150");
                ret.ResponseStatus = 0;
            }
            else if (secondsIn > 150 && secondsIn <= 210)
            {
                log.LogInformation($"Phase 2 ramp {secondsIn} between 150 and 210");
                // ramp to 150
                ret.ResponseStatus = Convert.ToInt32((((secondsIn - 150) / 60.0)) * 150) * 60;
            }
            else if (secondsIn > 210 && secondsIn <= 510)
            {
                log.LogInformation($"Phase 2 steady state {secondsIn} between 150 and 210");
                // 150 rps
                ret.ResponseStatus = 150 * 60;
            }
            else if (secondsIn > 510 && secondsIn <= 570)
            {
                log.LogInformation("Gap after Phase 2 {secondsIn} between 150 and 210");
                // gap
                ret.ResponseStatus = 0;
            }
            else if (secondsIn > 570 && secondsIn <= 645)
            {
                log.LogInformation($"Phase 3 ramp {secondsIn} between 570 and 645");
                // ramp to 450
                ret.ResponseStatus = Convert.ToInt32((((secondsIn - 570) / 75.0)) * 450) * 60;
            }
            else if (secondsIn > 645 && secondsIn <= 930)
            {
                log.LogInformation($"Phase 3 steady state {secondsIn} between 645 and 930");
                // 285 at 450 rps
                ret.ResponseStatus = 450 * 60;
            }
            else if (secondsIn > 930 && secondsIn <= 990)
            {
                log.LogInformation($"Cool down {secondsIn} between 930 and 990");
                // gap
                ret.ResponseStatus = 0;
            }
            else if (secondsIn > 990)
            {
                // gap
                ret.ResponseStatus = 0;
            }

            return(ret);
        }
Example #8
0
        /// <summary>
        /// Gets the concurrent connection count app gw.
        /// </summary>
        /// <returns>The concurrent connection count app gw.</returns>
        /// <param name="appGW">App gw.</param>
        /// <param name="azureClient">Azure client.</param>
        /// <param name="log">Log.</param>
        public static ConnectionInfo GetConnectionMetrics(IApplicationGateway appGW, IAzure azureClient, ILogger log)
        {
            try
            {
                Dictionary <string, List <object> > metricsByName = new Dictionary <string, List <object> >();
                ConnectionInfo ret = new ConnectionInfo();


                log.LogInformation("Getting Metric Definitions");
                var      metricDefs     = azureClient.MetricDefinitions.ListByResource(appGW.Id);
                DateTime recordDateTime = DateTime.Now.ToUniversalTime().AddMinutes(1);

                foreach (var metricDef in metricDefs)
                {
                    // Go back, 5 mins and grab most recent value
                    var metricCollection = metricDef.DefineQuery().StartingFrom(recordDateTime.AddMinutes(-6)).EndsBefore(recordDateTime).WithAggregation("Total").Execute();
                    foreach (var metric in metricCollection.Metrics)
                    {
                        foreach (var timeElement in metric.Timeseries)
                        {
                            foreach (var data in timeElement.Data)
                            {
                                if (metric.Name.Inner.LocalizedValue == "Current Connections")
                                {
                                    ret.HistoricalConcurrentConnections.Add(data.Total);
                                    if (data.Total.HasValue)
                                    {
                                        ret.CurrentConnections = Convert.ToInt32(data.Total);
                                    }
                                }
                                if (metric.Name.Inner.LocalizedValue == "Total Requests")
                                {
                                    ret.HistoricalTotalRequests.Add(data.Total);
                                    if (data.Total.HasValue)
                                    {
                                        ret.TotalRequests = Convert.ToInt32(data.Total);
                                    }
                                }
                                if (metric.Name.Inner.LocalizedValue == "Response Status")
                                {
                                    ret.HistoricalResponseStatus.Add(data.Total);
                                    if (data.Total.HasValue)
                                    {
                                        ret.ResponseStatus = Convert.ToInt32(data.Total);
                                    }
                                }
                                if (metricsByName.ContainsKey(metric.Name.Inner.Value))
                                {
                                    metricsByName[metric.Name.Inner.Value].Add(data.Total);
                                }
                                else
                                {
                                    metricsByName[metric.Name.Inner.Value] = new List <object>()
                                    {
                                        data.Total
                                    };
                                }
                            }
                        }
                    }
                }

                //DEBUG LOGGING

                /*Console.WriteLine("Metrics:");
                 * foreach (var x in metricsByName.Keys)
                 * {
                 *  Console.WriteLine($"{x} : {string.Join(",",metricsByName[x])}");
                 * }
                 */
                return(ret);
            }
            catch (Exception e)
            {
                log.LogError(e, "Error Getting metrics: " + e.ToString());
                throw;
            }
        }
Example #9
0
        // Print app gateway info
        public static void PrintAppGateway(IApplicationGateway resource)
        {
            var info = new StringBuilder();

            info.Append("App gateway: ").Append(resource.Id)
            .Append("Name: ").Append(resource.Name)
            .Append("\n\tResource group: ").Append(resource.ResourceGroupName)
            .Append("\n\tRegion: ").Append(resource.Region)
            .Append("\n\tTags: ").Append(resource.Tags.ToString())
            .Append("\n\tSKU: ").Append(resource.Sku.ToString())
            .Append("\n\tOperational state: ").Append(resource.OperationalState)
            .Append("\n\tInternet-facing? ").Append(resource.IsPublic)
            .Append("\n\tInternal? ").Append(resource.IsPrivate)
            .Append("\n\tDefault private IP address: ").Append(resource.PrivateIPAddress)
            .Append("\n\tPrivate IP address allocation method: ").Append(resource.PrivateIPAllocationMethod)
            .Append("\n\tDisabled SSL protocols: ").Append(resource.DisabledSslProtocols);

            // Show IP configs
            var ipConfigs = resource.IPConfigurations;

            info.Append("\n\tIP configurations: ").Append(ipConfigs.Count);
            foreach (var ipConfig in ipConfigs.Values)
            {
                info.Append("\n\t\tName: ").Append(ipConfig.Name)
                .Append("\n\t\t\tNetwork id: ").Append(ipConfig.NetworkId)
                .Append("\n\t\t\tSubnet name: ").Append(ipConfig.SubnetName);
            }

            // Show frontends
            var frontends = resource.Frontends;

            info.Append("\n\tFrontends: ").Append(frontends.Count);
            foreach (var frontend in frontends.Values)
            {
                info.Append("\n\t\tName: ").Append(frontend.Name)
                .Append("\n\t\t\tPublic? ").Append(frontend.IsPublic);

                if (frontend.IsPublic)
                {
                    // Show public frontend info
                    info.Append("\n\t\t\tPublic IP address ID: ").Append(frontend.PublicIPAddressId);
                }

                if (frontend.IsPrivate)
                {
                    // Show private frontend info
                    info.Append("\n\t\t\tPrivate IP address: ").Append(frontend.PrivateIPAddress)
                    .Append("\n\t\t\tPrivate IP allocation method: ").Append(frontend.PrivateIPAllocationMethod)
                    .Append("\n\t\t\tSubnet name: ").Append(frontend.SubnetName)
                    .Append("\n\t\t\tVirtual network ID: ").Append(frontend.NetworkId);
                }
            }

            // Show backends
            var backends = resource.Backends;

            info.Append("\n\tBackends: ").Append(backends.Count);
            foreach (var backend in backends.Values)
            {
                info.Append("\n\t\tName: ").Append(backend.Name)
                .Append("\n\t\t\tAssociated NIC IP configuration IDs: ").Append(backend.BackendNicIPConfigurationNames.Keys.ToString());

                // Show addresses
                var addresses = backend.Addresses;
                info.Append("\n\t\t\tAddresses: ").Append(addresses.Count);
                foreach (var address in addresses)
                {
                    info.Append("\n\t\t\t\tFQDN: ").Append(address.Fqdn)
                    .Append("\n\t\t\t\tIP: ").Append(address.IpAddress);
                }
            }

            // Show backend HTTP configurations
            var httpConfigs = resource.BackendHttpConfigurations;

            info.Append("\n\tHTTP Configurations: ").Append(httpConfigs.Count);
            foreach (var httpConfig in httpConfigs.Values)
            {
                info.Append("\n\t\tName: ").Append(httpConfig.Name)
                .Append("\n\t\t\tCookie based affinity: ").Append(httpConfig.CookieBasedAffinity)
                .Append("\n\t\t\tPort: ").Append(httpConfig.Port)
                .Append("\n\t\t\tRequest timeout in seconds: ").Append(httpConfig.RequestTimeout)
                .Append("\n\t\t\tProtocol: ").Append(httpConfig.Protocol.ToString());
            }

            // Show SSL certificates
            var sslCerts = resource.SslCertificates;

            info.Append("\n\tSSL certificates: ").Append(sslCerts.Count);
            foreach (var cert in sslCerts.Values)
            {
                info.Append("\n\t\tName: ").Append(cert.Name)
                .Append("\n\t\t\tCert data: ").Append(cert.PublicData);
            }

            // Show HTTP listeners
            var listeners = resource.Listeners;

            info.Append("\n\tHTTP listeners: ").Append(listeners.Count);
            foreach (var listener in listeners.Values)
            {
                info.Append("\n\t\tName: ").Append(listener.Name)
                .Append("\n\t\t\tHost name: ").Append(listener.HostName)
                .Append("\n\t\t\tServer name indication required? ").Append(listener.RequiresServerNameIndication)
                .Append("\n\t\t\tAssociated frontend name: ").Append(listener.Frontend.Name)
                .Append("\n\t\t\tFrontend port name: ").Append(listener.FrontendPortName)
                .Append("\n\t\t\tFrontend port number: ").Append(listener.FrontendPortNumber)
                .Append("\n\t\t\tProtocol: ").Append(listener.Protocol.ToString());
                if (listener.SslCertificate != null)
                {
                    info.Append("\n\t\t\tAssociated SSL certificate: ").Append(listener.SslCertificate.Name);
                }
            }

            // Show probes
            var probes = resource.Probes;

            info.Append("\n\tProbes: ").Append(probes.Count);
            foreach (IApplicationGatewayProbe probe in probes.Values)
            {
                info.Append("\n\t\tName: ").Append(probe.Name)
                .Append("\n\t\tProtocol:").Append(probe.Protocol.ToString())
                .Append("\n\t\tInterval in seconds: ").Append(probe.TimeBetweenProbesInSeconds)
                .Append("\n\t\tRetries: ").Append(probe.RetriesBeforeUnhealthy)
                .Append("\n\t\tTimeout: ").Append(probe.TimeoutInSeconds)
                .Append("\n\t\tHost: ").Append(probe.Host);
            }

            // Show request routing rules
            var rules = resource.RequestRoutingRules;

            info.Append("\n\tRequest routing rules: ").Append(rules.Count);
            foreach (var rule in rules.Values)
            {
                info.Append("\n\t\tName: ").Append(rule.Name)
                .Append("\n\t\t\tType: ").Append(rule.RuleType.ToString())
                .Append("\n\t\t\tPublic IP address ID: ").Append(rule.PublicIPAddressId)
                .Append("\n\t\t\tHost name: ").Append(rule.HostName)
                .Append("\n\t\t\tServer name indication required? ").Append(rule.RequiresServerNameIndication)
                .Append("\n\t\t\tFrontend port: ").Append(rule.FrontendPort)
                .Append("\n\t\t\tFrontend protocol: ").Append(rule.FrontendProtocol.ToString())
                .Append("\n\t\t\tBackend port: ").Append(rule.BackendPort)
                .Append("\n\t\t\tCookie based affinity enabled? ").Append(rule.CookieBasedAffinity);

                // Show backend addresses
                var addresses = rule.BackendAddresses;
                info.Append("\n\t\t\tBackend addresses: ").Append(addresses.Count);
                foreach (var address in addresses)
                {
                    info.Append("\n\t\t\t\t")
                    .Append(address.Fqdn)
                    .Append(" [").Append(address.IpAddress).Append("]");
                }

                // Show SSL cert
                info.Append("\n\t\t\tSSL certificate name: ");
                var cert = rule.SslCertificate;
                if (cert == null)
                {
                    info.Append("(None)");
                }
                else
                {
                    info.Append(cert.Name);
                }

                // Show backend
                info.Append("\n\t\t\tAssociated backend address pool: ");
                var backend = rule.Backend;
                if (backend == null)
                {
                    info.Append("(None)");
                }
                else
                {
                    info.Append(backend.Name);
                }

                // Show backend HTTP settings config
                info.Append("\n\t\t\tAssociated backend HTTP settings configuration: ");
                var config = rule.BackendHttpConfiguration;
                if (config == null)
                {
                    info.Append("(None)");
                }
                else
                {
                    info.Append(config.Name);
                }

                // Show frontend listener
                info.Append("\n\t\t\tAssociated frontend listener: ");
                var listener = rule.Listener;
                if (listener == null)
                {
                    info.Append("(None)");
                }
                else
                {
                    info.Append(config.Name);
                }
            }

            TestHelper.WriteLine(info.ToString());
        }
Example #10
0
 /// <summary>
 /// Specifies the application gateway backend to associate this IP configuration with.
 /// </summary>
 /// <param name="appGateway">An existing application gateway.</param>
 /// <param name="backendName">The name of an existing backend on the application gateway.</param>
 /// <return>The next stage of the definition.</return>
 NicIPConfiguration.Definition.IWithAttach <NetworkInterface.Definition.IWithCreate> NicIPConfiguration.Definition.IWithApplicationGatewayBeta <NetworkInterface.Definition.IWithCreate> .WithExistingApplicationGatewayBackend(IApplicationGateway appGateway, string backendName)
 {
     return(this.WithExistingApplicationGatewayBackend(appGateway, backendName) as NicIPConfiguration.Definition.IWithAttach <NetworkInterface.Definition.IWithCreate>);
 }
Example #11
0
 /// <summary>
 /// Specifies the application gateway backend to associate this IP configuration with.
 /// </summary>
 /// <param name="appGateway">An existing application gateway.</param>
 /// <param name="backendName">The name of an existing backend on the application gateway.</param>
 /// <return>The next stage of the update.</return>
 NicIPConfiguration.Update.IUpdate NicIPConfiguration.Update.IWithApplicationGatewayBeta.WithExistingApplicationGatewayBackend(IApplicationGateway appGateway, string backendName)
 {
     return(this.WithExistingApplicationGatewayBackend(appGateway, backendName) as NicIPConfiguration.Update.IUpdate);
 }