public override void ExecuteCmdlet() { base.ExecuteCmdlet(); var backendAddressPool = new PSApplicationGatewayBackendAddressPool(); backendAddressPool.Name = this.Name; if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResource)) { backendAddressPool.BackendAddresses = this.BackendAddresses; } else { foreach (string id in this.BackendIpConfigurationIds) { var backendIpConfig = new PSResourceId(); backendIpConfig.Id = id; backendAddressPool.BackendIpConfigurations.Add(backendIpConfig); } } backendAddressPool.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId( this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId, Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayBackendAddressPoolName, this.Name); WriteObject(backendAddressPool); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); var backendAddressPool = this.ApplicationGateway.BackendAddressPools.SingleOrDefault (resource => string.Equals(resource.Name, this.Name, System.StringComparison.CurrentCultureIgnoreCase)); if (backendAddressPool != null) { throw new ArgumentException("Backend address pool with the specified name already exists"); } backendAddressPool = new PSApplicationGatewayBackendAddressPool(); backendAddressPool.Name = this.Name; if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResourceId)) { backendAddressPool.BackendIpConfigurations = new System.Collections.Generic.List <PSResourceId>(); foreach (string id in this.BackendIPConfigurationIds) { var backendIpConfig = new PSResourceId(); backendIpConfig.Id = id; backendAddressPool.BackendIpConfigurations.Add(backendIpConfig); } } else if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByIP)) { backendAddressPool.BackendAddresses = new System.Collections.Generic.List <PSApplicationGatewayBackendAddress>(); foreach (string ip in this.BackendIPAddresses) { var backendAddress = new PSApplicationGatewayBackendAddress(); backendAddress.IpAddress = ip; backendAddressPool.BackendAddresses.Add(backendAddress); } } else { backendAddressPool.BackendAddresses = new System.Collections.Generic.List <PSApplicationGatewayBackendAddress>(); foreach (string fqdn in this.BackendFqdns) { var backendAddress = new PSApplicationGatewayBackendAddress(); backendAddress.Fqdn = fqdn; backendAddressPool.BackendAddresses.Add(backendAddress); } } backendAddressPool.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId( this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId, Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayBackendAddressPoolName, this.Name); this.ApplicationGateway.BackendAddressPools.Add(backendAddressPool); WriteObject(this.ApplicationGateway); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); var backendAddressPool = new PSApplicationGatewayBackendAddressPool(); backendAddressPool.Name = this.Name; if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByResourceId)) { backendAddressPool.BackendIpConfigurations = new System.Collections.Generic.List <PSResourceId>(); foreach (string id in this.BackendIPConfigurationIds) { var backendIpConfig = new PSResourceId(); backendIpConfig.Id = id; backendAddressPool.BackendIpConfigurations.Add(backendIpConfig); } } else if (string.Equals(ParameterSetName, Microsoft.Azure.Commands.Network.Properties.Resources.SetByIP)) { backendAddressPool.BackendAddresses = new System.Collections.Generic.List <PSApplicationGatewayBackendAddress>(); foreach (string ip in this.BackendIPAddresses) { var backendAddress = new PSApplicationGatewayBackendAddress(); backendAddress.IpAddress = ip; backendAddressPool.BackendAddresses.Add(backendAddress); } } else { backendAddressPool.BackendAddresses = new System.Collections.Generic.List <PSApplicationGatewayBackendAddress>(); foreach (string fqdn in this.BackendFqdns) { var backendAddress = new PSApplicationGatewayBackendAddress(); backendAddress.Fqdn = fqdn; backendAddressPool.BackendAddresses.Add(backendAddress); } } backendAddressPool.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId( this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId, Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayBackendAddressPoolName, this.Name); WriteObject(backendAddressPool); }
public PSApplicationGatewayBackendAddressPool NewObject() { var backendAddressPool = new PSApplicationGatewayBackendAddressPool(); backendAddressPool.Name = this.Name; if (BackendIPAddresses != null && BackendFqdns != null) { throw new ArgumentException("At most one of BackendIPAddresses and BackendFqdns can be specified."); } else if (BackendIPAddresses != null && BackendIPAddresses.Count > 0) { backendAddressPool.BackendAddresses = new System.Collections.Generic.List <PSApplicationGatewayBackendAddress>(); foreach (string ip in this.BackendIPAddresses) { var backendAddress = new PSApplicationGatewayBackendAddress(); backendAddress.IpAddress = ip; backendAddressPool.BackendAddresses.Add(backendAddress); } } else if (BackendFqdns != null && BackendFqdns.Count > 0) { backendAddressPool.BackendAddresses = new System.Collections.Generic.List <PSApplicationGatewayBackendAddress>(); foreach (string fqdn in this.BackendFqdns) { var backendAddress = new PSApplicationGatewayBackendAddress(); backendAddress.Fqdn = fqdn; backendAddressPool.BackendAddresses.Add(backendAddress); } } backendAddressPool.Id = ApplicationGatewayChildResourceHelper.GetResourceNotSetId( this.NetworkClient.NetworkManagementClient.SubscriptionId, Microsoft.Azure.Commands.Network.Properties.Resources.ApplicationGatewayBackendAddressPoolName, this.Name); return(backendAddressPool); }