Configuring private and public IP addresses
In this section, we are going to configure both a private and a public IP address. When we created the VNet, a private IP address was created for us automatically by Azure. However, we are going to create another in this demonstration and associate it, along with the public IP address, to a network interface card (NIC). To configure a private and public IP address from PowerShell, you have to perform the following steps:
- In the same PowerShell window, add the following code to retrieve the VNet and subnet configuration:
$vnet = Get-AzVirtualNetwork -Name PacktVirtualNetwork - ResourceGroupName PacktVNetResourceGroup $subnet = Get-AzVirtualNetworkSubnetConfig -Name default - VirtualNetwork $vnet
- Next, create a private and a public IP address and assign them to the configuration, as follows:
$publicIP = New-AzPublicIpAddress ` -Name PacktPublicIP ` -ResourceGroupName PacktVNetResourceGroup ` -AllocationMethod Dynamic ` -Location EastUS...