|
1 | 1 | --- |
2 | 2 | title: Create a VM with a static private IP address using the Azure portal, Azure PowerShell, or Azure CLI |
3 | 3 | description: Learn to create a virtual machine with a static private IP address using the Azure portal, Azure PowerShell, or Azure CLI. |
4 | | -ms.date: 02/19/2026 |
| 4 | +ms.date: 02/24/2026 |
5 | 5 | ms.author: mbender |
6 | 6 | author: mbender-ms |
7 | 7 | ms.service: azure-virtual-network |
@@ -90,6 +90,9 @@ When you create a virtual machine (VM), it's automatically assigned a private IP |
90 | 90 |
|
91 | 91 | 1. Select **Review + create**. Review the settings, and then select **Create**. |
92 | 92 |
|
| 93 | +> [!NOTE] |
| 94 | +> The virtual machine is created without a public IP address and with no public inbound ports. To connect to the virtual machine, use Azure Bastion. For more information, see [Quickstart: Deploy Azure Bastion with default settings](../../bastion/quickstart-host-portal.md). |
| 95 | +
|
93 | 96 | # [Azure PowerShell](#tab/azurepowershell) |
94 | 97 |
|
95 | 98 | Use the following steps to create a resource group, virtual network, and virtual machine. |
@@ -130,6 +133,23 @@ $vnet = @{ |
130 | 133 | New-AzVirtualNetwork @vnet |
131 | 134 | ``` |
132 | 135 |
|
| 136 | +### Create a network security group |
| 137 | + |
| 138 | +Create a network security group with [New-AzNetworkSecurityGroup](/powershell/module/az.network/new-aznetworksecuritygroup). The default rules in the network security group deny all inbound access from the internet. |
| 139 | + |
| 140 | +```azurepowershell-interactive |
| 141 | +## Create network security group. ## |
| 142 | +$nsg = @{ |
| 143 | + Name = 'myNSG' |
| 144 | + ResourceGroupName = 'myResourceGroup' |
| 145 | + Location = 'eastus2' |
| 146 | +} |
| 147 | +New-AzNetworkSecurityGroup @nsg |
| 148 | +``` |
| 149 | + |
| 150 | +> [!NOTE] |
| 151 | +> The default rules of the network security group block all inbound access from the internet, including SSH. To connect to the virtual machine, use Azure Bastion. For more information, see [Quickstart: Deploy Azure Bastion with default settings](../../bastion/quickstart-host-portal.md). |
| 152 | +
|
133 | 153 | ### Create a virtual machine |
134 | 154 |
|
135 | 155 | Create a credential object for the virtual machine with [Get-Credential](/powershell/module/microsoft.powershell.security/get-credential). Enter a username and password when prompted: |
@@ -185,6 +205,19 @@ az network vnet create \ |
185 | 205 | --subnet-prefixes 10.0.0.0/24 |
186 | 206 | ``` |
187 | 207 |
|
| 208 | +### Create a network security group |
| 209 | + |
| 210 | +Create a network security group with [az network nsg create](/cli/azure/network/nsg#az-network-nsg-create). The default rules in the network security group deny all inbound access from the internet. |
| 211 | + |
| 212 | +```azurecli-interactive |
| 213 | +az network nsg create \ |
| 214 | + --resource-group myResourceGroup \ |
| 215 | + --name myNSG |
| 216 | +``` |
| 217 | + |
| 218 | +> [!NOTE] |
| 219 | +> The default rules of the network security group block all inbound access from the internet, including SSH. To connect to the virtual machine, use Azure Bastion. For more information, see [Quickstart: Deploy Azure Bastion with default settings](../../bastion/quickstart-host-portal.md). |
| 220 | +
|
188 | 221 | ### Create a virtual machine |
189 | 222 |
|
190 | 223 | The following command creates a Linux virtual machine without a public IP address with [az vm create](/cli/azure/vm#az-vm-create). The `--generate-ssh-keys` parameter generates an SSH key pair for the VM: |
|
0 commit comments