Skip to content

Commit 8b4c36c

Browse files
Merge pull request #269398 from rayoef/update-linux-vm-exec-doc
Added context that was removed in previous update
2 parents eca7dd7 + c4f9ee5 commit 8b4c36c

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

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

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,37 @@
11
---
22
title: 'Quickstart: Use the Azure CLI to create a Linux Virtual Machine'
3-
description: Create a Linux virtual machine using the Azure CLI.
3+
description: In this quickstart, you learn how to use the Azure CLI to create a Linux virtual machine
44
author: chasecrum
55
ms.service: virtual-machines
66
ms.collection: linux
77
ms.topic: quickstart
88
ms.date: 02/28/2024
9-
ms.author: chasecrum
9+
ms.author: jushiman
1010
ms.reviewer: jushiman
1111
ms.custom: mvc, devx-track-azurecli, mode-api, innovation-engine, linux-related-content
1212
---
1313

14-
# Create a Linux virtual machine on Azure
14+
# Quickstart: Create a Linux virtual machine with the Azure CLI on Azure
15+
16+
**Applies to:** :heavy_check_mark: Linux VMs
1517

1618
[![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/?Microsoft_Azure_CloudNative_clientoptimizations=false&feature.canmodifyextensions=true#view/Microsoft_Azure_CloudNative/SubscriptionSelectionPage.ReactView/tutorialKey/CreateLinuxVMAndSSH)
1719

20+
This quickstart shows you how to use the Azure CLI to deploy a Linux virtual machine (VM) in Azure. The Azure CLI is used to create and manage Azure resources via either the command line or scripts.
21+
22+
If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F) before you begin.
23+
24+
## Launch Azure Cloud Shell
25+
26+
The Azure Cloud Shell is a free interactive shell that you can use to run the steps in this article. It has common Azure tools preinstalled and configured to use with your account.
27+
28+
To open the Cloud Shell, just select **Try it** from the upper right corner of a code block. You can also open Cloud Shell in a separate browser tab by going to [https://shell.azure.com/bash](https://shell.azure.com/bash). Select **Copy** to copy the blocks of code, paste it into the Cloud Shell, and select **Enter** to run it.
29+
30+
If you prefer to install and use the CLI locally, this quickstart requires Azure CLI version 2.0.30 or later. Run `az --version` to find the version. If you need to install or upgrade, see [Install Azure CLI]( /cli/azure/install-azure-cli).
31+
1832
## Define environment variables
1933

20-
The First step is to define the environment variables.
34+
The first step is to define the environment variables. Environment variables are commonly used in Linux to centralize configuration data to improve consistency and maintainability of the system. Create the following environment variables to specify the names of resources that you create later in this tutorial:
2135

2236
```bash
2337
export RANDOM_ID="$(openssl rand -hex 3)"
@@ -30,11 +44,11 @@ export MY_VM_IMAGE="Canonical:0001-com-ubuntu-minimal-jammy:minimal-22_04-lts-ge
3044

3145
## Log in to Azure using the CLI
3246

33-
In order to run commands in Azure using the CLI, you need to log in first. This is done using the `az login` command.
47+
In order to run commands in Azure using the CLI, you need to log in first. Log in using the `az login` command.
3448

3549
## Create a resource group
3650

37-
A resource group is a container for related resources. All resources must be placed in a resource group. The following command creates a resource group with the previously defined $MY_RESOURCE_GROUP_NAME and $REGION parameters.
51+
A resource group is a container for related resources. All resources must be placed in a resource group. The [az group create](/cli/azure/group) command creates a resource group with the previously defined $MY_RESOURCE_GROUP_NAME and $REGION parameters.
3852

3953
```bash
4054
az group create --name $MY_RESOURCE_GROUP_NAME --location $REGION
@@ -59,7 +73,9 @@ Results:
5973

6074
## Create the virtual machine
6175

62-
To create a VM in this resource group, we need to use the `vm create` command. In the following code example, we provided the `--generate-ssh-keys` flag, which causes the CLI to look for an available ssh key in `~/.ssh`. If one is found, it is used. If not, one is generated and stored in `~/.ssh`. We also provide the `--public-ip-sku Standard` flag to ensure that the machine is accessible via a public IP address. Finally, we deploy the latest `Ubuntu 22.04` image.
76+
To create a VM in this resource group, use the `vm create` command.
77+
78+
The following example creates a VM and adds a user account. The `--generate-ssh-keys` parameter causes the CLI to look for an available ssh key in `~/.ssh`. If one is found, that key is used. If not, one is generated and stored in `~/.ssh`. The `--public-ip-sku Standard` parameter ensures that the machine is accessible via a public IP address. Finally, we deploy the latest `Ubuntu 22.04` image.
6379

6480
All other values are configured using environment variables.
6581

@@ -74,7 +90,7 @@ az vm create \
7490
--public-ip-sku Standard
7591
```
7692

77-
Results:
93+
It takes a few minutes to create the VM and supporting resources. The following example output shows the VM create operation was successful.
7894

7995
<!-- expected_similarity=0.3 -->
8096
```json
@@ -105,7 +121,7 @@ az vm extension set \
105121

106122
## Store IP address of VM in order to SSH
107123

108-
Run the following command to store the IP Address of the VM as an environment variable:
124+
Run the following command to store the IP address of the VM as an environment variable:
109125

110126
```bash
111127
export IP_ADDRESS=$(az vm show --show-details --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_VM_NAME --query publicIps --output tsv)

0 commit comments

Comments
 (0)