protected override void ProcessRecord() { base.ProcessRecord(); // Get the subnetId and publicIpAddressId from the object if specified if (string.Equals(ParameterSetName, "object")) { this.SubnetId = this.Subnet.Id; if (PublicIpAddress != null) { this.PublicIpAddressId = this.PublicIpAddress.Id; } } var frontendIpConfig = new PSFrontendIPConfiguration(); 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.GetResourceNotSetId( this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId, Microsoft.Azure.Commands.Network.Properties.Resources.LoadBalancerFrontendIpConfigName, this.Name); WriteObject(frontendIpConfig); }
public override void Execute() { base.Execute(); var existingFrontendIpConfig = this.LoadBalancer.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"); } var frontendIpConfig = new PSFrontendIPConfiguration(); frontendIpConfig.Name = this.Name; if (!string.IsNullOrEmpty(this.SubnetId)) { frontendIpConfig.Subnet = new PSSubnet(); 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 PSPublicIpAddress(); frontendIpConfig.PublicIpAddress.Id = this.PublicIpAddressId; } frontendIpConfig.Id = ChildResourceHelper.GetResourceId( this.NetworkClient.NetworkManagementClient.SubscriptionId, this.LoadBalancer.ResourceGroupName, this.LoadBalancer.Name, Microsoft.Azure.Commands.Network.Properties.Resources.LoadBalancerFrontendIpConfigName, this.Name); this.LoadBalancer.FrontendIpConfigurations.Add(frontendIpConfig); WriteObject(this.LoadBalancer); }
public override void Execute() { base.Execute(); var frontendIpConfig = new PSFrontendIPConfiguration(); frontendIpConfig.Name = this.Name; if (!string.IsNullOrEmpty(this.SubnetId)) { frontendIpConfig.Subnet = new PSSubnet(); 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 PSPublicIpAddress(); frontendIpConfig.PublicIpAddress.Id = this.PublicIpAddressId; } frontendIpConfig.Id = ChildResourceHelper.GetResourceNotSetId( this.NetworkClient.NetworkManagementClient.SubscriptionId, Microsoft.Azure.Commands.Network.Properties.Resources.LoadBalancerFrontendIpConfigName, this.Name); WriteObject(frontendIpConfig); }