Inheritance: PSTopLevelResource
        private PSApplicationGateway CreateApplicationGateway()
        {
            var applicationGateway = new PSApplicationGateway();
            applicationGateway.Name = this.Name;
            applicationGateway.ResourceGroupName = this.ResourceGroupName;
            applicationGateway.Location = this.Location;
            applicationGateway.Sku = this.Sku;

            if (this.SslPolicy != null)
            {
                applicationGateway.SslPolicy = new PSApplicationGatewaySslPolicy();
                applicationGateway.SslPolicy = this.SslPolicy;
            }

            if (this.GatewayIPConfigurations != null)
            {
                applicationGateway.GatewayIPConfigurations = this.GatewayIPConfigurations;
            }

            if (this.SslCertificates != null)
            {
                applicationGateway.SslCertificates = this.SslCertificates;
            }

            if (this.AuthenticationCertificates != null)
            {
                applicationGateway.AuthenticationCertificates = this.AuthenticationCertificates;
            }

            if (this.FrontendIPConfigurations != null)
            {
                applicationGateway.FrontendIPConfigurations = this.FrontendIPConfigurations;
            }

            if (this.FrontendPorts != null)
            {
                applicationGateway.FrontendPorts = this.FrontendPorts;
            }

            if (this.Probes != null)
            {
                applicationGateway.Probes = this.Probes;
            }

            if (this.BackendAddressPools != null)
            {
                applicationGateway.BackendAddressPools = this.BackendAddressPools;
            }

            if (this.BackendHttpSettingsCollection != null)
            {
                applicationGateway.BackendHttpSettingsCollection = this.BackendHttpSettingsCollection;
            }

            if (this.HttpListeners != null)
            {
                applicationGateway.HttpListeners = this.HttpListeners;
            }

            if (this.UrlPathMaps != null)
            {
                applicationGateway.UrlPathMaps = this.UrlPathMaps;
            }

            if (this.RequestRoutingRules != null)
            {
                applicationGateway.RequestRoutingRules = this.RequestRoutingRules;
            }

            if (this.WebApplicationFirewallConfiguration != null)
            {
                applicationGateway.WebApplicationFirewallConfiguration = this.WebApplicationFirewallConfiguration;
            }

            // Normalize the IDs
            ApplicationGatewayChildResourceHelper.NormalizeChildResourcesId(applicationGateway);

            // Map to the sdk object
            var appGwModel = Mapper.Map<MNM.ApplicationGateway>(applicationGateway);
            appGwModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);

            // Execute the Create ApplicationGateway call
            this.ApplicationGatewayClient.CreateOrUpdate(this.ResourceGroupName, this.Name, appGwModel);

            var getApplicationGateway = this.GetApplicationGateway(this.ResourceGroupName, this.Name);

            return getApplicationGateway;
        }
        public static void NormalizeChildResourcesId(PSApplicationGateway applicationGateway)
        {
            // Normalize GatewayIpConfiguration
            if (applicationGateway.GatewayIPConfigurations != null)
            {
                foreach (var gatewayIpConfig in applicationGateway.GatewayIPConfigurations)
                {
                    gatewayIpConfig.Id = string.Empty;                    
                }
            }

            // Normalize SslCertificates
            if (applicationGateway.SslCertificates != null)
            {
                foreach (var sslCertificate in applicationGateway.SslCertificates)
                {
                    sslCertificate.Id = string.Empty;
                }
            }

            // Normalize FrontendIpConfiguration
            if (applicationGateway.FrontendIPConfigurations != null)
            {
                foreach (var frontendIpConfiguration in applicationGateway.FrontendIPConfigurations)
                {
                    frontendIpConfiguration.Id = string.Empty;                    
                }
            }

            // Normalize FrontendPort
            if (applicationGateway.FrontendPorts != null)
            {
                foreach (var frontendPort in applicationGateway.FrontendPorts)
                {
                    frontendPort.Id = string.Empty;
                }
            }

            // Normalize BackendAddressPool
            if (applicationGateway.BackendAddressPools != null)
            {
                foreach (var backendAddressPool in applicationGateway.BackendAddressPools)
                {
                    backendAddressPool.Id = string.Empty;
                }
            }

            // Normalize Probe
            if (applicationGateway.Probes != null)
            {
                foreach (var probe in applicationGateway.Probes)
                {
                    probe.Id = string.Empty;
                }
            }

            // Normalize BackendHttpSettings
            if (applicationGateway.BackendHttpSettingsCollection != null)
            {
                foreach (var backendHttpSettings in applicationGateway.BackendHttpSettingsCollection)
                {
                    backendHttpSettings.Id = string.Empty;

                    if (null != backendHttpSettings.Probe)
                    {
                        backendHttpSettings.Probe.Id = NormalizeApplicationGatewayNameChildResourceIds(
                                                    backendHttpSettings.Probe.Id,
                                                    applicationGateway.ResourceGroupName,
                                                    applicationGateway.Name);
                    }
                }
            }

            // Normalize HttpListener
            if (applicationGateway.HttpListeners != null)
            {
                foreach (var httpListener in applicationGateway.HttpListeners)
                {
                    httpListener.Id = string.Empty;

                    httpListener.FrontendPort.Id = NormalizeApplicationGatewayNameChildResourceIds(
                                                httpListener.FrontendPort.Id,
                                                applicationGateway.ResourceGroupName,
                                                applicationGateway.Name);

                    if (null != httpListener.FrontendIpConfiguration)
                    {
                        httpListener.FrontendIpConfiguration.Id = NormalizeApplicationGatewayNameChildResourceIds(
                                                                        httpListener.FrontendIpConfiguration.Id,
                                                                        applicationGateway.ResourceGroupName,
                                                                        applicationGateway.Name);
                    }

                    if (null != httpListener.SslCertificate)
                    { 
                        httpListener.SslCertificate.Id = NormalizeApplicationGatewayNameChildResourceIds(
                                                                        httpListener.SslCertificate.Id,
                                                                        applicationGateway.ResourceGroupName,
                                                                        applicationGateway.Name);
                    }
                }
            }

            // Normalize UrlPathMap
            if (applicationGateway.UrlPathMaps != null)
            {
                foreach (var urlPathMap in applicationGateway.UrlPathMaps)
                {
                    urlPathMap.Id = string.Empty;

                    urlPathMap.DefaultBackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
                                                    urlPathMap.DefaultBackendAddressPool.Id,
                                                    applicationGateway.ResourceGroupName,
                                                    applicationGateway.Name);

                    urlPathMap.DefaultBackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
                                                    urlPathMap.DefaultBackendHttpSettings.Id,
                                                    applicationGateway.ResourceGroupName,
                                                    applicationGateway.Name);

                    foreach (var pathRule in urlPathMap.PathRules)
                    {
                        pathRule.BackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
                                      pathRule.BackendAddressPool.Id,
                                      applicationGateway.ResourceGroupName,
                                      applicationGateway.Name);

                        pathRule.BackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
                                                        pathRule.BackendHttpSettings.Id,
                                                        applicationGateway.ResourceGroupName,
                                                        applicationGateway.Name);
                    }
                }
            }

            // Normalize RequestRoutingRule
            if (applicationGateway.RequestRoutingRules != null)
            {
                foreach (var requestRoutingRule in applicationGateway.RequestRoutingRules)
                {
                    requestRoutingRule.Id = string.Empty;

                    requestRoutingRule.HttpListener.Id = NormalizeApplicationGatewayNameChildResourceIds(
                                                                    requestRoutingRule.HttpListener.Id,
                                                                    applicationGateway.ResourceGroupName,
                                                                    applicationGateway.Name);

                    if (null != requestRoutingRule.BackendAddressPool)
                    {
                        requestRoutingRule.BackendAddressPool.Id = NormalizeApplicationGatewayNameChildResourceIds(
                                                                        requestRoutingRule.BackendAddressPool.Id,
                                                                        applicationGateway.ResourceGroupName,
                                                                        applicationGateway.Name);
                    }

                    if (null != requestRoutingRule.BackendHttpSettings)
                    {
                        requestRoutingRule.BackendHttpSettings.Id = NormalizeApplicationGatewayNameChildResourceIds(
                                                                    requestRoutingRule.BackendHttpSettings.Id,
                                                                    applicationGateway.ResourceGroupName,
                                                                    applicationGateway.Name);
                    }

                    if (null != requestRoutingRule.UrlPathMap)
                    {
                        requestRoutingRule.UrlPathMap.Id = NormalizeApplicationGatewayNameChildResourceIds(
                                                                    requestRoutingRule.UrlPathMap.Id,
                                                                    applicationGateway.ResourceGroupName,
                                                                    applicationGateway.Name);
                    }
                }
            }
        }
        private PSApplicationGateway CreateApplicationGateway()
        {
            var applicationGateway = new PSApplicationGateway();
            applicationGateway.Name = this.Name;
            applicationGateway.ResourceGroupName = this.ResourceGroupName;
            applicationGateway.Location = this.Location;            
            applicationGateway.Sku = this.Sku;

            if (this.GatewayIPConfigurations != null)
            {
                applicationGateway.GatewayIPConfigurations = new List<PSApplicationGatewayIPConfiguration>();
                applicationGateway.GatewayIPConfigurations = this.GatewayIPConfigurations;
            }

            if (this.SslCertificates != null)
            {
                applicationGateway.SslCertificates = new List<PSApplicationGatewaySslCertificate>();
                applicationGateway.SslCertificates = this.SslCertificates;
            }

            if (this.FrontendIPConfigurations != null)
            {
                applicationGateway.FrontendIPConfigurations = new List<PSApplicationGatewayFrontendIPConfiguration>();
                applicationGateway.FrontendIPConfigurations = this.FrontendIPConfigurations;
            }

            if (this.FrontendPorts != null)
            {
                applicationGateway.FrontendPorts = new List<PSApplicationGatewayFrontendPort>();
                applicationGateway.FrontendPorts = this.FrontendPorts;
            }

            if (this.BackendAddressPools != null)
            {
                applicationGateway.BackendAddressPools = new List<PSApplicationGatewayBackendAddressPool>();
                applicationGateway.BackendAddressPools = this.BackendAddressPools;
            }

            if (this.BackendHttpSettingsCollection != null)
            {
                applicationGateway.BackendHttpSettingsCollection = new List<PSApplicationGatewayBackendHttpSettings>();
                applicationGateway.BackendHttpSettingsCollection = this.BackendHttpSettingsCollection;
            }

            if (this.HttpListeners != null)
            {
                applicationGateway.HttpListeners = new List<PSApplicationGatewayHttpListener>();
                applicationGateway.HttpListeners = this.HttpListeners;
            }

            if (this.RequestRoutingRules != null)
            {
                applicationGateway.RequestRoutingRules = new List<PSApplicationGatewayRequestRoutingRule>();
                applicationGateway.RequestRoutingRules = this.RequestRoutingRules;
            }

            // Normalize the IDs
            ApplicationGatewayChildResourceHelper.NormalizeChildResourcesId(applicationGateway);

            // Map to the sdk object
            var appGwModel = Mapper.Map<MNM.ApplicationGateway>(applicationGateway);
            appGwModel.Type = Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayType;
            appGwModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);

            // Execute the Create ApplicationGateway call
            this.ApplicationGatewayClient.CreateOrUpdate(this.ResourceGroupName, this.Name, appGwModel);

            var getApplicationGateway = this.GetApplicationGateway(this.ResourceGroupName, this.Name);

            return getApplicationGateway;
        }