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
|**Image**| Select **Ubuntu Server 22.04 LTS - x64 Gen2**|
59
76
|**Size**| Accept the default, or drop down and select a size |
60
-
|**Username**| Enter an admin username for the VM |
61
-
|**Password**| Enter a password for the VM |
62
-
|**Confirm password**| Confirm the password for the VM |
77
+
|**Authentication type**| Select **SSH public key**|
78
+
|**Username**| Enter *azureuser*|
79
+
|**SSH public key source**| Select **Generate new key pair**|
80
+
|**Key pair name**| Enter *mySSHKey*|
63
81
|**Public inbound ports**| Select **None**|
64
82
65
-
> [!NOTE]
66
-
> All public inbound ports are closed for this virtual machine. To manage your virtual machines, deploy Azure Bastion. For more information, see [Quickstart: Deploy Azure Bastion from the Azure portal](../../bastion/quickstart-host-portal.md).
67
-
68
83
1. Select the **Networking** tab at the top of the page.
69
84
70
85
1. On the **Networking** page, enter or select the following values:
71
86
72
-
-**Virtual network**: Accept the default network name.
87
+
-**Virtual network**: Select **myVNet**.
73
88
-**Subnet**: Select **default** if not already selected.
74
89
-**Public IP**: Select **None**.
75
90
76
91
1. Select **Review + create**. Review the settings, and then select **Create**.
77
92
78
93
# [Azure PowerShell](#tab/azurepowershell)
79
94
80
-
Use the following steps to create a resource group and a virtual machine.
95
+
Use the following steps to create a resource group, virtual network, and virtual machine.
81
96
82
-
## Create a resource group
97
+
###Create a resource group
83
98
84
99
The following command creates a resource group with [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup).
85
100
@@ -92,7 +107,30 @@ $rg = @{
92
107
New-AzResourceGroup @rg
93
108
```
94
109
95
-
## Create a network security group
110
+
### Create a virtual network and subnet
111
+
112
+
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).
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.
98
136
@@ -106,38 +144,38 @@ $nsg = @{
106
144
New-AzNetworkSecurityGroup @nsg
107
145
```
108
146
109
-
> [!NOTE]
110
-
> All public inbound ports are closed for this virtual machine. To manage your virtual machines, deploy Azure Bastion. For more information, see [Quickstart: Deploy Azure Bastion from the Azure portal](/azure/bastion/quickstart-host-portal).
111
-
112
-
## Create a virtual machine
147
+
### Create a virtual machine
113
148
114
-
Create a virtual machine with [New-AzVM](/powershell/module/az.compute/new-azvm). When prompted, enter the username and password for the virtual machine.
149
+
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:
115
150
116
151
```azurepowershell-interactive
117
-
# Create a credential object
118
152
$cred = Get-Credential
153
+
```
119
154
120
-
# Define the virtual machine parameters
121
-
$vmParams = @{
155
+
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:
156
+
157
+
```azurepowershell-interactive
158
+
## Create virtual machine. ##
159
+
$vm = @{
122
160
ResourceGroupName = 'myResourceGroup'
123
-
Location = 'EastUS2'
161
+
Location = 'East US 2'
124
162
Name = 'myVM'
125
-
Image = 'Win2022AzureEditionCore'
126
-
Size = 'Standard_DS1_v2'
163
+
Image = 'Ubuntu2204'
127
164
Credential = $cred
128
-
SecurityGroupName = 'myNSG'
165
+
VirtualNetworkName = 'myVNet'
166
+
SubnetName = 'default'
129
167
PublicIpAddressName = ''
168
+
GenerateSshKey = $true
169
+
SshKeyName = 'mySSHKey'
130
170
}
131
-
132
-
# Create the virtual machine
133
-
New-AzVM @vmParams
171
+
New-AzVM @vm
134
172
```
135
173
136
174
# [Azure CLI](#tab/azurecli)
137
175
138
-
Use the following steps to create a resource group and a virtual machine.
176
+
Use the following steps to create a resource group, virtual network, and virtual machine.
139
177
140
-
## Create a resource group
178
+
###Create a resource group
141
179
142
180
The following command creates a resource group with [az group create](/cli/azure/group#az-group-create):
143
181
@@ -147,7 +185,21 @@ az group create \
147
185
--location eastus2
148
186
```
149
187
150
-
## Create a network security group
188
+
### Create a virtual network and subnet
189
+
190
+
The following command creates a virtual network and subnet with [az network vnet create](/cli/azure/network/vnet#az-network-vnet-create):
191
+
192
+
```azurecli-interactive
193
+
az network vnet create \
194
+
--name myVNet \
195
+
--resource-group myResourceGroup \
196
+
--location eastus2 \
197
+
--address-prefixes 10.0.0.0/16 \
198
+
--subnet-name default \
199
+
--subnet-prefixes 10.0.0.0/24
200
+
```
201
+
202
+
### Create a network security group
151
203
152
204
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.
153
205
@@ -157,23 +209,21 @@ az network nsg create \
157
209
--name myNSG
158
210
```
159
211
160
-
> [!NOTE]
161
-
> All public inbound ports are closed for this virtual machine. To manage your virtual machines, deploy Azure Bastion. For more information, see [Quickstart: Deploy Azure Bastion from the Azure portal](/azure/bastion/quickstart-host-portal).
212
+
### Create a virtual machine
162
213
163
-
## Create a virtual machine
164
-
165
-
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:
214
+
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