public override void Execute() { base.Execute(); var existingInboundNatPool = this.LoadBalancer.InboundNatPools.SingleOrDefault(resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase)); if (existingInboundNatPool != null) { throw new ArgumentException("InboundNatPool with the specified name already exists"); } var inboundNatPool = new PSInboundNatPool(); inboundNatPool.Name = this.Name; inboundNatPool.Protocol = this.Protocol; inboundNatPool.FrontendPortRangeStart = this.FrontendPortRangeStart; inboundNatPool.FrontendPortRangeEnd = this.FrontendPortRangeEnd; inboundNatPool.BackendPort = this.BackendPort; if (!string.IsNullOrEmpty(this.FrontendIpConfigurationId)) { inboundNatPool.FrontendIPConfiguration = new PSResourceId() { Id = this.FrontendIpConfigurationId }; } inboundNatPool.Id = ChildResourceHelper.GetResourceId( this.NetworkClient.NetworkManagementClient.SubscriptionId, this.LoadBalancer.ResourceGroupName, this.LoadBalancer.Name, Microsoft.Azure.Commands.Network.Properties.Resources.LoadBalancerInboundNatPoolName, this.Name); this.LoadBalancer.InboundNatPools.Add(inboundNatPool); WriteObject(this.LoadBalancer); }
public override void Execute() { base.Execute(); var inboundNatPool = new PSInboundNatPool(); inboundNatPool.Name = this.Name; inboundNatPool.Protocol = this.Protocol; inboundNatPool.FrontendPortRangeStart = this.FrontendPortRangeStart; inboundNatPool.FrontendPortRangeEnd = this.FrontendPortRangeEnd; inboundNatPool.BackendPort = this.BackendPort; if (!string.IsNullOrEmpty(this.FrontendIpConfigurationId)) { inboundNatPool.FrontendIPConfiguration = new PSResourceId() { Id = this.FrontendIpConfigurationId }; } inboundNatPool.Id = ChildResourceHelper.GetResourceNotSetId( this.NetworkClient.NetworkManagementClient.SubscriptionId, Microsoft.Azure.Commands.Network.Properties.Resources.LoadBalancerInboundNatPoolName, this.Name); WriteObject(inboundNatPool); }