Skip to content

Commit e15d741

Browse files
author
naman-msft
committed
updating the tools folder
1 parent 01a78c5 commit e15d741

File tree

13 files changed

+589
-594
lines changed

13 files changed

+589
-594
lines changed
Lines changed: 45 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,42 @@
11
---
2-
title: 'Quickstart: Create a Linux VM and SSH into it'
3-
description: Learn how to create a Linux virtual machine in Azure and SSH into it using Azure CLI commands within an Exec Doc.
2+
title: Quickstart: Create a Linux VM and SSH into it using Azure CLI
3+
description: Learn how to create a Linux virtual machine on Azure and connect to it using SSH with pre-generated SSH keys. This Exec Doc demonstrates deploying the VM in a uniquely named resource group, retrieving its public IP address, and providing the SSH command to connect.
44
ms.topic: quickstart
5-
ms.date: 10/12/2023
6-
author: azureuser123
7-
ms.author: azureuser123
8-
ms.custom: innovation-engine, azurecli, linux-related-content
5+
ms.date: 10/07/2023
6+
author: chatgpt
7+
ms.author: chatgpt
8+
ms.custom: innovation-engine, azurecli, linux-vm
99
---
1010

11-
In this Exec Doc, you will learn how to create a Linux virtual machine (VM) in Azure using the Azure CLI and then SSH into the newly created VM. All commands have been configured to run non-interactively. Remember to update any variables if necessary and note that resources are appended with a random suffix to avoid naming conflicts in subsequent runs.
11+
# Quickstart: Create a Linux VM and SSH into it using Azure CLI
1212

13-
## Step 1: Set Environment Variables
13+
This Exec Doc walks you through deploying a Linux virtual machine (VM) on Azure using the Azure CLI. The VM is deployed in a new resource group with a random suffix to ensure uniqueness. Once the VM is created, the public IP is retrieved and an SSH command is provided so you can connect to the VM.
1414

15-
In this step, we declare the environment variables that will be used throughout the Exec Doc. A random suffix is appended to the resource group and VM names to ensure uniqueness.
15+
## Step 1: Set Environment Variables and Create a Resource Group
16+
17+
In this step, we declare environment variables that will be used throughout the Exec Doc. We generate random suffixes to ensure that resource names are unique between successive runs.
1618

1719
```bash
1820
export RANDOM_SUFFIX=$(openssl rand -hex 3)
19-
export REGION="WestUS2"
20-
export MY_RESOURCE_GROUP_NAME="MyResourceGroup$RANDOM_SUFFIX"
21-
export MY_VM_NAME="MyLinuxVM$RANDOM_SUFFIX"
21+
export RESOURCE_GROUP="MyResourceGroup$RANDOM_SUFFIX"
22+
export REGION="centralindia"
2223
```
2324

24-
## Step 2: Create a Resource Group
25-
26-
This step creates a new resource group in the specified region.
25+
Next, we create a resource group in the specified region.
2726

2827
```bash
29-
az group create --name $MY_RESOURCE_GROUP_NAME --location $REGION
28+
az group create --name $RESOURCE_GROUP --location $REGION
3029
```
3130

32-
Results:
31+
Results:
3332

3433
<!-- expected_similarity=0.3 -->
35-
3634
```JSON
3735
{
38-
"id": "/subscriptions/xxxxx-xxxxx-xxxxx-xxxxx/resourceGroups/MyResourceGroupxxxxx",
39-
"location": "WestUS2",
36+
"id": "/subscriptions/xxxxx-xxxxx-xxxxx-xxxxx/resourceGroups/MyResourceGroupxxx",
37+
"location": "centralindia",
4038
"managedBy": null,
41-
"name": "MyResourceGroupxxxxx",
39+
"name": "MyResourceGroupxxx",
4240
"properties": {
4341
"provisioningState": "Succeeded"
4442
},
@@ -47,46 +45,54 @@ Results:
4745
}
4846
```
4947

50-
## Step 3: Create a Linux Virtual Machine
48+
## Step 2: Create the Linux Virtual Machine
5149

52-
Now you will create a Linux VM using the Ubuntu LTS image. The command includes the generation of SSH keys if they do not already exist. The default administrator username is set to "azureuser".
50+
Now that the resource group is ready, we create a Linux VM. In this example, the VM is created with an Ubuntu 22.04 image, which is a valid image name. A default administrator username is provided and SSH keys are generated automatically if they do not exist in your environment.
5351

5452
```bash
55-
az vm create --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_VM_NAME --image UbuntuLTS --admin-username azureuser --generate-ssh-keys
53+
export VM_NAME="LinuxVm$RANDOM_SUFFIX"
54+
az vm create --resource-group $RESOURCE_GROUP --name $VM_NAME --image Ubuntu2204 --admin-username azureuser --generate-ssh-keys
5655
```
5756

58-
Results:
57+
Results:
5958

6059
<!-- expected_similarity=0.3 -->
61-
6260
```JSON
6361
{
6462
"fqdns": "",
65-
"id": "/subscriptions/xxxxx-xxxxx-xxxxx-xxxxx/resourceGroups/MyResourceGroupxxxxx/providers/Microsoft.Compute/virtualMachines/MyLinuxVMxxxxx",
66-
"location": "WestUS2",
67-
"name": "MyLinuxVMxxxxx",
63+
"id": "/subscriptions/xxxxx-xxxxx-xxxxx-xxxxx/resourceGroups/MyResourceGroupxxx/providers/Microsoft.Compute/virtualMachines/LinuxVmxxx",
64+
"location": "centralindia",
65+
"macAddress": "...",
6866
"powerState": "VM running",
6967
"privateIpAddress": "10.0.0.4",
70-
"publicIpAddress": "52.xxx.xxx.xxx"
68+
"publicIpAddress": "xx.xx.xx.xx",
69+
"resourceGroup": "MyResourceGroupxxx",
70+
"zones": ""
7171
}
7272
```
7373

74-
## Step 4: Retrieve the VM's Public IP Address
74+
## Step 3: Retrieve the VM's Public IP Address
7575

76-
Next, you retrieve the public IP address of the newly created VM. This value is stored in an environment variable for later use in the SSH command.
76+
After the VM is created, we need its public IP address to connect via SSH. The following command queries the public IP address from the VM's network settings and stores it in an environment variable.
7777

7878
```bash
79-
export PUBLIC_IP=$(az vm show -d --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_VM_NAME --query publicIps -o tsv)
79+
export PUBLIC_IP=$(az vm list-ip-addresses --resource-group $RESOURCE_GROUP --name $VM_NAME --query "[].virtualMachine.network.publicIpAddresses[0].ipAddress" -o tsv)
80+
echo "The public IP of the VM is: $PUBLIC_IP"
8081
```
8182

82-
## Step 5: SSH into the VM
83+
Results:
8384

84-
Finally, use the SSH command to connect to your Linux VM. The SSH command includes the option to disable strict host key checking to avoid interactive prompts during the first connection.
85+
<!-- expected_similarity=0.3 -->
86+
```text
87+
The public IP of the VM is: xx.xx.xx.xx
88+
```
89+
90+
## Step 4: SSH into the Linux VM
91+
92+
Now that you have the public IP, the following SSH command is provided for informational purposes. When executed, it will open an interactive SSH session into the Linux VM.
8593

8694
```bash
87-
ssh -o StrictHostKeyChecking=no azureuser@$PUBLIC_IP
95+
ssh azureuser@$PUBLIC_IP
8896
```
8997

90-
This SSH command connects you to the VM using the default administrator account "azureuser". Once connected, you can start managing your Linux environment directly.
91-
92-
Happy learning and exploring your new Linux VM in Azure!
98+
This completes the Exec Doc for deploying a Linux VM and connecting to it via SSH using the Azure CLI.

tools/Deploy_Linux_VM_and_Enable_SSH_on_Azure/attempt_1_failure.md

Lines changed: 0 additions & 92 deletions
This file was deleted.

tools/Deploy_Linux_VM_with_SSH_Access_in_Azure/FINAL_OUTPUT_success.md

Lines changed: 0 additions & 102 deletions
This file was deleted.

0 commit comments

Comments
 (0)