Skip to content

Commit 3bd1d6a

Browse files
authored
Merge pull request #200034 from cynthn/93616
Pulling over 93616
2 parents 276b370 + e4039a3 commit 3bd1d6a

File tree

6 files changed

+40
-62
lines changed

6 files changed

+40
-62
lines changed
43.9 KB
Loading
Binary file not shown.
43.2 KB
Loading
Binary file not shown.

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

Lines changed: 17 additions & 24 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: 03/30/2021
9+
ms.date: 06/01/2022
1010
ms.author: cynthn
1111
ms.custom: mvc, seo-javascript-september2019, seo-javascript-october2019, seo-python-october2019, devx-track-azurecli, mode-api
1212
---
@@ -47,7 +47,7 @@ The following example creates a VM named *myVM* and adds a user account named *a
4747
az vm create \
4848
--resource-group myResourceGroup \
4949
--name myVM \
50-
--image UbuntuLTS \
50+
--image Debian \
5151
--admin-username azureuser \
5252
--generate-ssh-keys
5353
```
@@ -67,42 +67,33 @@ It takes a few minutes to create the VM and supporting resources. The following
6767
}
6868
```
6969

70-
Note your own `publicIpAddress` in the output from your VM. This address is used to access the VM in the next steps.
70+
Make a note of the `publicIpAddress` to use later.
7171

72-
[!INCLUDE [ephemeral-ip-note.md](../../../includes/ephemeral-ip-note.md)]
73-
74-
## Open port 80 for web traffic
72+
## Install web server
7573

76-
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.
7775

7876
```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:
85-
86-
```bash
87-
77+
az vm run-command invoke \
78+
-g myResourceGroup \
79+
-n myVM \
80+
--command-id RunShellScript \
81+
--scripts "sudo apt-get update && sudo apt-get install -y nginx"
8882
```
8983

90-
## Install web server
84+
## Open port 80 for web traffic
9185

92-
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:
9387

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
9790
```
9891

99-
When done, type `exit` to leave the SSH session.
100-
10192
## View the web server in action
10293

10394
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:
10495

105-
![View the NGINX welcome page](./media/quick-create-cli/view-the-nginx-welcome-page.png)
96+
![Screenshot showing the N G I N X default web page.](./media/quick-create-cli/nginix-welcome-page-debian.png)
10697

10798
## Clean up resources
10899

@@ -119,3 +110,5 @@ In this quickstart, you deployed a simple virtual machine, opened a network port
119110

120111
> [!div class="nextstepaction"]
121112
> [Azure Linux virtual machine tutorials](./tutorial-manage-vm.md)
113+
114+

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

Lines changed: 23 additions & 38 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: 01/14/2022
9+
ms.date: 06/01/2022
1010
ms.author: cynthn
1111
ms.custom: mvc, devx-track-azurepowershell,
1212
---
@@ -31,27 +31,26 @@ To open the Cloud Shell, just select **Try it** from the upper right corner of a
3131
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:
3232

3333
```azurepowershell-interactive
34-
New-AzResourceGroup -Name "myResourceGroup" -Location "EastUS"
34+
New-AzResourceGroup -Name 'myResourceGroup' -Location 'EastUS'
3535
```
3636

37-
3837
## Create a virtual machine
3938

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.
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.
4140

4241
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.
4342

4443
In this example, you create a VM named *myVM*, in *East US*, using the *Standard_B2s* VM size.
4544

4645
```azurepowershell-interactive
4746
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 `
5251
-size Standard_B2s `
5352
-PublicIpAddressName myPubIP `
54-
-OpenPorts 80,22 `
53+
-OpenPorts 80 `
5554
-GenerateSshKey `
5655
-SshKeyName mySSHKey
5756
```
@@ -63,55 +62,41 @@ Private key is saved to /home/user/.ssh/1234567891
6362
Public key is saved to /home/user/.ssh/1234567891.pub
6463
```
6564

66-
Make a note of the path to your private key to use later.
67-
6865
It will take a few minutes for your VM to be deployed. When the deployment is finished, move on to the next section.
6966

67+
## Install NGINX
7068

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.
8070

8171
```azurepowershell-interactive
82-
Get-AzPublicIpAddress -ResourceGroupName "myResourceGroup" | Select "IpAddress"
72+
Invoke-AzVMRunCommand `
73+
-ResourceGroupName 'myResourceGroup' `
74+
-Name 'myVM' `
75+
-CommandId 'RunShellScript' `
76+
-ScriptString 'sudo apt-get update && sudo apt-get install -y nginx'
8377
```
8478

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.
79+
The `-ScriptString' parameter requires version `4.27.0` or later of the 'Az.Compute` module.
8680

87-
```bash
88-
ssh -i ~/.ssh/1234567891 [email protected]
89-
```
9081

91-
## Install NGINX
82+
## View the web server in action
9283

93-
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.
84+
Get the public IP address of your VM:
9485

95-
```bash
96-
sudo apt-get -y update
97-
sudo apt-get -y install nginx
86+
```azurepowershell-interactive
87+
Get-AzPublicIpAddress -Name myPubIP -ResourceGroupName myResourceGroup | select "IpAddress"
9888
```
9989

100-
When done, type `exit` to leave the SSH session.
101-
102-
103-
## View the web server in action
104-
105-
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.
10691

107-
![NGINX default Welcome page](./media/quick-create-cli/nginix-welcome-page.png)
92+
![Screenshot showing the N G I N X default web page.](./media/quick-create-cli/nginix-welcome-page-debian.png)
10893

10994
## Clean up resources
11095

11196
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:
11297

11398
```azurepowershell-interactive
114-
Remove-AzResourceGroup -Name "myResourceGroup"
99+
Remove-AzResourceGroup -Name 'myResourceGroup'
115100
```
116101

117102
## Next steps

0 commit comments

Comments
 (0)