Inheritance: PSTopLevelResource
        private PSPublicIpAddress CreatePublicIpAddress()
        {
            var publicIp = new PSPublicIpAddress();
            publicIp.Name = this.Name;
            publicIp.Location = this.Location;
            publicIp.PublicIpAllocationMethod = this.AllocationMethod;
            publicIp.PublicIpAddressVersion = this.IpAddressVersion;

            if (this.IdleTimeoutInMinutes > 0)
            {
                publicIp.IdleTimeoutInMinutes = this.IdleTimeoutInMinutes;
            }

            if (!string.IsNullOrEmpty(this.DomainNameLabel))
            {
                publicIp.DnsSettings = new PSPublicIpAddressDnsSettings();
                publicIp.DnsSettings.DomainNameLabel = this.DomainNameLabel;
                publicIp.DnsSettings.ReverseFqdn = this.ReverseFqdn;
            }

            var publicIpModel = Mapper.Map<MNM.PublicIPAddress>(publicIp);

            publicIpModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true);

            this.PublicIpAddressClient.CreateOrUpdate(this.ResourceGroupName, this.Name, publicIpModel);

            var getPublicIp = this.GetPublicIpAddress(this.ResourceGroupName, this.Name);

            return getPublicIp;
        }
        public void Allocate(PSVirtualNetwork virtualNetwork, PSPublicIpAddress[] publicIpAddresses, PSPublicIpAddress ManagementPublicIpAddress = null)
        {
            if (virtualNetwork == null)
            {
                throw new ArgumentNullException(nameof(virtualNetwork), "Virtual Network cannot be null!");
            }

            if (publicIpAddresses == null || publicIpAddresses.Count() == 0)
            {
                throw new ArgumentNullException(nameof(publicIpAddresses), "Public IP Addresses cannot be null or empty!");
            }

            PSSubnet firewallSubnet = null;

            try
            {
                firewallSubnet = virtualNetwork.Subnets.Single(subnet => AzureFirewallSubnetName.Equals(subnet.Name));
            }
            catch (InvalidOperationException)
            {
                throw new ArgumentException($"Virtual Network {virtualNetwork.Name} should contain a Subnet named {AzureFirewallSubnetName}");
            }

            PSSubnet firewallMgmtSubnet = null;

            if (ManagementPublicIpAddress != null)
            {
                try
                {
                    firewallMgmtSubnet = virtualNetwork.Subnets.Single(subnet => AzureFirewallMgmtSubnetName.Equals(subnet.Name));
                }
                catch (InvalidOperationException)
                {
                    throw new ArgumentException($"Virtual Network {virtualNetwork.Name} should contain a Subnet named {AzureFirewallMgmtSubnetName}");
                }

                this.ManagementIpConfiguration = new PSAzureFirewallIpConfiguration
                {
                    Name            = AzureFirewallMgmtIpConfigurationName,
                    PublicIpAddress = new PSResourceId {
                        Id = ManagementPublicIpAddress.Id
                    },
                    Subnet = new PSResourceId {
                        Id = firewallMgmtSubnet.Id
                    }
                };
            }

            this.IpConfigurations = new List <PSAzureFirewallIpConfiguration>();

            for (var i = 0; i < publicIpAddresses.Count(); i++)
            {
                this.IpConfigurations.Add(
                    new PSAzureFirewallIpConfiguration
                {
                    Name            = $"{AzureFirewallIpConfigurationName}{i}",
                    PublicIpAddress = new PSResourceId {
                        Id = publicIpAddresses[i].Id
                    }
                });
            }

            this.IpConfigurations[0].Subnet = new PSResourceId {
                Id = firewallSubnet.Id
            };
        }