public override void ExecuteCmdlet() { base.ExecuteCmdlet(); // Get the subnetId and publicIp AddressId from the object if specified if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResource)) { if (Subnet != null) { this.SubnetId = this.Subnet.Id; } if (PublicIpAddress != null) { this.PublicIpAddressId = this.PublicIpAddress.Id; } } var frontendIpConfig = new PSApplicationGatewayFrontendIpConfiguration(); frontendIpConfig.Name = this.Name; if (!string.IsNullOrEmpty(this.SubnetId)) { frontendIpConfig.Subnet = new PSResourceId(); frontendIpConfig.Subnet.Id = this.SubnetId; if (!string.IsNullOrEmpty(this.PrivateIpAddress)) { frontendIpConfig.PrivateIpAddress = this.PrivateIpAddress; frontendIpConfig.PrivateIpAllocationMethod = Management.Network.Models.IpAllocationMethod.Static; } else { frontendIpConfig.PrivateIpAllocationMethod = Management.Network.Models.IpAllocationMethod.Dynamic; } } if (!string.IsNullOrEmpty(this.PublicIpAddressId)) { frontendIpConfig.PublicIpAddress = new PSResourceId(); frontendIpConfig.PublicIpAddress.Id = this.PublicIpAddressId; } frontendIpConfig.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId( this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId, Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayFrontendIpConfigName, this.Name); WriteObject(frontendIpConfig); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); var existingFrontendIpConfig = this.ApplicationGateway.FrontendIpConfigurations.SingleOrDefault (resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase)); if (existingFrontendIpConfig != null) { throw new ArgumentException("FrontendIpConfiguration with the specified name already exists"); } // Get the subnetId and publicIpAddressId from the object if specified if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResource)) { this.SubnetId = this.Subnet.Id; if (PublicIpAddress != null) { this.PublicIpAddressId = this.PublicIpAddress.Id; } } var frontendIpConfig = new PSApplicationGatewayFrontendIpConfiguration(); frontendIpConfig.Name = this.Name; if (!string.IsNullOrEmpty(this.SubnetId)) { frontendIpConfig.Subnet = new PSResourceId(); frontendIpConfig.Subnet.Id = this.SubnetId; if (!string.IsNullOrEmpty(this.PrivateIpAddress)) { frontendIpConfig.PrivateIpAddress = this.PrivateIpAddress; frontendIpConfig.PrivateIpAllocationMethod = Management.Network.Models.IpAllocationMethod.Static; } else { frontendIpConfig.PrivateIpAllocationMethod = Management.Network.Models.IpAllocationMethod.Dynamic; } } if (!string.IsNullOrEmpty(this.PublicIpAddressId)) { frontendIpConfig.PublicIpAddress = new PSResourceId(); frontendIpConfig.PublicIpAddress.Id = this.PublicIpAddressId; } frontendIpConfig.Id = ChildResourceHelper.GetResourceId( this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId, this.ApplicationGateway.ResourceGroupName, this.ApplicationGateway.Name, Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayFrontendIpConfigName, this.Name); this.ApplicationGateway.FrontendIpConfigurations.Add(frontendIpConfig); WriteObject(this.ApplicationGateway); }