Skip to content

Commit 2f33440

Browse files
committed
docs: Add RG split, nginx install via Run Command, and web test for dual-stack article
1 parent face17d commit 2f33440

1 file changed

Lines changed: 158 additions & 50 deletions

File tree

articles/virtual-network/ip-services/create-vm-dual-stack-ipv6-portal.md

Lines changed: 158 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,26 @@ If you choose to install and use PowerShell locally, this article requires the A
4747

4848
In this section, you create a resource group and dual-stack virtual network for the virtual machine in the Azure portal.
4949

50+
### Create a resource group
51+
5052
1. Sign-in to the [Azure portal](https://portal.azure.com).
5153

54+
1. In the portal, search for and select **Resource groups**.
55+
56+
1. Select **+ Create**.
57+
58+
1. On the **Basics** tab, enter or select the following values:
59+
60+
| Setting | Value |
61+
| ------- | ----- |
62+
| **Subscription** | Select your subscription. |
63+
| **Resource group** | Enter *myResourceGroup*. |
64+
| **Region** | Select **(US) East US 2**. |
65+
66+
1. Select **Review + create**, and then select **Create**.
67+
68+
### Create a virtual network
69+
5270
1. In the search box at the top of the portal, enter **Virtual network**. Select **Virtual networks** in the search results.
5371

5472
1. Select **+ Create**.
@@ -59,7 +77,7 @@ In this section, you create a resource group and dual-stack virtual network for
5977
| ------- | ----- |
6078
| **Project details** | |
6179
| Subscription | Select your subscription. |
62-
| Resource group | Select **Create new**. </br> In **Name**, enter **myResourceGroup**. </br> Select **OK**. |
80+
| Resource group | Select **myResourceGroup**. |
6381
| **Instance details** | |
6482
| Name | Enter **myVNet**. |
6583
| Region | Select **East US 2**. |
@@ -548,65 +566,173 @@ New-AzVM @vm -GenerateSshKey
548566

549567
---
550568

551-
## Test SSH connection
569+
## Install nginx
570+
571+
In this section, you create a network security group rule to allow HTTP traffic and install nginx on the virtual machine using the Run Command feature.
552572

553573
# [Azure portal](#tab/azureportal)
554574

555-
You connect to the virtual machine with SSH to test the IPv4 public IP address.
575+
### Create an inbound security rule
556576

557-
1. In the search box at the top of the portal, enter **Public IP address**. Select **Public IP addresses** in the search results.
577+
1. In the search box at the top of the portal, enter **Network security group**. Select **Network security groups** in the search results.
578+
579+
1. Select **myNSG**.
580+
581+
1. Select **Inbound security rules** in **Settings**.
582+
583+
1. Select **+ Add**.
584+
585+
1. Enter or select the following information:
586+
587+
| Setting | Value |
588+
| ------- | ----- |
589+
| Source | Leave the default of **Any**. |
590+
| Source port ranges | Leave the default of **\***. |
591+
| Destination | Leave the default of **Any**. |
592+
| Service | Select **HTTP**. |
593+
| Action | Leave the default of **Allow**. |
594+
| Priority | Enter **100**. |
595+
| Name | Enter *myNSGRuleHTTP*. |
596+
597+
1. Select **Add**.
598+
599+
### Install nginx with Run Command
600+
601+
1. In the search box at the top of the portal, enter **Virtual machine**. Select **Virtual machines** in the search results.
602+
603+
1. Select **myVM**.
558604

559-
2. Select **myPublicIP-IPv4**.
605+
1. In **Operations**, select **Run command**.
560606

561-
3. The public IPv4 address is in the **Overview** in **IP address**. In this example it's, **20.22.46.19**.
607+
1. Select **RunShellScript**.
562608

563-
4. Open an SSH connection to the virtual machine by using the following command. Replace the IP address with the IP address of your virtual machine. Replace **`azureuser`** with the username you chose during virtual machine creation. The **`-i`** is the path to the private key that you downloaded earlier. In this example, it's **~/.ssh/mySSHKey.pem**.
609+
1. Enter the following commands:
564610

565611
```bash
566-
ssh -i ~/.ssh/mySSHkey.pem [email protected]
612+
sudo apt-get update
613+
sudo apt-get install -y nginx
567614
```
615+
616+
1. Select **Run**.
617+
618+
1. Wait for the command to complete. The output pane displays **Enable succeeded** when complete.
619+
568620
# [Azure CLI](#tab/azurecli/)
569621

570-
Use [az network public-ip show](/cli/azure/network/public-ip#az-network-public-ip-show) to display the IP addresses of the virtual machine.
622+
### Create an inbound security rule
623+
624+
Use [az network nsg rule create](/cli/azure/network/nsg/rule#az-network-nsg-rule-create) to create a network security group rule to allow HTTP traffic.
571625

572626
```azurecli-interactive
573-
az network public-ip show \
627+
az network nsg rule create \
574628
--resource-group myResourceGroup \
575-
--name myPublicIP-IPv4 \
576-
--query ipAddress \
577-
--output tsv
629+
--nsg-name myNSG \
630+
--name myNSGRuleHTTP \
631+
--protocol '*' \
632+
--direction inbound \
633+
--source-address-prefix '*' \
634+
--source-port-range '*' \
635+
--destination-address-prefix '*' \
636+
--destination-port-range 80 \
637+
--access allow \
638+
--priority 100
578639
```
579640

641+
### Install nginx
642+
643+
Use [az vm run-command invoke](/cli/azure/vm/run-command#az-vm-run-command-invoke) to install nginx on the virtual machine.
644+
580645
```azurecli-interactive
581-
user@Azure:~$ az network public-ip show \
582-
> --resource-group myResourceGroup \
583-
> --name myPublicIP-IPv4 \
584-
> --query ipAddress \
585-
> --output tsv
586-
20.119.201.208
646+
az vm run-command invoke \
647+
--resource-group myResourceGroup \
648+
--name myVM \
649+
--command-id RunShellScript \
650+
--scripts "sudo apt-get update && sudo apt-get install -y nginx"
587651
```
588652

653+
# [Azure PowerShell](#tab/azurepowershell/)
654+
655+
### Create an inbound security rule
656+
657+
Use [Get-AzNetworkSecurityGroup](/powershell/module/az.network/get-aznetworksecuritygroup) and [Add-AzNetworkSecurityRuleConfig](/powershell/module/az.network/add-aznetworksecurityruleconfig) to create a network security group rule to allow HTTP traffic.
658+
659+
```azurepowershell-interactive
660+
## Place the network security group into a variable. ##
661+
$nsg = @{
662+
Name = 'myNSG'
663+
ResourceGroupName = 'myResourceGroup'
664+
}
665+
$nsgObj = Get-AzNetworkSecurityGroup @nsg
666+
667+
## Create the network security group rule. ##
668+
$nsgRule = @{
669+
Name = 'myNSGRuleHTTP'
670+
Protocol = '*'
671+
Direction = 'Inbound'
672+
Priority = 100
673+
SourceAddressPrefix = '*'
674+
SourcePortRange = '*'
675+
DestinationAddressPrefix = '*'
676+
DestinationPortRange = 80
677+
Access = 'Allow'
678+
}
679+
$nsgObj | Add-AzNetworkSecurityRuleConfig @nsgRule | Set-AzNetworkSecurityGroup
680+
```
681+
682+
### Install nginx
683+
684+
Use [Invoke-AzVMRunCommand](/powershell/module/az.compute/invoke-azvmruncommand) to install nginx on the virtual machine.
685+
686+
```azurepowershell-interactive
687+
$vm = @{
688+
ResourceGroupName = 'myResourceGroup'
689+
Name = 'myVM'
690+
CommandId = 'RunShellScript'
691+
ScriptString = 'sudo apt-get update && sudo apt-get install -y nginx'
692+
}
693+
Invoke-AzVMRunCommand @vm
694+
```
695+
696+
---
697+
698+
## Test dual-stack connectivity
699+
700+
Verify nginx is running by connecting to the public IPv4 address of the virtual machine.
701+
702+
# [Azure portal](#tab/azureportal)
703+
704+
1. In the search box at the top of the portal, enter **Public IP address**. Select **Public IP addresses** in the search results.
705+
706+
1. Select **myPublicIP-IPv4**.
707+
708+
1. Note the public IPv4 address in the **Overview** under **IP address**. In this example, it's **20.22.46.19**.
709+
710+
1. Open your web browser and browse to `http://20.22.46.19`. Replace the IP address with the public IPv4 address of your virtual machine.
711+
712+
1. The default nginx welcome page is displayed, confirming that the web server is running and accessible over IPv4.
713+
714+
# [Azure CLI](#tab/azurecli/)
715+
716+
Use [az network public-ip show](/cli/azure/network/public-ip#az-network-public-ip-show) to display the IP addresses of the virtual machine.
717+
589718
```azurecli-interactive
590719
az network public-ip show \
591720
--resource-group myResourceGroup \
592-
--name myPublicIP-IPv6 \
721+
--name myPublicIP-IPv4 \
593722
--query ipAddress \
594723
--output tsv
595724
```
596725
597-
```azurecli-interactive
598-
user@Azure:~$ az network public-ip show \
599-
> --resource-group myResourceGroup \
600-
> --name myPublicIP-IPv6 \
601-
> --query ipAddress \
602-
> --output tsv
603-
2603:1030:408:6::9d
604-
```
726+
Open your web browser and browse to the IPv4 address displayed. The default nginx welcome page confirms that the web server is running and accessible.
605727
606-
Open an SSH connection to the virtual machine by using the following command. Replace the IP address with the IP address of your virtual machine.
728+
Use the following command to display the IPv6 address:
607729
608730
```azurecli-interactive
609-
731+
az network public-ip show \
732+
--resource-group myResourceGroup \
733+
--name myPublicIP-IPv6 \
734+
--query ipAddress \
735+
--output tsv
610736
```
611737
612738
# [Azure PowerShell](#tab/azurepowershell/)
@@ -621,13 +747,9 @@ $ip4 = @{
621747
Get-AzPublicIPAddress @ip4 | select IpAddress
622748
```
623749
624-
```azurepowershell-interactive
625-
PS /home/user> Get-AzPublicIPAddress @ip4 | select IpAddress
750+
Open your web browser and browse to the IPv4 address displayed. The default nginx welcome page confirms that the web server is running and accessible.
626751
627-
IpAddress
628-
---------
629-
20.72.115.187
630-
```
752+
Use the following command to display the IPv6 address:
631753
632754
```azurepowershell-interactive
633755
$ip6 = @{
@@ -637,20 +759,6 @@ $ip6 = @{
637759
Get-AzPublicIPAddress @ip6 | select IpAddress
638760
```
639761
640-
```azurepowershell-interactive
641-
PS /home/user> Get-AzPublicIPAddress @ip6 | select IpAddress
642-
643-
IpAddress
644-
---------
645-
2603:1030:403:3::1ca
646-
```
647-
648-
Open an SSH connection to the virtual machine by using the following command. Replace the IP address with the IP address of your virtual machine.
649-
650-
```azurepowershell-interactive
651-
652-
```
653-
654762
---
655763
656764
## Clean up resources

0 commit comments

Comments
 (0)