Skip to content

Commit e29a1f1

Browse files
authored
Merge pull request #183988 from cynthn/lin-quick
Quickstarts
2 parents 633768b + 9744a19 commit e29a1f1

File tree

4 files changed

+37
-134
lines changed

4 files changed

+37
-134
lines changed
0 Bytes
Loading

articles/virtual-machines/linux/quick-create-portal.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ ms.service: virtual-machines
66
ms.collection: linux
77
ms.topic: quickstart
88
ms.workload: infrastructure
9-
ms.date: 06/25/2020
9+
ms.date: 12/13/2021
1010
ms.author: cynthn
1111
ms.custom: mvc, mode-ui
1212
---
@@ -21,20 +21,22 @@ If you don't have an Azure subscription, create a [free account](https://azure.m
2121

2222
## Sign in to Azure
2323

24-
Sign in to the [Azure portal](https://portal.azure.com) if you haven't already.
24+
Sign in to the [Azure portal](https://portal.azure.com).
2525

2626
## Create virtual machine
2727

2828
1. Type **virtual machines** in the search.
2929
1. Under **Services**, select **Virtual machines**.
30-
1. In the **Virtual machines** page, select **Add**. The **Create a virtual machine** page opens.
30+
1. In the **Virtual machines** page, select **Create** and then **Virtual machine**. The **Create a virtual machine** page opens.
31+
3132
1. In the **Basics** tab, under **Project details**, make sure the correct subscription is selected and then choose to **Create new** resource group. Type *myResourceGroup* for the name.*.
3233

3334
![Screenshot of the Project details section showing where you select the Azure subscription and the resource group for the virtual machine](./media/quick-create-portal/project-details.png)
3435

35-
1. Under **Instance details**, type *myVM* for the **Virtual machine name**, choose *East US* for your **Region**, and choose *Ubuntu 18.04 LTS* for your **Image**. Leave the other defaults.
36+
1. Under **Instance details**, type *myVM* for the **Virtual machine name**, and choose *Ubuntu 18.04 LTS - Gen2* for your **Image**. Leave the other defaults. The default size and pricing is only shown as an example. Size availability and pricing is dependent on your region and subscription.
37+
38+
:::image type="content" source="media/quick-create-portal/instance-details.png" alt-text="Screenshot of the Instance details section where you provide a name for the virtual machine and select its region, image, and size.":::
3639

37-
![Screenshot of the Instance details section where you provide a name for the virtual machine and select its region, image and size](./media/quick-create-portal/instance-details.png)
3840

3941
1. Under **Administrator account**, select **SSH public key**.
4042

articles/virtual-machines/linux/quick-create-powershell.md

Lines changed: 28 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ ms.service: virtual-machines
66
ms.collection: linux
77
ms.topic: quickstart
88
ms.workload: infrastructure
9-
ms.date: 07/31/2020
9+
ms.date: 01/14/2022
1010
ms.author: cynthn
11-
ms.custom: mvc, devx-track-azurepowershell, mode-api
11+
ms.custom: mvc, devx-track-azurepowershell,
1212
---
1313

1414
# Quickstart: Create a Linux virtual machine in Azure with PowerShell
@@ -25,20 +25,6 @@ The Azure Cloud Shell is a free interactive shell that you can use to run the st
2525

2626
To open the Cloud Shell, just select **Try it** from the upper right corner of a code block. Select **Copy** to copy the blocks of code, paste it into the Cloud Shell, and press enter to run it.
2727

28-
## Create SSH key pair
29-
30-
Use [ssh-keygen](https://www.ssh.com/ssh/keygen/) to create an SSH key pair. If you already have an SSH key pair, you can skip this step.
31-
32-
33-
```azurepowershell-interactive
34-
ssh-keygen -t rsa -b 4096
35-
```
36-
37-
You will be prompted to provide a filename for the key pair or you can hit **Enter** to use the default location of `/home/<username>/.ssh/id_rsa`. You will also be able to create a password for the keys, if you like.
38-
39-
For more detailed information on how to create SSH key pairs, see [How to use SSH keys with Windows](ssh-from-windows.md).
40-
41-
If you create your SSH key pair using the Cloud Shell, it will be stored in a [storage account that is automatically created by Cloud Shell](../../cloud-shell/persisting-shell-storage.md). Don't delete the storage account, or the files share in it, until after you have retrieved your keys or you will lose access to the VM.
4228

4329
## Create a resource group
4430

@@ -48,146 +34,60 @@ Create an Azure resource group with [New-AzResourceGroup](/powershell/module/az.
4834
New-AzResourceGroup -Name "myResourceGroup" -Location "EastUS"
4935
```
5036

51-
## Create virtual network resources
5237

53-
Create a virtual network, subnet, and a public IP address. These resources are used to provide network connectivity to the VM and connect it to the internet:
38+
## Create a virtual machine
5439

55-
```azurepowershell-interactive
56-
# Create a subnet configuration
57-
$subnetConfig = New-AzVirtualNetworkSubnetConfig `
58-
-Name "mySubnet" `
59-
-AddressPrefix 192.168.1.0/24
60-
61-
# Create a virtual network
62-
$vnet = New-AzVirtualNetwork `
63-
-ResourceGroupName "myResourceGroup" `
64-
-Location "EastUS" `
65-
-Name "myVNET" `
66-
-AddressPrefix 192.168.0.0/16 `
67-
-Subnet $subnetConfig
68-
69-
# Create a public IP address and specify a DNS name
70-
$pip = New-AzPublicIpAddress `
71-
-ResourceGroupName "myResourceGroup" `
72-
-Location "EastUS" `
73-
-AllocationMethod Static `
74-
-IdleTimeoutInMinutes 4 `
75-
-Name "mypublicdns$(Get-Random)"
76-
```
40+
We will be automatically generating an SSH key pair to use for connecting to the VM. The public key that is created using `-GenerateSshKey` will be stored in Azure as a resource, using the name you provide as `SshKeyName`. The SSH key resource can be reused for creating additional VMs. Both the public and private keys will also downloaded for you. When you create your SSH key pair using the Cloud Shell, the keys are stored in a [storage account that is automatically created by Cloud Shell](../../cloud-shell/persisting-shell-storage.md). Don't delete the storage account, or the file share in it, until after you have retrieved your keys or you will lose access to the VM.
41+
42+
You will be prompted for a user name that will be used when you connect to the VM. You will also be asked for a password, which you can leave blank. Password login for the VM is disabled when using an SSH key.
7743

78-
Create an Azure Network Security Group and traffic rule. The Network Security Group secures the VM with inbound and outbound rules. In the following example, an inbound rule is created for TCP port 22 that allows SSH connections. To allow incoming web traffic, an inbound rule for TCP port 80 is also created.
44+
In this example, you create a VM named *myVM*, in *East US*, using the *Standard_B2s* VM size.
7945

8046
```azurepowershell-interactive
81-
# Create an inbound network security group rule for port 22
82-
$nsgRuleSSH = New-AzNetworkSecurityRuleConfig `
83-
-Name "myNetworkSecurityGroupRuleSSH" `
84-
-Protocol "Tcp" `
85-
-Direction "Inbound" `
86-
-Priority 1000 `
87-
-SourceAddressPrefix * `
88-
-SourcePortRange * `
89-
-DestinationAddressPrefix * `
90-
-DestinationPortRange 22 `
91-
-Access "Allow"
92-
93-
# Create an inbound network security group rule for port 80
94-
$nsgRuleWeb = New-AzNetworkSecurityRuleConfig `
95-
-Name "myNetworkSecurityGroupRuleWWW" `
96-
-Protocol "Tcp" `
97-
-Direction "Inbound" `
98-
-Priority 1001 `
99-
-SourceAddressPrefix * `
100-
-SourcePortRange * `
101-
-DestinationAddressPrefix * `
102-
-DestinationPortRange 80 `
103-
-Access "Allow"
104-
105-
# Create a network security group
106-
$nsg = New-AzNetworkSecurityGroup `
107-
-ResourceGroupName "myResourceGroup" `
108-
-Location "EastUS" `
109-
-Name "myNetworkSecurityGroup" `
110-
-SecurityRules $nsgRuleSSH,$nsgRuleWeb
47+
New-AzVm `
48+
-ResourceGroupName "myResourceGroup" `
49+
-Name "myVM" `
50+
-Location "East US" `
51+
-Image UbuntuLTS `
52+
-size Standard_B2s `
53+
-PublicIpAddressName myPubIP `
54+
-OpenPorts 80,22 `
55+
-GenerateSshKey `
56+
-SshKeyName mySSHKey
11157
```
11258

113-
Create a virtual network interface card (NIC) with [New-AzNetworkInterface](/powershell/module/az.network/new-aznetworkinterface). The virtual NIC connects the VM to a subnet, Network Security Group, and public IP address.
59+
The output will give you the location of the local copy of the SSH key. For example:
11460

115-
```azurepowershell-interactive
116-
# Create a virtual network card and associate with public IP address and NSG
117-
$nic = New-AzNetworkInterface `
118-
-Name "myNic" `
119-
-ResourceGroupName "myResourceGroup" `
120-
-Location "EastUS" `
121-
-SubnetId $vnet.Subnets[0].Id `
122-
-PublicIpAddressId $pip.Id `
123-
-NetworkSecurityGroupId $nsg.Id
61+
```output
62+
Private key is saved to /home/user/.ssh/1234567891
63+
Public key is saved to /home/user/.ssh/1234567891.pub
12464
```
12565

126-
## Create a virtual machine
66+
Make a note of the path to your private key to use later.
12767

128-
To create a VM in PowerShell, you create a configuration that has settings like the image to use, size, and authentication options. Then the configuration is used to build the VM.
68+
It will take a few minutes for your VM to be deployed. When the deployment is finished, move on to the next section.
12969

130-
Define the SSH credentials, OS information, and VM size. In this example, the SSH key is stored in `~/.ssh/id_rsa.pub`.
13170

132-
```azurepowershell-interactive
133-
# Define a credential object
134-
$securePassword = ConvertTo-SecureString ' ' -AsPlainText -Force
135-
$cred = New-Object System.Management.Automation.PSCredential ("azureuser", $securePassword)
136-
137-
# Create a virtual machine configuration
138-
$vmConfig = New-AzVMConfig `
139-
-VMName "myVM" `
140-
-VMSize "Standard_D1_v2" | `
141-
Set-AzVMOperatingSystem `
142-
-Linux `
143-
-ComputerName "myVM" `
144-
-Credential $cred `
145-
-DisablePasswordAuthentication | `
146-
Set-AzVMSourceImage `
147-
-PublisherName "Canonical" `
148-
-Offer "UbuntuServer" `
149-
-Skus "18.04-LTS" `
150-
-Version "latest" | `
151-
Add-AzVMNetworkInterface `
152-
-Id $nic.Id
153-
154-
# Configure the SSH key
155-
$sshPublicKey = cat ~/.ssh/id_rsa.pub
156-
Add-AzVMSshPublicKey `
157-
-VM $vmconfig `
158-
-KeyData $sshPublicKey `
159-
-Path "/home/azureuser/.ssh/authorized_keys"
160-
```
71+
## Connect to the VM
16172

162-
Now, combine the previous configuration definitions to create with [New-AzVM](/powershell/module/az.compute/new-azvm):
73+
You need to change the permission on the SSH key using `chmod`. Replace *~/.ssh/1234567891* in the following example with the private key name and path from the earlier output.
16374

16475
```azurepowershell-interactive
165-
New-AzVM `
166-
-ResourceGroupName "myResourceGroup" `
167-
-Location eastus -VM $vmConfig
76+
chmod 600 ~/.ssh/1234567891
16877
```
16978

170-
It will take a few minutes for your VM to be deployed. When the deployment is finished, move on to the next section.
171-
172-
[!INCLUDE [ephemeral-ip-note.md](../../../includes/ephemeral-ip-note.md)]
173-
174-
## Connect to the VM
175-
17679
Create an SSH connection with the VM using the public IP address. To see the public IP address of the VM, use the [Get-AzPublicIpAddress](/powershell/module/az.network/get-azpublicipaddress) cmdlet:
17780

17881
```azurepowershell-interactive
17982
Get-AzPublicIpAddress -ResourceGroupName "myResourceGroup" | Select "IpAddress"
18083
```
18184

182-
Using the same shell you used to create your SSH key pair, paste the the following command into the shell to create an SSH session. Replace *10.111.12.123* with the IP address of your VM.
85+
Using the same shell you used to create your SSH key pair, paste the the following command into the shell to create an SSH session. Replace *~/.ssh/1234567891* in the following example with the private key name and path from the earlier output. Replace *10.111.12.123* with the IP address of your VM and *azureuser* with the name you provided when you created the VM.
18386

18487
```bash
185-
88+
ssh -i ~/.ssh/1234567891 [email protected]
18689
```
18790

188-
When prompted, the login user name is *azureuser*. If a passphrase is used with your SSH keys, you need to enter that when prompted.
189-
190-
19191
## Install NGINX
19292

19393
To see your VM in action, install the NGINX web server. From your SSH session, update your package sources and then install the latest NGINX package.

articles/virtual-machines/windows/quick-create-portal.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ Sign in to the Azure portal at https://portal.azure.com.
2727

2828
1. Type **virtual machines** in the search.
2929
1. Under **Services**, select **Virtual machines**.
30-
1. In the **Virtual machines** page, select **Create** then **Virtual machine**.
30+
1. In the **Virtual machines** page, select **Create** and then **Virtual machine**. The **Create a virtual machine** page opens.
31+
3132
1. In the **Basics** tab, under **Project details**, make sure the correct subscription is selected and then choose to **Create new** resource group. Type *myResourceGroup* for the name.
3233

3334
![Screenshot of the Project details section showing where you select the Azure subscription and the resource group for the virtual machine](./media/quick-create-portal/project-details.png)

0 commit comments

Comments
 (0)