From 48df3019bfc77295954dfd44e1c67e3afa40bcb8 Mon Sep 17 00:00:00 2001 From: Thomas Thornton Date: Tue, 17 Mar 2020 14:34:23 +0000 Subject: [PATCH 1/2] Update New-AzNetworkInterface.md Removed reference to the manual subnet entry and added code to allow retrieval of subnetID via PowerShell from Virtual Network. This would be a best practice rather than hard-coding subnet ID entry. --- src/Network/Network/help/New-AzNetworkInterface.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Network/Network/help/New-AzNetworkInterface.md b/src/Network/Network/help/New-AzNetworkInterface.md index eed3c1a77cf2..aa3549680967 100644 --- a/src/Network/Network/help/New-AzNetworkInterface.md +++ b/src/Network/Network/help/New-AzNetworkInterface.md @@ -70,15 +70,17 @@ created automatically using the name IPConfiguration1. ### Example 2: Create an Azure network interface using an IP configuration object ``` -PS C:\>$IPconfig = New-AzNetworkInterfaceIpConfig -Name "IPConfig1" -PrivateIpAddressVersion IPv4 -PrivateIpAddress "10.0.1.10" -SubnetId "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/ResourceGroup1/providers/Microsoft.Network/virtualNetworks/VirtualNetwork1/subnets/Subnet1" +PS C:\>$Subnet = Get-AzVirtualNetwork -name "VirtualNetwork1" -ResourceGroupName "ResourceGroup1" +PS C:\>$IPconfig = New-AzNetworkInterfaceIpConfig -Name "IPConfig1" -PrivateIpAddressVersion IPv4 -PrivateIpAddress "10.0.1.10" -SubnetId $Subnet.subnets[0].id PS C:\> New-AzNetworkInterface -Name "NetworkInterface1" -ResourceGroupName "ResourceGroup1" -Location "centralus" -IpConfiguration $IPconfig ``` This example creates a new network interface using an IP configuration object. The IP configuration object specifies a static private IPv4 address. -The first command creates a network interface IP configuration named IPConfig1 and stores the +The first command retrieves an existing specified virtual network used to assign the subnet in the second command. +The second command creates a network interface IP configuration named IPConfig1 and stores the configuration in the variable named $IPconfig. -The second command creates a network interface named NetworkInterface1 that uses the network +The third command creates a network interface named NetworkInterface1 that uses the network interface IP configuration stored in the variable named $IPconfig. ## PARAMETERS From b4ff9caf7e492f7c6feb03af74fe1005ef5f36c1 Mon Sep 17 00:00:00 2001 From: Yeming Liu Date: Mon, 23 Mar 2020 15:53:44 +0800 Subject: [PATCH 2/2] update cmdlet syntax --- src/Network/Network/help/New-AzNetworkInterface.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Network/Network/help/New-AzNetworkInterface.md b/src/Network/Network/help/New-AzNetworkInterface.md index aa3549680967..ff64812a0241 100644 --- a/src/Network/Network/help/New-AzNetworkInterface.md +++ b/src/Network/Network/help/New-AzNetworkInterface.md @@ -70,8 +70,8 @@ created automatically using the name IPConfiguration1. ### Example 2: Create an Azure network interface using an IP configuration object ``` -PS C:\>$Subnet = Get-AzVirtualNetwork -name "VirtualNetwork1" -ResourceGroupName "ResourceGroup1" -PS C:\>$IPconfig = New-AzNetworkInterfaceIpConfig -Name "IPConfig1" -PrivateIpAddressVersion IPv4 -PrivateIpAddress "10.0.1.10" -SubnetId $Subnet.subnets[0].id +PS C:\>$Subnet = Get-AzVirtualNetwork -Name "VirtualNetwork1" -ResourceGroupName "ResourceGroup1" +PS C:\>$IPconfig = New-AzNetworkInterfaceIpConfig -Name "IPConfig1" -PrivateIpAddressVersion IPv4 -PrivateIpAddress "10.0.1.10" -SubnetId $Subnet.Subnets[0].Id PS C:\> New-AzNetworkInterface -Name "NetworkInterface1" -ResourceGroupName "ResourceGroup1" -Location "centralus" -IpConfiguration $IPconfig ```