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
By default, only SSH connections are opened when you create a Linux VM in Azure. Use [az vm open-port](/cli/azure/vm) to open TCP port 80 for use with the NGINX web server:
74
+
To see your VM in action, install the NGINX web server. Update your package sources and then install the latest NGINX package.
77
75
78
76
```azurecli-interactive
79
-
az vm open-port --port 80 --resource-group myResourceGroup --name myVM
80
-
```
81
-
82
-
## Connect to virtual machine
83
-
84
-
SSH to your VM as normal. Replace the IP address in the example with the public IP address of your VM as noted in the previous output:
To see your VM in action, install the NGINX web server. Update your package sources and then install the latest NGINX package.
86
+
By default, only SSH connections are opened when you create a Linux VM in Azure. Use [az vm open-port](/cli/azure/vm) to open TCP port 80 for use with the NGINX web server:
93
87
94
-
```bash
95
-
sudo apt-get -y update
96
-
sudo apt-get -y install nginx
88
+
```azurecli-interactive
89
+
az vm open-port --port 80 --resource-group myResourceGroup --name myVM
97
90
```
98
91
99
-
When done, type `exit` to leave the SSH session.
100
-
101
92
## View the web server in action
102
93
103
94
Use a web browser of your choice to view the default NGINX welcome page. Use the public IP address of your VM as the web address. The following example shows the default NGINX web site:
104
95
105
-

96
+

106
97
107
98
## Clean up resources
108
99
@@ -119,3 +110,5 @@ In this quickstart, you deployed a simple virtual machine, opened a network port
119
110
120
111
> [!div class="nextstepaction"]
121
112
> [Azure Linux virtual machine tutorials](./tutorial-manage-vm.md)
Copy file name to clipboardExpand all lines: articles/virtual-machines/linux/quick-create-powershell.md
+23-38Lines changed: 23 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ ms.service: virtual-machines
6
6
ms.collection: linux
7
7
ms.topic: quickstart
8
8
ms.workload: infrastructure
9
-
ms.date: 01/14/2022
9
+
ms.date: 06/01/2022
10
10
ms.author: cynthn
11
11
ms.custom: mvc, devx-track-azurepowershell,
12
12
---
@@ -31,27 +31,26 @@ To open the Cloud Shell, just select **Try it** from the upper right corner of a
31
31
Create an Azure resource group with [New-AzResourceGroup](/powershell/module/az.resources/new-azresourcegroup). A resource group is a logical container into which Azure resources are deployed and managed:
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.
39
+
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 be 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
40
42
41
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.
43
42
44
43
In this example, you create a VM named *myVM*, in *East US*, using the *Standard_B2s* VM size.
45
44
46
45
```azurepowershell-interactive
47
46
New-AzVm `
48
-
-ResourceGroupName "myResourceGroup" `
49
-
-Name "myVM" `
50
-
-Location "East US" `
51
-
-Image UbuntuLTS `
47
+
-ResourceGroupName 'myResourceGroup' `
48
+
-Name 'myVM' `
49
+
-Location 'East US' `
50
+
-Image Debian `
52
51
-size Standard_B2s `
53
52
-PublicIpAddressName myPubIP `
54
-
-OpenPorts 80,22 `
53
+
-OpenPorts 80 `
55
54
-GenerateSshKey `
56
55
-SshKeyName mySSHKey
57
56
```
@@ -63,55 +62,41 @@ Private key is saved to /home/user/.ssh/1234567891
63
62
Public key is saved to /home/user/.ssh/1234567891.pub
64
63
```
65
64
66
-
Make a note of the path to your private key to use later.
67
-
68
65
It will take a few minutes for your VM to be deployed. When the deployment is finished, move on to the next section.
69
66
67
+
## Install NGINX
70
68
71
-
## Connect to the VM
72
-
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.
74
-
75
-
```azurepowershell-interactive
76
-
chmod 600 ~/.ssh/1234567891
77
-
```
78
-
79
-
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:
69
+
To see your VM in action, install the NGINX web server.
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.
79
+
The `-ScriptString' parameter requires version `4.27.0` or later of the 'Az.Compute` module.
Use a web browser of your choice to view the default NGINX welcome page. Enter the public IP address of the VM as the web address. The public IP address can be found on the VM overview page or as part of the SSH connection string you used earlier.
90
+
Use a web browser of your choice to view the default NGINX welcome page. Enter the public IP address of the VM as the web address.

108
93
109
94
## Clean up resources
110
95
111
96
When no longer needed, you can use the [Remove-AzResourceGroup](/powershell/module/az.resources/remove-azresourcegroup) cmdlet to remove the resource group, VM, and all related resources:
0 commit comments