Inheritance: PSChildResource
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var peering = new PSPeering();

            peering.Name = this.Name;
            peering.PeeringType = this.PeeringType;
            peering.PrimaryPeerAddressPrefix = this.PrimaryPeerAddressPrefix;
            peering.SecondaryPeerAddressPrefix = this.SecondaryPeerAddressPrefix;
            peering.PeerASN = this.PeerASN;
            peering.VlanId = this.VlanId;

            if (!string.IsNullOrEmpty(this.SharedKey))
            {
                peering.SharedKey = this.SharedKey;
            }

            if (this.MicrosoftConfigAdvertisedPublicPrefixes != null
                && this.MicrosoftConfigAdvertisedPublicPrefixes.Any())
            {
                peering.MicrosoftPeeringConfig = new PSPeeringConfig();
                peering.MicrosoftPeeringConfig.AdvertisedPublicPrefixes = this.MicrosoftConfigAdvertisedPublicPrefixes;
                peering.MicrosoftPeeringConfig.CustomerASN = this.MicrosoftConfigCustomerAsn;
                peering.MicrosoftPeeringConfig.RoutingRegistryName = this.MicrosoftConfigRoutingRegistryName;
            }

            WriteObject(peering);
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            // Verify if the subnet exists in the VirtualNetwork
            var peering = this.Circuit.Peerings.SingleOrDefault(resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));

            if (peering != null)
            {
                throw new ArgumentException("Peering with the specified name already exists");
            }

            peering = new PSPeering();

            peering.Name = this.Name;
            peering.PeeringType = this.PeeringType;
            peering.PrimaryPeerAddressPrefix = this.PrimaryPeerAddressPrefix;
            peering.SecondaryPeerAddressPrefix = this.SecondaryPeerAddressPrefix;
            peering.AzureASN = this.AzureASN;
            peering.PeerASN = this.PeerASN;
            peering.VlanId = this.VlanId;

            if (this.MircosoftConfigAdvertisedPublicPrefixes != null
                && this.MircosoftConfigAdvertisedPublicPrefixes.Any())
            {
                peering.MicrosoftPeeringConfig = new PSPeeringConfig();
                peering.MicrosoftPeeringConfig.AdvertisedPublicPrefixes = this.MircosoftConfigAdvertisedPublicPrefixes;
                peering.MicrosoftPeeringConfig.CustomerASN = this.MircosoftConfigCustomerAsn;
                peering.MicrosoftPeeringConfig.RoutingRegistryName = this.MircosoftConfigRoutingRegistryName;
            }

            this.Circuit.Peerings.Add(peering);

            WriteObject(this.Circuit);
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            var peering = new PSPeering();

            peering.Name = this.Name;
            peering.PeeringType = this.PeeringType;
            peering.PrimaryPeerAddressPrefix = this.PrimaryPeerAddressPrefix;
            peering.SecondaryPeerAddressPrefix = this.SecondaryPeerAddressPrefix;
            peering.AzureASN = this.AzureASN;
            peering.PeerASN = this.PeerASN;
            peering.VlanId = this.VlanId;

            if (this.MircosoftConfigAdvertisedPublicPrefixes != null
                && this.MircosoftConfigAdvertisedPublicPrefixes.Any())
            {
                peering.MicrosoftPeeringConfig = new PSPeeringConfig();
                peering.MicrosoftPeeringConfig.AdvertisedPublicPrefixes = this.MircosoftConfigAdvertisedPublicPrefixes;
                peering.MicrosoftPeeringConfig.CustomerASN = this.MircosoftConfigCustomerAsn;
                peering.MicrosoftPeeringConfig.RoutingRegistryName = this.MircosoftConfigRoutingRegistryName;
            }

            WriteObject(peering);
        }