Skip to content

Commit e76906b

Browse files
author
naman-msft
committed
fixed some header issues in ada
1 parent 20478cd commit e76906b

File tree

7 files changed

+548
-5
lines changed

7 files changed

+548
-5
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
---
2+
title: Quickstart: Create a Linux VM and SSH into it using Azure CLI
3+
description: This guide demonstrates how to create a Linux virtual machine in Azure using the Azure CLI with the Ubuntu 22.04 image, and then execute a non-interactive SSH command to verify connectivity with the VM.
4+
ms.topic: quickstart
5+
ms.date: 10/16/2023
6+
author: chatgpt
7+
ms.author: chatgpt
8+
ms.custom: innovation-engine, azure-cli
9+
---
10+
11+
# Quickstart: Create a Linux VM and SSH into it using Azure CLI
12+
13+
This Exec Doc walks you through creating an Azure resource group, deploying a Linux VM using the Ubuntu 22.04 image, and verifying connectivity by SSHing into the VM via a non-interactive command. All necessary environment variables are declared and suffixed where needed to ensure that repeated runs do not cause naming conflicts.
14+
15+
## Step 1: Create a Resource Group
16+
17+
In this section, we declare our environment variables, generate a random suffix, and create a resource group. The random suffix ensures that the resource group name is unique during each execution. We have changed our region from WestUS2 to centralindia to avoid regional quota issues.
18+
19+
```bash
20+
export RANDOM_SUFFIX=$(openssl rand -hex 3)
21+
export REGION="centralindia"
22+
export MY_RESOURCE_GROUP_NAME="MyResourceGroup$RANDOM_SUFFIX"
23+
az group create --name $MY_RESOURCE_GROUP_NAME --location $REGION
24+
```
25+
26+
Results:
27+
28+
<!-- expected_similarity=0.3 -->
29+
```JSON
30+
{
31+
"id": "/subscriptions/xxxxx/resourceGroups/MyResourceGroupxxxxx",
32+
"location": "centralindia",
33+
"managedBy": null,
34+
"name": "MyResourceGroupxxxxx",
35+
"properties": {
36+
"provisioningState": "Succeeded"
37+
},
38+
"tags": null,
39+
"type": "Microsoft.Resources/resourceGroups"
40+
}
41+
```
42+
43+
## Step 2: Create a Linux Virtual Machine
44+
45+
Now, we create a Linux VM using the Ubuntu 22.04 image. This is a valid image from the approved list. An SSH key will automatically be generated if one does not exist. To ensure uniqueness, the VM name is appended with the same random suffix used earlier.
46+
47+
```bash
48+
export MY_VM_NAME="MyLinuxVM$RANDOM_SUFFIX"
49+
az vm create --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_VM_NAME --image Ubuntu2204 --admin-username azureuser --generate-ssh-keys
50+
```
51+
52+
Results:
53+
54+
<!-- expected_similarity=0.3 -->
55+
```JSON
56+
{
57+
"fqdns": "",
58+
"id": "/subscriptions/xxxxx/resourceGroups/MyResourceGroupxxxxx/providers/Microsoft.Compute/virtualMachines/MyLinuxVMxxxxx",
59+
"location": "centralindia",
60+
"macAddress": "xx:xx:xx:xx:xx:xx",
61+
"powerState": "VM running",
62+
"privateIpAddress": "10.0.0.4",
63+
"publicIpAddress": "52.123.45.67",
64+
"resourceGroup": "MyResourceGroupxxxxx",
65+
"zones": ""
66+
}
67+
```
68+
69+
## Step 3: Retrieve the Public IP Address
70+
71+
Here we retrieve the public IP address of the newly created virtual machine. We store the IP in an environment variable and display it. This IP is then used to SSH into the VM.
72+
73+
```bash
74+
export PUBLIC_IP=$(az vm list-ip-addresses --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_VM_NAME --query "[].virtualMachine.network.publicIpAddresses[0].ipAddress" -o tsv)
75+
echo $PUBLIC_IP
76+
```
77+
78+
Results:
79+
80+
<!-- expected_similarity=0.3 -->
81+
```text
82+
52.123.45.67
83+
```
84+
85+
## Step 4: SSH into the Linux VM
86+
87+
Finally, we use SSH in a non-interactive mode to execute a simple command on the remote VM. This command will echo a message confirming that the SSH connection is working. The SSH command uses the option to bypass host key checking for automation purposes.
88+
89+
```bash
90+
ssh -o StrictHostKeyChecking=no azureuser@$PUBLIC_IP "echo 'Hello from VM'"
91+
```
92+
93+
Results:
94+
95+
<!-- expected_similarity=0.3 -->
96+
```text
97+
Hello from VM
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title: Quickstart: Create a Linux VM and SSH into it using Azure CLI
3+
description: This guide demonstrates how to create a Linux virtual machine in Azure using the Azure CLI with the Ubuntu 22.04 image, and then execute a non-interactive SSH command to verify connectivity with the VM.
4+
ms.topic: quickstart
5+
ms.date: 10/16/2023
6+
author: chatgpt
7+
ms.author: chatgpt
8+
ms.custom: innovation-engine, azure-cli
9+
---
10+
11+
# Quickstart: Create a Linux VM and SSH into it using Azure CLI
12+
13+
This Exec Doc walks you through creating an Azure resource group, deploying a Linux VM using the Ubuntu 22.04 image, and verifying connectivity by SSHing into the VM via a non-interactive command. All necessary environment variables are declared and suffixed where needed to ensure that repeated runs do not cause naming conflicts.
14+
15+
## Step 1: Create a Resource Group
16+
17+
In this section, we declare our environment variables, generate a random suffix, and create a resource group. The random suffix ensures that the resource group name is unique during each execution. We have changed our region from WestUS2 to centralindia to avoid regional quota issues.
18+
19+
```bash
20+
export RANDOM_SUFFIX=$(openssl rand -hex 3)
21+
export REGION="centralindia"
22+
export MY_RESOURCE_GROUP_NAME="MyResourceGroup$RANDOM_SUFFIX"
23+
az group create --name $MY_RESOURCE_GROUP_NAME --location $REGION
24+
```
25+
26+
Results:
27+
28+
<!-- expected_similarity=0.3 -->
29+
```JSON
30+
{
31+
"id": "/subscriptions/xxxxx/resourceGroups/MyResourceGroupxxxxx",
32+
"location": "centralindia",
33+
"managedBy": null,
34+
"name": "MyResourceGroupxxxxx",
35+
"properties": {
36+
"provisioningState": "Succeeded"
37+
},
38+
"tags": null,
39+
"type": "Microsoft.Resources/resourceGroups"
40+
}
41+
```
42+
43+
## Step 2: Create a Linux Virtual Machine
44+
45+
Now, we create a Linux VM using the Ubuntu 22.04 image. This is a valid image from the approved list. An SSH key will automatically be generated if one does not exist. To ensure uniqueness, the VM name is appended with the same random suffix used earlier.
46+
47+
```bash
48+
export MY_VM_NAME="MyLinuxVM$RANDOM_SUFFIX"
49+
az vm create --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_VM_NAME --image Ubuntu2204 --admin-username azureuser --generate-ssh-keys
50+
```
51+
52+
Results:
53+
54+
<!-- expected_similarity=0.3 -->
55+
```JSON
56+
{
57+
"fqdns": "",
58+
"id": "/subscriptions/xxxxx/resourceGroups/MyResourceGroupxxxxx/providers/Microsoft.Compute/virtualMachines/MyLinuxVMxxxxx",
59+
"location": "centralindia",
60+
"macAddress": "xx:xx:xx:xx:xx:xx",
61+
"powerState": "VM running",
62+
"privateIpAddress": "10.0.0.4",
63+
"publicIpAddress": "52.123.45.67",
64+
"resourceGroup": "MyResourceGroupxxxxx",
65+
"zones": ""
66+
}
67+
```
68+
69+
## Step 3: Retrieve the Public IP Address
70+
71+
Here we retrieve the public IP address of the newly created virtual machine. We store the IP in an environment variable and display it. This IP is then used to SSH into the VM.
72+
73+
```bash
74+
export PUBLIC_IP=$(az vm list-ip-addresses --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_VM_NAME --query "[].virtualMachine.network.publicIpAddresses[0].ipAddress" -o tsv)
75+
echo $PUBLIC_IP
76+
```
77+
78+
Results:
79+
80+
<!-- expected_similarity=0.3 -->
81+
```text
82+
52.123.45.67
83+
```
84+
85+
## Step 4: SSH into the Linux VM
86+
87+
Finally, we use SSH in a non-interactive mode to execute a simple command on the remote VM. This command will echo a message confirming that the SSH connection is working. The SSH command uses the option to bypass host key checking for automation purposes.
88+
89+
```bash
90+
ssh -o StrictHostKeyChecking=no azureuser@$PUBLIC_IP "echo 'Hello from VM'"
91+
```
92+
93+
Results:
94+
95+
<!-- expected_similarity=0.3 -->
96+
```text
97+
Hello from VM
98+
```
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title: Quickstart: Create a Linux VM and SSH into it using Azure CLI
3+
description: This guide demonstrates how to create a Linux virtual machine in Azure using the Azure CLI with the Ubuntu 22.04 image, and then execute a non-interactive SSH command to verify connectivity with the VM.
4+
ms.topic: quickstart
5+
ms.date: 10/16/2023
6+
author: chatgpt
7+
ms.author: chatgpt
8+
ms.custom: innovation-engine, azure-cli
9+
---
10+
11+
# Quickstart: Create a Linux VM and SSH into it using Azure CLI
12+
13+
This Exec Doc walks you through creating an Azure resource group, deploying a Linux VM using the Ubuntu 22.04 image, and verifying connectivity by SSHing into the VM via a non-interactive command. All necessary environment variables are declared and suffixed where needed to ensure that repeated runs do not cause naming conflicts.
14+
15+
## Step 1: Create a Resource Group
16+
17+
In this section, we declare our environment variables, generate a random suffix, and create a resource group. The random suffix ensures that the resource group name is unique during each execution.
18+
19+
```bash
20+
export RANDOM_SUFFIX=$(openssl rand -hex 3)
21+
export REGION="WestUS2"
22+
export MY_RESOURCE_GROUP_NAME="MyResourceGroup$RANDOM_SUFFIX"
23+
az group create --name $MY_RESOURCE_GROUP_NAME --location $REGION
24+
```
25+
26+
Results:
27+
28+
<!-- expected_similarity=0.3 -->
29+
```JSON
30+
{
31+
"id": "/subscriptions/xxxxx/resourceGroups/MyResourceGroupxxxxx",
32+
"location": "WestUS2",
33+
"managedBy": null,
34+
"name": "MyResourceGroupxxxxx",
35+
"properties": {
36+
"provisioningState": "Succeeded"
37+
},
38+
"tags": null,
39+
"type": "Microsoft.Resources/resourceGroups"
40+
}
41+
```
42+
43+
## Step 2: Create a Linux Virtual Machine
44+
45+
Now, we create a Linux VM using the Ubuntu 22.04 image. An SSH key will automatically be generated if one does not exist. The VM name is suffixed with the same random value to ensure uniqueness.
46+
47+
```bash
48+
export MY_VM_NAME="MyLinuxVM$RANDOM_SUFFIX"
49+
az vm create --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_VM_NAME --image ubuntu2204 --admin-username azureuser --generate-ssh-keys
50+
```
51+
52+
Results:
53+
54+
<!-- expected_similarity=0.3 -->
55+
```JSON
56+
{
57+
"fqdns": "",
58+
"id": "/subscriptions/xxxxx/resourceGroups/MyResourceGroupxxxxx/providers/Microsoft.Compute/virtualMachines/MyLinuxVMxxxxx",
59+
"location": "WestUS2",
60+
"macAddress": "xx:xx:xx:xx:xx:xx",
61+
"powerState": "VM running",
62+
"privateIpAddress": "10.0.0.4",
63+
"publicIpAddress": "52.123.45.67",
64+
"resourceGroup": "MyResourceGroupxxxxx",
65+
"zones": ""
66+
}
67+
```
68+
69+
## Step 3: Retrieve the Public IP Address
70+
71+
Here we retrieve the public IP address of the newly created virtual machine. We store the IP in an environment variable and display it. This IP is then used to SSH into the VM.
72+
73+
```bash
74+
export PUBLIC_IP=$(az vm list-ip-addresses --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_VM_NAME --query "[].virtualMachine.network.publicIpAddresses[0].ipAddress" -o tsv)
75+
echo $PUBLIC_IP
76+
```
77+
78+
Results:
79+
80+
<!-- expected_similarity=0.3 -->
81+
```text
82+
52.123.45.67
83+
```
84+
85+
## Step 4: SSH into the Linux VM
86+
87+
Finally, we use SSH in a non-interactive mode to execute a simple command on the remote VM. This command will echo a message confirming that the SSH connection is working. Note that the SSH command uses the option to bypass host key checking for automation purposes.
88+
89+
```bash
90+
ssh -o StrictHostKeyChecking=no azureuser@$PUBLIC_IP "echo 'Hello from VM'"
91+
```
92+
93+
Results:
94+
95+
<!-- expected_similarity=0.3 -->
96+
```text
97+
Hello from VM
98+
```
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
title: Quickstart: Create a Linux VM and SSH into it using Azure CLI
3+
description: This guide demonstrates how to create a Linux virtual machine in Azure using the Azure CLI with the Ubuntu 22.04 image, and then execute a non-interactive SSH command to verify connectivity with the VM.
4+
ms.topic: quickstart
5+
ms.date: 10/16/2023
6+
author: chatgpt
7+
ms.author: chatgpt
8+
ms.custom: innovation-engine, azure-cli
9+
---
10+
11+
# Quickstart: Create a Linux VM and SSH into it using Azure CLI
12+
13+
This Exec Doc walks you through creating an Azure resource group, deploying a Linux VM using the Ubuntu 22.04 image, and verifying connectivity by SSHing into the VM via a non-interactive command. All necessary environment variables are declared and suffixed where needed to ensure that repeated runs do not cause naming conflicts.
14+
15+
## Step 1: Create a Resource Group
16+
17+
In this section, we declare our environment variables, generate a random suffix, and create a resource group. The random suffix ensures that the resource group name is unique during each execution.
18+
19+
```bash
20+
export RANDOM_SUFFIX=$(openssl rand -hex 3)
21+
export REGION="WestUS2"
22+
export MY_RESOURCE_GROUP_NAME="MyResourceGroup$RANDOM_SUFFIX"
23+
az group create --name $MY_RESOURCE_GROUP_NAME --location $REGION
24+
```
25+
26+
Results:
27+
28+
<!-- expected_similarity=0.3 -->
29+
```JSON
30+
{
31+
"id": "/subscriptions/xxxxx/resourceGroups/MyResourceGroupxxxxx",
32+
"location": "WestUS2",
33+
"managedBy": null,
34+
"name": "MyResourceGroupxxxxx",
35+
"properties": {
36+
"provisioningState": "Succeeded"
37+
},
38+
"tags": null,
39+
"type": "Microsoft.Resources/resourceGroups"
40+
}
41+
```
42+
43+
## Step 2: Create a Linux Virtual Machine
44+
45+
Now, we create a Linux VM using the Ubuntu 22.04 image, which is a valid image from the approved list. An SSH key will automatically be generated if one does not exist. The VM name is suffixed with the same random value to ensure uniqueness.
46+
47+
```bash
48+
export MY_VM_NAME="MyLinuxVM$RANDOM_SUFFIX"
49+
az vm create --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_VM_NAME --image Ubuntu2204 --admin-username azureuser --generate-ssh-keys
50+
```
51+
52+
Results:
53+
54+
<!-- expected_similarity=0.3 -->
55+
```JSON
56+
{
57+
"fqdns": "",
58+
"id": "/subscriptions/xxxxx/resourceGroups/MyResourceGroupxxxxx/providers/Microsoft.Compute/virtualMachines/MyLinuxVMxxxxx",
59+
"location": "WestUS2",
60+
"macAddress": "xx:xx:xx:xx:xx:xx",
61+
"powerState": "VM running",
62+
"privateIpAddress": "10.0.0.4",
63+
"publicIpAddress": "52.123.45.67",
64+
"resourceGroup": "MyResourceGroupxxxxx",
65+
"zones": ""
66+
}
67+
```
68+
69+
## Step 3: Retrieve the Public IP Address
70+
71+
Here we retrieve the public IP address of the newly created virtual machine. We store the IP in an environment variable and display it. This IP is then used to SSH into the VM.
72+
73+
```bash
74+
export PUBLIC_IP=$(az vm list-ip-addresses --resource-group $MY_RESOURCE_GROUP_NAME --name $MY_VM_NAME --query "[].virtualMachine.network.publicIpAddresses[0].ipAddress" -o tsv)
75+
echo $PUBLIC_IP
76+
```
77+
78+
Results:
79+
80+
<!-- expected_similarity=0.3 -->
81+
```text
82+
52.123.45.67
83+
```
84+
85+
## Step 4: SSH into the Linux VM
86+
87+
Finally, we use SSH in a non-interactive mode to execute a simple command on the remote VM. This command will echo a message confirming that the SSH connection is working. The SSH command uses the option to bypass host key checking for automation purposes.
88+
89+
```bash
90+
ssh -o StrictHostKeyChecking=no azureuser@$PUBLIC_IP "echo 'Hello from VM'"
91+
```
92+
93+
Results:
94+
95+
<!-- expected_similarity=0.3 -->
96+
```text
97+
Hello from VM
98+
```

0 commit comments

Comments
 (0)