Inheritance: PSTopLevelResource
        public static void NormalizeChildResourcesId(PSLoadBalancer loadBalancer)
        {
            // Normalize LoadBalancingRules
            if (loadBalancer.LoadBalancingRules != null)
            {
                foreach (var loadBalancingRule in loadBalancer.LoadBalancingRules)
                {
                    loadBalancingRule.Id = string.Empty;

                    if (loadBalancingRule.FrontendIPConfiguration != null)
                    {
                        loadBalancingRule.FrontendIPConfiguration.Id =
                            NormalizeLoadBalancerChildResourceIds(
                                loadBalancingRule.FrontendIPConfiguration.Id,
                                loadBalancer.ResourceGroupName,
                                loadBalancer.Name);
                    }

                    if (loadBalancingRule.BackendAddressPool != null)
                    {
                        loadBalancingRule.BackendAddressPool.Id =
                            NormalizeLoadBalancerChildResourceIds(
                                loadBalancingRule.BackendAddressPool.Id,
                                loadBalancer.ResourceGroupName,
                                loadBalancer.Name);
                    }

                    if (loadBalancingRule.Probe != null)
                    {
                        loadBalancingRule.Probe.Id = 
                            NormalizeLoadBalancerChildResourceIds(
                                loadBalancingRule.Probe.Id,
                                loadBalancer.ResourceGroupName,
                                loadBalancer.Name);
                    }
                }
            }

            // Normalize InboundNatRule
            if (loadBalancer.InboundNatRules != null)
            {
                foreach (var inboundNatRule in loadBalancer.InboundNatRules)
                {
                    inboundNatRule.Id = string.Empty;

                    if (inboundNatRule.FrontendIPConfiguration != null)
                    {
                        inboundNatRule.FrontendIPConfiguration.Id =
                            NormalizeLoadBalancerChildResourceIds(
                                inboundNatRule.FrontendIPConfiguration.Id,
                                loadBalancer.ResourceGroupName,
                                loadBalancer.Name);
                    }
                }
            }

            // Normalize InboundNatPool
            if (loadBalancer.InboundNatPools != null)
            {
                foreach (var inboundNatPool in loadBalancer.InboundNatPools)
                {
                    inboundNatPool.Id = string.Empty;

                    if (inboundNatPool.FrontendIPConfiguration != null)
                    {
                        inboundNatPool.FrontendIPConfiguration.Id =
                            NormalizeLoadBalancerChildResourceIds(
                                inboundNatPool.FrontendIPConfiguration.Id,
                                loadBalancer.ResourceGroupName,
                                loadBalancer.Name);
                    }
                }
            }

            // Normalize FrontendIpconfig
            if (loadBalancer.FrontendIpConfigurations != null)
            {
                foreach (var frontendIpConfig in loadBalancer.FrontendIpConfigurations)
                {
                    frontendIpConfig.Id = string.Empty;
                }
            }

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

            // Normalize BackendAddressPool
            if (loadBalancer.BackendAddressPools != null)
            {
                foreach (var backendAddressPool in loadBalancer.BackendAddressPools)
                {
                    backendAddressPool.Id = string.Empty;
                }
            }
        }
        private PSLoadBalancer CreateLoadBalancer()
        {
            var loadBalancer = new PSLoadBalancer();
            loadBalancer.Name = this.Name;
            loadBalancer.ResourceGroupName = this.ResourceGroupName;
            loadBalancer.Location = this.Location;

            if (this.FrontendIpConfiguration != null)
            {
                loadBalancer.FrontendIpConfigurations = new List<PSFrontendIPConfiguration>();
                loadBalancer.FrontendIpConfigurations = this.FrontendIpConfiguration;
            }

            if (this.BackendAddressPool != null)
            {
                loadBalancer.BackendAddressPools = new List<PSBackendAddressPool>();
                loadBalancer.BackendAddressPools = this.BackendAddressPool;
            }

            if (this.Probe != null)
            {
                loadBalancer.Probes = new List<PSProbe>();
                loadBalancer.Probes = this.Probe;
            }

            if (this.InboundNatRule != null)
            {
                loadBalancer.InboundNatRules = new List<PSInboundNatRule>();
                loadBalancer.InboundNatRules = this.InboundNatRule;
            }

            if (this.LoadBalancingRule != null)
            {
                loadBalancer.LoadBalancingRules = new List<PSLoadBalancingRule>();
                loadBalancer.LoadBalancingRules = this.LoadBalancingRule;
            }

            if (this.InboundNatPool != null)
            {
                loadBalancer.InboundNatPools = new List<PSInboundNatPool>();
                loadBalancer.InboundNatPools = this.InboundNatPool;
            }

            // Normalize the IDs
            ChildResourceHelper.NormalizeChildResourcesId(loadBalancer);

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

            // Execute the Create VirtualNetwork call
            this.LoadBalancerClient.CreateOrUpdate(this.ResourceGroupName, this.Name, lbModel);

            var getLoadBalancer = this.GetLoadBalancer(this.ResourceGroupName, this.Name);

            return getLoadBalancer;
        }
        public static void NormalizeChildResourcesId(PSLoadBalancer loadBalancer, string subscriptionId)
        {
            // Normalize LoadBalancingRules
            if (loadBalancer.LoadBalancingRules != null)
            {
                foreach (var loadBalancingRule in loadBalancer.LoadBalancingRules)
                {
                    loadBalancingRule.Id = GetResourceId(subscriptionId, loadBalancer.ResourceGroupName, loadBalancer.Name, Microsoft.Azure.Commands.Network.Properties.Resources.LoadBalancerRuleName, loadBalancingRule.Name);

                    if (loadBalancingRule.FrontendIPConfiguration != null)
                    {
                        loadBalancingRule.FrontendIPConfiguration.Id =
                            NormalizeLoadBalancerChildResourceIds(
                                loadBalancingRule.FrontendIPConfiguration.Id,
                                loadBalancer.ResourceGroupName,
                                loadBalancer.Name);
                    }

                    if (loadBalancingRule.BackendAddressPool != null)
                    {
                        loadBalancingRule.BackendAddressPool.Id =
                            NormalizeLoadBalancerChildResourceIds(
                                loadBalancingRule.BackendAddressPool.Id,
                                loadBalancer.ResourceGroupName,
                                loadBalancer.Name);
                    }

                    if (loadBalancingRule.Probe != null)
                    {
                        loadBalancingRule.Probe.Id =
                            NormalizeLoadBalancerChildResourceIds(
                                loadBalancingRule.Probe.Id,
                                loadBalancer.ResourceGroupName,
                                loadBalancer.Name);
                    }
                }
            }

            // Normalize InboundNatRule
            if (loadBalancer.InboundNatRules != null)
            {
                foreach (var inboundNatRule in loadBalancer.InboundNatRules)
                {
                    inboundNatRule.Id = GetResourceId(subscriptionId, loadBalancer.ResourceGroupName, loadBalancer.Name, Microsoft.Azure.Commands.Network.Properties.Resources.LoadBalancerInBoundNatRuleName, inboundNatRule.Name);

                    if (inboundNatRule.FrontendIPConfiguration != null)
                    {
                        inboundNatRule.FrontendIPConfiguration.Id =
                            NormalizeLoadBalancerChildResourceIds(
                                inboundNatRule.FrontendIPConfiguration.Id,
                                loadBalancer.ResourceGroupName,
                                loadBalancer.Name);
                    }
                }
            }

            // Normalize InboundNatPool
            if (loadBalancer.InboundNatPools != null)
            {
                foreach (var inboundNatPool in loadBalancer.InboundNatPools)
                {
                    inboundNatPool.Id = GetResourceId(subscriptionId, loadBalancer.ResourceGroupName, loadBalancer.Name, Microsoft.Azure.Commands.Network.Properties.Resources.LoadBalancerInboundNatPoolName, inboundNatPool.Name);

                    if (inboundNatPool.FrontendIPConfiguration != null)
                    {
                        inboundNatPool.FrontendIPConfiguration.Id =
                            NormalizeLoadBalancerChildResourceIds(
                                inboundNatPool.FrontendIPConfiguration.Id,
                                loadBalancer.ResourceGroupName,
                                loadBalancer.Name);
                    }
                }
            }

            // Normalize FrontendIpconfig
            if (loadBalancer.FrontendIpConfigurations != null)
            {
                foreach (var frontendIpConfig in loadBalancer.FrontendIpConfigurations)
                {
                    frontendIpConfig.Id = GetResourceId(subscriptionId, loadBalancer.ResourceGroupName, loadBalancer.Name, Microsoft.Azure.Commands.Network.Properties.Resources.LoadBalancerFrontendIpConfigName, frontendIpConfig.Name);
                }
            }

            // Normalize Probe
            if (loadBalancer.Probes != null)
            {
                foreach (var probe in loadBalancer.Probes)
                {
                    probe.Id = GetResourceId(subscriptionId, loadBalancer.ResourceGroupName, loadBalancer.Name, Microsoft.Azure.Commands.Network.Properties.Resources.LoadBalancerProbeName, probe.Name);
                }
            }

            // Normalize BackendAddressPool
            if (loadBalancer.BackendAddressPools != null)
            {
                foreach (var backendAddressPool in loadBalancer.BackendAddressPools)
                {
                    backendAddressPool.Id = GetResourceId(subscriptionId, loadBalancer.ResourceGroupName, loadBalancer.Name, Microsoft.Azure.Commands.Network.Properties.Resources.LoadBalancerBackendAddressPoolName, backendAddressPool.Name);
                }
            }
        }