public override void Execute() { base.Execute(); ConfirmAction( Force.IsPresent, string.Format(Properties.Resources.OverwritingResource, Name), Properties.Resources.CreatingResourceMessage, Name, () => { var peering = this.ExpressRouteCrossConnection.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 PSExpressRouteCrossConnectionPeering(); peering.Name = this.Name; peering.PeeringType = this.PeeringType; peering.PeerASN = this.PeerASN; peering.VlanId = this.VlanId; if (!string.IsNullOrEmpty(this.SharedKey)) { peering.SharedKey = this.SharedKey; } if (this.PeerAddressType == IPv6) { this.SetIpv6PeeringParameters(peering); } else { // Set IPv4 config even if no PeerAddresType has been specified for backward compatibility this.SetIpv4PeeringParameters(peering); } this.ConstructMicrosoftConfig(peering); this.ExpressRouteCrossConnection.Peerings.Add(peering); // Map to the sdk operation var crossConnectionModel = NetworkResourceManagerProfile.Mapper.Map <Management.Network.Models.ExpressRouteCrossConnection>(ExpressRouteCrossConnection); crossConnectionModel.Tags = TagsConversionHelper.CreateTagDictionary(ExpressRouteCrossConnection.Tag, validate: true); // Execute the Update ExpressRouteCrossConnection call ExpressRouteCrossConnectionClient.CreateOrUpdate(ExpressRouteCrossConnection.ResourceGroupName, ExpressRouteCrossConnection.Name, crossConnectionModel); var getExpressRouteCrossConnection = GetExpressRouteCrossConnection(ExpressRouteCrossConnection.ResourceGroupName, ExpressRouteCrossConnection.Name); WriteObject(getExpressRouteCrossConnection); }); }
public void ConstructMicrosoftConfig(PSExpressRouteCrossConnectionPeering peering) { if (MicrosoftConfigAdvertisedPublicPrefix != null && MicrosoftConfigAdvertisedPublicPrefix.Count() > 0) { if (PeerAddressType == IPv6) { peering.Ipv6PeeringConfig.MicrosoftPeeringConfig = new PSPeeringConfig(); peering.Ipv6PeeringConfig.MicrosoftPeeringConfig.AdvertisedPublicPrefixes = MicrosoftConfigAdvertisedPublicPrefix.ToList(); peering.Ipv6PeeringConfig.MicrosoftPeeringConfig.CustomerASN = MicrosoftConfigCustomerAsn; peering.Ipv6PeeringConfig.MicrosoftPeeringConfig.RoutingRegistryName = MicrosoftConfigRoutingRegistryName; } else { // Set IPv4 config even if no PeerAddresType has been specified for backward compatibility peering.MicrosoftPeeringConfig = new PSPeeringConfig(); peering.MicrosoftPeeringConfig.AdvertisedPublicPrefixes = MicrosoftConfigAdvertisedPublicPrefix.ToList(); peering.MicrosoftPeeringConfig.CustomerASN = MicrosoftConfigCustomerAsn; peering.MicrosoftPeeringConfig.RoutingRegistryName = MicrosoftConfigRoutingRegistryName; } } }
public void SetIpv4PeeringParameters(PSExpressRouteCrossConnectionPeering peering) { peering.PrimaryPeerAddressPrefix = PrimaryPeerAddressPrefix; peering.SecondaryPeerAddressPrefix = SecondaryPeerAddressPrefix; }