public PSApplicationGatewayHttpListener NewObject()
        {
            var httpListener = new PSApplicationGatewayHttpListener();

            httpListener.Name     = this.Name;
            httpListener.Protocol = this.Protocol;

            if (!string.IsNullOrEmpty(this.FrontendIPConfigurationId))
            {
                httpListener.FrontendIpConfiguration    = new PSResourceId();
                httpListener.FrontendIpConfiguration.Id = this.FrontendIPConfigurationId;
            }

            if (!string.IsNullOrEmpty(this.FrontendPortId))
            {
                httpListener.FrontendPort    = new PSResourceId();
                httpListener.FrontendPort.Id = this.FrontendPortId;
            }
            if (!string.IsNullOrEmpty(this.SslCertificateId))
            {
                httpListener.SslCertificate    = new PSResourceId();
                httpListener.SslCertificate.Id = this.SslCertificateId;
            }

            httpListener.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
                this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId,
                Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayHttpListenerName,
                this.Name);

            return(httpListener);
        }
Beispiel #2
0
        public PSApplicationGatewayHttpListener NewObject()
        {
            var httpListener = new PSApplicationGatewayHttpListener();

            httpListener.Name     = this.Name;
            httpListener.Protocol = this.Protocol;
            httpListener.HostName = this.HostName;

            if (string.Equals(this.RequireServerNameIndication, "true", StringComparison.OrdinalIgnoreCase))
            {
                httpListener.RequireServerNameIndication = true;
            }
            else if (string.Equals(this.RequireServerNameIndication, "false", StringComparison.OrdinalIgnoreCase))
            {
                httpListener.RequireServerNameIndication = false;
            }
            else if (string.Equals(this.Protocol, "https", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrEmpty(this.HostName))
            {
                // Set default as true to be at parity with portal.
                httpListener.RequireServerNameIndication = true;
            }

            if (!string.IsNullOrEmpty(this.FrontendIPConfigurationId))
            {
                httpListener.FrontendIpConfiguration    = new PSResourceId();
                httpListener.FrontendIpConfiguration.Id = this.FrontendIPConfigurationId;
            }

            if (!string.IsNullOrEmpty(this.FrontendPortId))
            {
                httpListener.FrontendPort    = new PSResourceId();
                httpListener.FrontendPort.Id = this.FrontendPortId;
            }

            if (!string.IsNullOrEmpty(this.SslCertificateId))
            {
                httpListener.SslCertificate    = new PSResourceId();
                httpListener.SslCertificate.Id = this.SslCertificateId;
            }

            if (!string.IsNullOrEmpty(this.FirewallPolicyId))
            {
                httpListener.FirewallPolicy    = new PSResourceId();
                httpListener.FirewallPolicy.Id = this.FirewallPolicyId;
            }

            if (this.CustomErrorConfiguration != null)
            {
                httpListener.CustomErrorConfigurations = this.CustomErrorConfiguration?.ToList();
            }

            httpListener.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
                this.NetworkClient.NetworkManagementClient.SubscriptionId,
                Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayHttpListenerName,
                this.Name);

            return(httpListener);
        }
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

            var httpListener = this.ApplicationGateway.HttpListeners.SingleOrDefault
                                   (resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase));

            if (httpListener != null)
            {
                throw new ArgumentException("Http Listener with the specified name already exists");
            }

            httpListener          = new PSApplicationGatewayHttpListener();
            httpListener.Name     = this.Name;
            httpListener.Protocol = this.Protocol;

            if (!string.IsNullOrEmpty(this.FrontendIPConfigurationId))
            {
                httpListener.FrontendIpConfiguration    = new PSResourceId();
                httpListener.FrontendIpConfiguration.Id = this.FrontendIPConfigurationId;
            }

            if (!string.IsNullOrEmpty(this.FrontendPortId))
            {
                httpListener.FrontendPort    = new PSResourceId();
                httpListener.FrontendPort.Id = this.FrontendPortId;
            }
            if (!string.IsNullOrEmpty(this.SslCertificateId))
            {
                httpListener.SslCertificate    = new PSResourceId();
                httpListener.SslCertificate.Id = this.SslCertificateId;
            }

            httpListener.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId(
                this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId,
                Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayHttpListenerName,
                this.Name);

            this.ApplicationGateway.HttpListeners.Add(httpListener);

            WriteObject(this.ApplicationGateway);
        }