public string FormatIdBgpPeeringAddresses(string id, string resourceGroupName, string resourceName) { string result = ChildResourceHelp.NormalizeVirtualNetworkGatewayChildResourceIds(id, resourceGroupName, resourceName); result = result.Replace("virtualNetworkGatewayIpConfiguration", "ipConfigurations"); return(result); }
public override void Execute() { base.Execute(); if (ShouldProcess(Name, Properties.Resources.AddingResourceMessage + Properties.Resources.VirtualNetworkGatewayIpConfigName)) { // Get the subnetId and publicIpAddressId from the objects if specified if (string.Equals(ParameterSetName, "object")) { if (Subnet != null) { this.SubnetId = this.Subnet.Id; } if (PublicIpAddress != null) { this.PublicIpAddressId = this.PublicIpAddress.Id; } } var vnetGatewayIpConfig = new PSVirtualNetworkGatewayIpConfiguration(); vnetGatewayIpConfig.Name = this.Name; if (!string.IsNullOrEmpty(this.SubnetId)) { vnetGatewayIpConfig.Subnet = new PSResourceId(); vnetGatewayIpConfig.Subnet.Id = this.SubnetId; } if (!string.IsNullOrEmpty(this.PrivateIpAddress)) { vnetGatewayIpConfig.PrivateIpAddress = this.PrivateIpAddress; vnetGatewayIpConfig.PrivateIpAllocationMethod = Management.Network.Models.IPAllocationMethod.Static; } else { vnetGatewayIpConfig.PrivateIpAllocationMethod = Management.Network.Models.IPAllocationMethod.Dynamic; } if (!string.IsNullOrEmpty(this.PublicIpAddressId)) { vnetGatewayIpConfig.PublicIpAddress = new PSResourceId(); vnetGatewayIpConfig.PublicIpAddress.Id = this.PublicIpAddressId; } vnetGatewayIpConfig.Id = ChildResourceHelp.GetResourceNotSetId( this.NetworkClient.NetworkManagementClient.SubscriptionId, Properties.Resources.VirtualNetworkGatewayIpConfigName, this.Name); if (this.VirtualNetworkGateway.IpConfigurations == null) { this.VirtualNetworkGateway.IpConfigurations = new List <PSVirtualNetworkGatewayIpConfiguration>(); } this.VirtualNetworkGateway.IpConfigurations.Add(vnetGatewayIpConfig); WriteObject(this.VirtualNetworkGateway); } }
protected override void ProcessRecord() { base.ProcessRecord(); // Get the subnetId and publicIpAddressId from the objects if specified if (string.Equals(ParameterSetName, "object")) { if (Subnet != null) { this.SubnetId = this.Subnet.Id; } if (PublicIpAddress != null) { this.PublicIpAddressId = this.PublicIpAddress.Id; } } var vnetGatewayIpConfig = new PSVirtualNetworkGatewayIpConfiguration(); vnetGatewayIpConfig.Name = this.Name; if (!string.IsNullOrEmpty(this.SubnetId)) { vnetGatewayIpConfig.Subnet = new PSResourceId(); vnetGatewayIpConfig.Subnet.Id = this.SubnetId; } if (!string.IsNullOrEmpty(this.PrivateIpAddress)) { vnetGatewayIpConfig.PrivateIpAddress = this.PrivateIpAddress; vnetGatewayIpConfig.PrivateIpAllocationMethod = Management.Network.Models.IpAllocationMethod.Static; } else { vnetGatewayIpConfig.PrivateIpAllocationMethod = Management.Network.Models.IpAllocationMethod.Dynamic; } if (!string.IsNullOrEmpty(this.PublicIpAddressId)) { vnetGatewayIpConfig.PublicIpAddress = new PSResourceId(); vnetGatewayIpConfig.PublicIpAddress.Id = this.PublicIpAddressId; } vnetGatewayIpConfig.Id = ChildResourceHelp.GetResourceNotSetId( this.NetworkClient.NetworkResourceProviderClient.Credentials.SubscriptionId, Microsoft.Azure.Commands.Network.Properties.Resources.VirtualNetworkGatewayIpConfigName, this.Name); WriteObject(vnetGatewayIpConfig); }