Пример #1
0
        public override void ExecuteCmdlet()
        {
            base.ExecuteCmdlet();

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

            if (gatewayIPConfiguration == null)
            {
                throw new ArgumentException("Application gateway IP configuration with the specified name does not exist");
            }

            gatewayIPConfiguration = new PSApplicationGatewayIPConfiguration();

            gatewayIPConfiguration.Name = this.Name;

            if (!string.IsNullOrEmpty(this.SubnetId))
            {
                var gatewayIPConfig = new PSResourceId();
                gatewayIPConfig.Id            = this.SubnetId;
                gatewayIPConfiguration.Subnet = gatewayIPConfig;
            }

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

            this.ApplicationGateway.GatewayIPConfigurations.Add(gatewayIPConfiguration);

            WriteObject(this.ApplicationGateway);
        }
        public PSApplicationGatewayIPConfiguration NewObject()
        {
            var gatewayIPConfiguration = new PSApplicationGatewayIPConfiguration();

            gatewayIPConfiguration.Name = this.Name;

            if (!string.IsNullOrEmpty(this.SubnetId))
            {
                var gatewayIPConfig = new PSResourceId();
                gatewayIPConfig.Id            = this.SubnetId;
                gatewayIPConfiguration.Subnet = gatewayIPConfig;
            }

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

            return(gatewayIPConfiguration);
        }