public override void Execute() { base.Execute(); var circuitconnection = new PSExpressRouteCircuitConnection(); circuitconnection.Name = this.Name; circuitconnection.AddressPrefix = this.AddressPrefix; var peering = this.ExpressRouteCircuit.Peerings.First( resource => string.Equals(resource.Name, "AzurePrivatePeering", System.StringComparison.CurrentCultureIgnoreCase)); if (peering == null) { throw new ArgumentException("Private Peering needs to be configured on the Express Route Circuit"); } circuitconnection.ExpressRouteCircuitPeering = new PSResourceId(); circuitconnection.ExpressRouteCircuitPeering.Id = peering.Id; circuitconnection.PeerExpressRouteCircuitPeering = new PSResourceId(); circuitconnection.PeerExpressRouteCircuitPeering.Id = this.PeerExpressRouteCircuitPeering; if (!string.IsNullOrWhiteSpace(this.AuthorizationKey)) { circuitconnection.AuthorizationKey = this.AuthorizationKey; } peering.Connections.Add(circuitconnection); WriteObject(this.ExpressRouteCircuit); }
public override void Execute() { base.Execute(); var peering = this.ExpressRouteCircuit.Peerings.SingleOrDefault( resource => string.Equals(resource.Name, "AzurePrivatePeering", System.StringComparison.CurrentCultureIgnoreCase)); if (peering == null) { throw new ArgumentException(Properties.Resources.ExpressRoutePrivatePeeringNotFound); } var circuitconnection = peering.Connections.SingleOrDefault( resource => string.Equals(resource.Name, Name, System.StringComparison.CurrentCultureIgnoreCase)); if (circuitconnection != null) { throw new ArgumentException(string.Format(Properties.Resources.ExpressRouteCircuitConnectionAlreadyAdded, Name)); } circuitconnection = new PSExpressRouteCircuitConnection(); circuitconnection.Name = this.Name; circuitconnection.ExpressRouteCircuitPeering = new PSResourceId(); circuitconnection.ExpressRouteCircuitPeering.Id = peering.Id; circuitconnection.PeerExpressRouteCircuitPeering = new PSResourceId(); circuitconnection.PeerExpressRouteCircuitPeering.Id = this.PeerExpressRouteCircuitPeering; if (!string.IsNullOrWhiteSpace(this.AuthorizationKey)) { circuitconnection.AuthorizationKey = this.AuthorizationKey; } if (this.AddressPrefixType == IPv6) { // Create new PSExpressRouteIPv6AddressPrefix() var expressRouteIPv6AddressPrefix = new PSExpressRouteCircuitConnectionIPv6ConnectionConfig(); expressRouteIPv6AddressPrefix.AddressPrefix = AddressPrefix; circuitconnection.IPv6CircuitConnectionConfig = expressRouteIPv6AddressPrefix; } else { // For IPv4 circuitconnection.AddressPrefix = this.AddressPrefix; } peering.Connections.Add(circuitconnection); WriteObject(this.ExpressRouteCircuit); }