You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
> In this example, you open port 3389 to enable remote access to the Windows Server VM from the internet. However, opening port 3389 to the internet is not recommended to manage production workloads. For information about secure access to Azure VMs, see [What is Azure Bastion?](../../bastion/bastion-overview.md)
79
+
|**Public inbound ports**| Select **None**|
48
80
49
81
1. Select the **Networking** tab at the top of the page.
50
-
82
+
51
83
1. On the **Networking** page, enter or select the following values:
52
84
53
-
-**Virtual network**: Accept the default network name.
85
+
-**Virtual network**: Select **myVNet**.
54
86
-**Subnet**: Select **default** if not already selected.
55
-
-**Public IP**: Accept the default public IP configuration.
Use the following steps to create a resource group and a virtual machine.
93
+
Use the following steps to create a resource group, virtual network, and virtual machine.
66
94
67
95
### Create a resource group
68
96
69
97
The following command creates a resource group with [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup).
70
98
71
99
```azurepowershell-interactive
72
100
## Create resource group. ##
73
-
$rg =@{
101
+
$rg =@{
74
102
Name = 'myResourceGroup'
75
103
Location = 'eastus2'
76
104
}
77
105
New-AzResourceGroup @rg
106
+
```
107
+
108
+
### Create a virtual network and subnet
109
+
110
+
The following commands create a virtual network and subnet with [New-AzVirtualNetwork](/powershell/module/az.network/new-azvirtualnetwork) and [Add-AzVirtualNetworkSubnetConfig](/powershell/module/az.network/add-azvirtualnetworksubnetconfig).
The following command creates a Windows Server virtual machine with [New-AzVM](/powershell/module/az.compute/new-azvm). When prompted, provide a username and password to be used as the credentials for the virtual machine:
133
+
The following command creates a Linux virtual machine without a public IP address with [New-AzVM](/powershell/module/az.compute/new-azvm). The `-GenerateSshKey` parameter generates an SSH key pair for the VM:
83
134
84
135
```azurepowershell-interactive
85
136
## Create virtual machine. ##
86
137
$vm = @{
87
138
ResourceGroupName = 'myResourceGroup'
88
139
Location = 'East US 2'
89
140
Name = 'myVM'
90
-
PublicIpAddressName = 'myPublicIP'
141
+
Image = 'Ubuntu2204'
142
+
VirtualNetworkName = 'myVNet'
143
+
SubnetName = 'default'
144
+
PublicIpAddressName = ''
145
+
GenerateSshKey = $true
146
+
SshKeyName = 'mySSHKey'
91
147
}
92
148
New-AzVM @vm
93
149
```
94
150
95
151
# [Azure CLI](#tab/azurecli)
96
152
97
-
Use the following steps to create a resource group and a virtual machine.
153
+
Use the following steps to create a resource group, virtual network, and virtual machine.
98
154
99
155
### Create a resource group
100
156
101
157
The following command creates a resource group with [az group create](/cli/azure/group#az-group-create):
102
158
103
-
```azurecli
104
-
az group create --name myResourceGroup --location eastus2
159
+
```azurecli-interactive
160
+
az group create \
161
+
--name myResourceGroup \
162
+
--location eastus2
163
+
```
164
+
165
+
### Create a virtual network and subnet
166
+
167
+
The following command creates a virtual network and subnet with [az network vnet create](/cli/azure/network/vnet#az-network-vnet-create):
168
+
169
+
```azurecli-interactive
170
+
az network vnet create \
171
+
--name myVNet \
172
+
--resource-group myResourceGroup \
173
+
--location eastus2 \
174
+
--address-prefixes 10.0.0.0/16 \
175
+
--subnet-name default \
176
+
--subnet-prefixes 10.0.0.0/24
105
177
```
106
178
107
179
### Create a virtual machine
108
180
109
-
The following command creates a Windows Server virtual machine with [az vm create](/cli/azure/vm#az-vm-create). When prompted, provide a username and password to be used as the credentials for the virtual machine:
181
+
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