private PSVirtualNetworkGatewayConnection CreateVirtualNetworkGatewayConnection() { var vnetGatewayConnection = new PSVirtualNetworkGatewayConnection(); vnetGatewayConnection.Name = this.Name; vnetGatewayConnection.ResourceGroupName = this.ResourceGroupName; vnetGatewayConnection.Location = this.Location; vnetGatewayConnection.VirtualNetworkGateway1 = this.VirtualNetworkGateway1; vnetGatewayConnection.VirtualNetworkGateway2 = this.VirtualNetworkGateway2; vnetGatewayConnection.LocalNetworkGateway2 = this.LocalNetworkGateway2; vnetGatewayConnection.ConnectionType = this.ConnectionType; vnetGatewayConnection.RoutingWeight = this.RoutingWeight; vnetGatewayConnection.SharedKey = this.SharedKey; // Map to the sdk object var vnetGatewayConnectionModel = Mapper.Map <MNM.VirtualNetworkGatewayConnection>(vnetGatewayConnection); vnetGatewayConnectionModel.Type = Microsoft.Azure.Commands.Network.Properties.Resources.VirtualNetworkGatewayConnectionType; vnetGatewayConnectionModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true); // Execute the Create VirtualNetworkConnection call this.VirtualNetworkGatewayConnectionClient.CreateOrUpdate(this.ResourceGroupName, this.Name, vnetGatewayConnectionModel); var getVirtualNetworkGatewayConnection = this.GetVirtualNetworkGatewayConnection(this.ResourceGroupName, this.Name); return(getVirtualNetworkGatewayConnection); }
private PSVirtualNetworkGatewayConnection CreateVirtualNetworkGatewayConnection() { var vnetGatewayConnection = new PSVirtualNetworkGatewayConnection(); vnetGatewayConnection.Name = this.Name; vnetGatewayConnection.ResourceGroupName = this.ResourceGroupName; vnetGatewayConnection.Location = this.Location; vnetGatewayConnection.VirtualNetworkGateway1 = this.VirtualNetworkGateway1; vnetGatewayConnection.VirtualNetworkGateway2 = this.VirtualNetworkGateway2; vnetGatewayConnection.LocalNetworkGateway2 = this.LocalNetworkGateway2; vnetGatewayConnection.ConnectionType = this.ConnectionType; vnetGatewayConnection.RoutingWeight = this.RoutingWeight; vnetGatewayConnection.SharedKey = this.SharedKey; vnetGatewayConnection.EnableBgp = this.EnableBgp; vnetGatewayConnection.UsePolicyBasedTrafficSelectors = this.UsePolicyBasedTrafficSelectors; vnetGatewayConnection.ExpressRouteGatewayBypass = this.ExpressRouteGatewayBypass.IsPresent; if (!string.IsNullOrWhiteSpace(this.ConnectionProtocol)) { vnetGatewayConnection.ConnectionProtocol = this.ConnectionProtocol; } if (!string.IsNullOrEmpty(this.AuthorizationKey)) { vnetGatewayConnection.AuthorizationKey = this.AuthorizationKey; } if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResource)) { if (this.Peer != null) { this.PeerId = this.Peer.Id; } } if (!string.IsNullOrEmpty(this.PeerId)) { vnetGatewayConnection.Peer = new PSResourceId(); vnetGatewayConnection.Peer.Id = this.PeerId; } if (this.IpsecPolicies != null) { vnetGatewayConnection.IpsecPolicies = this.IpsecPolicies?.ToList(); } // Map to the sdk object var vnetGatewayConnectionModel = NetworkResourceManagerProfile.Mapper.Map <MNM.VirtualNetworkGatewayConnection>(vnetGatewayConnection); vnetGatewayConnectionModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true); // Execute the Create VirtualNetworkConnection call this.VirtualNetworkGatewayConnectionClient.CreateOrUpdate(this.ResourceGroupName, this.Name, vnetGatewayConnectionModel); var getVirtualNetworkGatewayConnection = this.GetVirtualNetworkGatewayConnection(this.ResourceGroupName, this.Name); return(getVirtualNetworkGatewayConnection); }
private PSVirtualNetworkGatewayConnection CreateVirtualNetworkGatewayConnection() { var vnetGatewayConnection = new PSVirtualNetworkGatewayConnection(); vnetGatewayConnection.Name = this.Name; vnetGatewayConnection.ResourceGroupName = this.ResourceGroupName; vnetGatewayConnection.Location = this.Location; vnetGatewayConnection.VirtualNetworkGateway1 = this.VirtualNetworkGateway1; vnetGatewayConnection.VirtualNetworkGateway2 = this.VirtualNetworkGateway2; vnetGatewayConnection.LocalNetworkGateway2 = this.LocalNetworkGateway2; vnetGatewayConnection.ConnectionType = this.ConnectionType; vnetGatewayConnection.RoutingWeight = this.RoutingWeight; vnetGatewayConnection.SharedKey = this.SharedKey; if (!string.IsNullOrEmpty(this.EnableBgp)) { vnetGatewayConnection.EnableBgp = bool.Parse(this.EnableBgp); } else { vnetGatewayConnection.EnableBgp = false; } if (!string.IsNullOrEmpty(this.AuthorizationKey)) { vnetGatewayConnection.AuthorizationKey = this.AuthorizationKey; } if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResource)) { if (this.Peer != null) { this.PeerId = this.Peer.Id; } } if (!string.IsNullOrEmpty(this.PeerId)) { vnetGatewayConnection.Peer = new PSResourceId(); vnetGatewayConnection.Peer.Id = this.PeerId; } // Map to the sdk object var vnetGatewayConnectionModel = Mapper.Map <MNM.VirtualNetworkGatewayConnection>(vnetGatewayConnection); vnetGatewayConnectionModel.Tags = TagsConversionHelper.CreateTagDictionary(this.Tag, validate: true); // Execute the Create VirtualNetworkConnection call this.VirtualNetworkGatewayConnectionClient.CreateOrUpdate(this.ResourceGroupName, this.Name, vnetGatewayConnectionModel); var getVirtualNetworkGatewayConnection = this.GetVirtualNetworkGatewayConnection(this.ResourceGroupName, this.Name); return(getVirtualNetworkGatewayConnection); }
public override void Execute() { PSVirtualNetworkGatewayConnection existingConnection = null; if (ParameterSetName.Equals("ByInputObject")) { existingConnection = InputObject; this.ResourceGroupName = this.InputObject.ResourceGroupName; this.Name = this.InputObject.Name; } else { if (ParameterSetName.Equals("ByResourceId")) { var parsedResourceId = new ResourceIdentifier(ResourceId); Name = parsedResourceId.ResourceName; ResourceGroupName = parsedResourceId.ResourceGroupName; } existingConnection = this.GetVirtualNetworkGatewayConnection(this.ResourceGroupName, this.Name); } if (existingConnection == null) { throw new PSArgumentException(Properties.Resources.ResourceNotFound, "Virtual Network Gateway connection"); } VpnPacketCaptureStopParameters parameters = new VpnPacketCaptureStopParameters(); if (this.SasUrl != null) { parameters.SasUrl = SasUrl; } base.Execute(); if (ShouldProcess(this.Name, String.Format(Properties.Resources.CreatingLongRunningOperationMessage, this.ResourceGroupName, this.Name))) { WriteVerbose(String.Format(Properties.Resources.CreatingLongRunningOperationMessage, this.ResourceGroupName, this.Name)); PSVirtualNetworkGatewayConnectionPacketCaptureResult output = new PSVirtualNetworkGatewayConnectionPacketCaptureResult() { Name = existingConnection.Name, ResourceGroupName = existingConnection.ResourceGroupName, Tag = existingConnection.Tag, ResourceGuid = existingConnection.ResourceGuid, Location = existingConnection.Location, }; output.StartTime = DateTime.UtcNow; var result = this.VirtualNetworkGatewayConnectionClient.StopPacketCapture(this.ResourceGroupName, this.Name, parameters); output.EndTime = DateTime.UtcNow; WriteObject(output); } }