Beispiel #1
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            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);
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();

            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.NetworkResourceProviderClient.Credentials.SubscriptionId,
                    Microsoft.Azure.Commands.Network.Properties.Resources.LoadBalancerInboundNatPoolsName,
                    this.Name);

            WriteObject(inboundNatPool);
        }
Beispiel #3
0
        public override void 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");
            }

            // InboundNatPools
            if (this.LoadBalancer.InboundNatPools == null)
            {
                this.LoadBalancer.InboundNatPools = new List <PSInboundNatPool>();
            }

            if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResource))
            {
                if (this.FrontendIpConfiguration != null)
                {
                    this.FrontendIpConfigurationId = this.FrontendIpConfiguration.Id;
                }
            }

            var vInboundNatPools = new PSInboundNatPool();

            vInboundNatPools.Protocol = this.Protocol;
            vInboundNatPools.FrontendPortRangeStart = this.FrontendPortRangeStart;
            vInboundNatPools.FrontendPortRangeEnd   = this.FrontendPortRangeEnd;
            vInboundNatPools.BackendPort            = this.BackendPort;
            vInboundNatPools.IdleTimeoutInMinutes   = this.MyInvocation.BoundParameters.ContainsKey("IdleTimeoutInMinutes") ? this.IdleTimeoutInMinutes : 4;
            vInboundNatPools.EnableFloatingIP       = this.EnableFloatingIP;
            vInboundNatPools.EnableTcpReset         = this.EnableTcpReset;
            vInboundNatPools.Name = this.Name;
            if (!string.IsNullOrEmpty(this.FrontendIpConfigurationId))
            {
                // FrontendIPConfiguration
                if (vInboundNatPools.FrontendIPConfiguration == null)
                {
                    vInboundNatPools.FrontendIPConfiguration = new PSResourceId();
                }
                vInboundNatPools.FrontendIPConfiguration.Id = this.FrontendIpConfigurationId;
            }
            var generatedId = string.Format(
                "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/loadBalancers/{2}/{3}/{4}",
                this.NetworkClient.NetworkManagementClient.SubscriptionId,
                this.LoadBalancer.ResourceGroupName,
                this.LoadBalancer.Name,
                "InboundNatPools",
                this.Name);

            vInboundNatPools.Id = generatedId;

            this.LoadBalancer.InboundNatPools.Add(vInboundNatPools);
            WriteObject(this.LoadBalancer, true);
        }
Beispiel #4
0
        public override void Execute()
        {
            if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResource))
            {
                if (this.FrontendIpConfiguration != null)
                {
                    this.FrontendIpConfigurationId = this.FrontendIpConfiguration.Id;
                }
            }
            var vInboundNatPools = new PSInboundNatPool();

            vInboundNatPools.Protocol = this.Protocol;
            vInboundNatPools.FrontendPortRangeStart = this.FrontendPortRangeStart;
            vInboundNatPools.FrontendPortRangeEnd   = this.FrontendPortRangeEnd;
            vInboundNatPools.BackendPort            = this.BackendPort;
            vInboundNatPools.IdleTimeoutInMinutes   = this.MyInvocation.BoundParameters.ContainsKey("IdleTimeoutInMinutes") ? this.IdleTimeoutInMinutes : 4;
            vInboundNatPools.EnableFloatingIP       = this.EnableFloatingIP;
            vInboundNatPools.EnableTcpReset         = this.EnableTcpReset;
            vInboundNatPools.Name = this.Name;
            if (!string.IsNullOrEmpty(this.FrontendIpConfigurationId))
            {
                // FrontendIPConfiguration
                if (vInboundNatPools.FrontendIPConfiguration == null)
                {
                    vInboundNatPools.FrontendIPConfiguration = new PSResourceId();
                }
                vInboundNatPools.FrontendIPConfiguration.Id = this.FrontendIpConfigurationId;
            }
            var generatedId = string.Format(
                "/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Network/loadBalancers/{2}/{3}/{4}",
                this.NetworkClient.NetworkManagementClient.SubscriptionId,
                Microsoft.Azure.Commands.Network.Properties.Resources.ResourceGroupNotSet,
                Microsoft.Azure.Commands.Network.Properties.Resources.LoadBalancerNameNotSet,
                "InboundNatPools",
                this.Name);

            vInboundNatPools.Id = generatedId;

            WriteObject(vInboundNatPools, true);
        }
        public override void Execute()
        {
            var vInboundNatPoolsIndex = this.LoadBalancer.InboundNatPools.IndexOf(
                this.LoadBalancer.InboundNatPools.SingleOrDefault(
                    resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase)));

            if (vInboundNatPoolsIndex == -1)
            {
                throw new ArgumentException("InboundNatPools with the specified name does not exist");
            }

            if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResource))
            {
                if (this.FrontendIpConfiguration != null)
                {
                    this.FrontendIpConfigurationId = this.FrontendIpConfiguration.Id;
                }
            }
            var vInboundNatPools = new PSInboundNatPool();

            vInboundNatPools.Protocol = this.Protocol;
            vInboundNatPools.FrontendPortRangeStart = this.FrontendPortRangeStart;
            vInboundNatPools.FrontendPortRangeEnd   = this.FrontendPortRangeEnd;
            vInboundNatPools.BackendPort            = this.BackendPort;
            vInboundNatPools.IdleTimeoutInMinutes   = this.MyInvocation.BoundParameters.ContainsKey("IdleTimeoutInMinutes") ? this.IdleTimeoutInMinutes : 4;
            vInboundNatPools.EnableFloatingIP       = this.EnableFloatingIP;
            vInboundNatPools.EnableTcpReset         = this.EnableTcpReset;
            vInboundNatPools.Name = this.Name;
            if (!string.IsNullOrEmpty(this.FrontendIpConfigurationId))
            {
                // FrontendIPConfiguration
                if (vInboundNatPools.FrontendIPConfiguration == null)
                {
                    vInboundNatPools.FrontendIPConfiguration = new PSResourceId();
                }
                vInboundNatPools.FrontendIPConfiguration.Id = this.FrontendIpConfigurationId;
            }
            this.LoadBalancer.InboundNatPools[vInboundNatPoolsIndex] = vInboundNatPools;
            WriteObject(this.LoadBalancer, true);
        }
Beispiel #6
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            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.LoadBalancerInboundNatPoolsName,
                    this.Name);

            this.LoadBalancer.InboundNatPools.Add(inboundNatPool);

            WriteObject(this.LoadBalancer);
        }