Skip to content

Commit 2819301

Browse files
author
naman-msft
committed
updated ada script
1 parent 7971ef3 commit 2819301

25 files changed

+2456
-9
lines changed
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
title: 'Quickstart: Create a Linux VM and SSH into It'
3+
description: This document demonstrates how to quickly create a Linux virtual machine (VM) in Azure and retrieve the SSH command needed to connect to it.
4+
ms.topic: quickstart
5+
ms.date: 10/06/2023
6+
author: chatgpt
7+
ms.author: chatgpt
8+
ms.custom: innovation-engine, cloud, azurecli
9+
---
10+
11+
This Exec Doc will guide you through creating an Azure resource group, deploying a Linux virtual machine with Ubuntu 22.04, retrieving its public IP address, and displaying the SSH command to connect to the VM. All commands are executed non-interactively with necessary environment variables declared on the fly. A random suffix is appended to resource names to ensure uniqueness across multiple executions.
12+
13+
### Step 1: Create a Resource Group
14+
15+
We first declare the required environment variables and create a new resource group. The variable RANDOM_SUFFIX ensures the resource group name is unique.
16+
17+
```bash
18+
export RANDOM_SUFFIX=$(openssl rand -hex 3)
19+
export REGION="centralindia"
20+
export MY_RESOURCE_GROUP_NAME="MyResourceGroup$RANDOM_SUFFIX"
21+
az group create --name $MY_RESOURCE_GROUP_NAME --location $REGION
22+
```
23+
24+
Results:
25+
26+
<!-- expected_similarity=0.3 -->
27+
28+
```JSON
29+
{
30+
"id": "/subscriptions/xxxxx-xxxxx-xxxxx-xxxxx/resourceGroups/MyResourceGroupxxxxxx",
31+
"location": "centralindia",
32+
"managedBy": null,
33+
"name": "MyResourceGroupxxxxxx",
34+
"properties": {
35+
"provisioningState": "Succeeded"
36+
},
37+
"tags": null,
38+
"type": "Microsoft.Resources/resourceGroups"
39+
}
40+
```
41+
42+
### Step 2: Create the Linux Virtual Machine
43+
44+
Next, we create a Linux VM using the Ubuntu 22.04 image. The VM name is generated using a random suffix for uniqueness. The admin username is set to "azureuser" and SSH keys are automatically generated.
45+
46+
```bash
47+
export VM_NAME="linuxvm$RANDOM_SUFFIX"
48+
export ADMIN_USERNAME="azureuser"
49+
az vm create --resource-group $MY_RESOURCE_GROUP_NAME --name $VM_NAME --image Ubuntu2204 --admin-username $ADMIN_USERNAME --generate-ssh-keys
50+
```
51+
52+
Results:
53+
54+
<!-- expected_similarity=0.3 -->
55+
56+
```JSON
57+
{
58+
"fqdns": "",
59+
"id": "/subscriptions/xxxxx-xxxxx-xxxxx-xxxxx/resourceGroups/MyResourceGroupxxxxxx/providers/Microsoft.Compute/virtualMachines/linuxvmxxxxxx",
60+
"location": "centralindia",
61+
"macAddress": "xx-xx-xx-xx-xx-xx",
62+
"powerState": "VM running",
63+
"privateIpAddress": "10.0.0.4",
64+
"publicIpAddress": "20.30.40.50",
65+
"resourceGroup": "MyResourceGroupxxxxxx",
66+
"zones": ""
67+
}
68+
```
69+
70+
### Step 3: Retrieve the VM's Public IP Address
71+
72+
We extract the public IP address of the newly created VM. This value will be used for connecting to the VM via SSH.
73+
74+
```bash
75+
export PUBLIC_IP=$(az vm list-ip-addresses --resource-group $MY_RESOURCE_GROUP_NAME --name $VM_NAME --query "[].virtualMachine.network.publicIpAddresses[0].ipAddress" -o tsv)
76+
echo "Public IP: $PUBLIC_IP"
77+
```
78+
79+
Results:
80+
81+
<!-- expected_similarity=0.3 -->
82+
83+
```text
84+
Public IP: 20.30.40.50
85+
```
86+
87+
### Step 4: Display SSH Command to Connect to the VM
88+
89+
Finally, we output the SSH command that you can use to connect to the Linux VM. Simply copy and run the displayed command in your terminal to access the VM. Note that this command is for demonstration purposes; running it will initiate an interactive SSH session.
90+
91+
```bash
92+
echo "To SSH into the VM, run the following command:"
93+
echo "ssh $ADMIN_USERNAME@$PUBLIC_IP"
94+
```
95+
96+
Results:
97+
98+
<!-- expected_similarity=0.3 -->
99+
100+
```text
101+
To SSH into the VM, run the following command:
102+
103+
```
104+
105+
You have now successfully created a Linux VM in Azure and retrieved the information required to SSH into it. Enjoy exploring your new VM!
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
title: 'Quickstart: Create a Linux VM and SSH into It'
3+
description: This document demonstrates how to quickly create a Linux virtual machine (VM) in Azure and retrieve the SSH command needed to connect to it.
4+
ms.topic: quickstart
5+
ms.date: 10/06/2023
6+
author: chatgpt
7+
ms.author: chatgpt
8+
ms.custom: innovation-engine, cloud, azurecli
9+
---
10+
11+
This Exec Doc will guide you through creating an Azure resource group, deploying a Linux virtual machine with Ubuntu LTS, retrieving its public IP address, and displaying the SSH command to connect to the VM. All commands are executed non-interactively with necessary environment variables declared on the fly. A random suffix is appended to resource names to ensure uniqueness across multiple executions.
12+
13+
### Step 1: Create a Resource Group
14+
15+
We first declare the required environment variables and create a new resource group. The variable RANDOM_SUFFIX ensures the resource group name is unique.
16+
17+
```bash
18+
export RANDOM_SUFFIX=$(openssl rand -hex 3)
19+
export REGION="centralindia"
20+
export MY_RESOURCE_GROUP_NAME="MyResourceGroup$RANDOM_SUFFIX"
21+
az group create --name $MY_RESOURCE_GROUP_NAME --location $REGION
22+
```
23+
24+
Results:
25+
26+
<!-- expected_similarity=0.3 -->
27+
28+
```JSON
29+
{
30+
"id": "/subscriptions/xxxxx-xxxxx-xxxxx-xxxxx/resourceGroups/MyResourceGroupxxxxxx",
31+
"location": "centralindia",
32+
"managedBy": null,
33+
"name": "MyResourceGroupxxxxxx",
34+
"properties": {
35+
"provisioningState": "Succeeded"
36+
},
37+
"tags": null,
38+
"type": "Microsoft.Resources/resourceGroups"
39+
}
40+
```
41+
42+
### Step 2: Create the Linux Virtual Machine
43+
44+
Next, we create a Linux VM using the Ubuntu LTS image. The VM name is generated using a random suffix for uniqueness. The admin username is set to "azureuser" and SSH keys are automatically generated.
45+
46+
```bash
47+
export VM_NAME="linuxvm$RANDOM_SUFFIX"
48+
export ADMIN_USERNAME="azureuser"
49+
az vm create --resource-group $MY_RESOURCE_GROUP_NAME --name $VM_NAME --image UbuntuLTS --admin-username $ADMIN_USERNAME --generate-ssh-keys
50+
```
51+
52+
Results:
53+
54+
<!-- expected_similarity=0.3 -->
55+
56+
```JSON
57+
{
58+
"fqdns": "",
59+
"id": "/subscriptions/xxxxx-xxxxx-xxxxx-xxxxx/resourceGroups/MyResourceGroupxxxxxx/providers/Microsoft.Compute/virtualMachines/linuxvmxxxxxx",
60+
"location": "centralindia",
61+
"macAddress": "xx-xx-xx-xx-xx-xx",
62+
"powerState": "VM running",
63+
"privateIpAddress": "10.0.0.4",
64+
"publicIpAddress": "20.30.40.50",
65+
"resourceGroup": "MyResourceGroupxxxxxx",
66+
"zones": ""
67+
}
68+
```
69+
70+
### Step 3: Retrieve the VM's Public IP Address
71+
72+
We extract the public IP address of the newly created VM. This value will be used for connecting to the VM via SSH.
73+
74+
```bash
75+
export PUBLIC_IP=$(az vm list-ip-addresses --resource-group $MY_RESOURCE_GROUP_NAME --name $VM_NAME --query "[].virtualMachine.network.publicIpAddresses[0].ipAddress" -o tsv)
76+
echo "Public IP: $PUBLIC_IP"
77+
```
78+
79+
Results:
80+
81+
<!-- expected_similarity=0.3 -->
82+
83+
```text
84+
Public IP: 20.30.40.50
85+
```
86+
87+
### Step 4: Display SSH Command to Connect to the VM
88+
89+
Finally, we output the SSH command that you can use to connect to the Linux VM. Simply copy and run the displayed command in your terminal to access the VM. Note that this command is for demonstration purposes; running it will initiate an interactive SSH session.
90+
91+
```bash
92+
echo "To SSH into the VM, run the following command:"
93+
echo "ssh $ADMIN_USERNAME@$PUBLIC_IP"
94+
```
95+
96+
Results:
97+
98+
<!-- expected_similarity=0.3 -->
99+
100+
```text
101+
To SSH into the VM, run the following command:
102+
103+
```
104+
105+
You have now successfully created a Linux VM in Azure and retrieved the information required to SSH into it. Enjoy exploring your new VM!
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
---
2+
title: 'Quickstart: Create a Linux VM and SSH into It'
3+
description: This document demonstrates how to quickly create a Linux virtual machine (VM) in Azure and retrieve the SSH command needed to connect to it.
4+
ms.topic: quickstart
5+
ms.date: 10/06/2023
6+
author: chatgpt
7+
ms.author: chatgpt
8+
ms.custom: innovation-engine, cloud, azurecli
9+
---
10+
11+
This Exec Doc will guide you through creating an Azure resource group, deploying a Linux virtual machine with Ubuntu LTS, retrieving its public IP address, and displaying the SSH command to connect to the VM. All commands are executed non-interactively with necessary environment variables declared on the fly. A random suffix is appended to resource names to ensure uniqueness across multiple executions.
12+
13+
### Step 1: Create a Resource Group
14+
15+
We first declare the required environment variables and create a new resource group. The variable RANDOM_SUFFIX ensures the resource group name is unique.
16+
17+
```bash
18+
export RANDOM_SUFFIX=$(openssl rand -hex 3)
19+
export REGION="centralindia"
20+
export MY_RESOURCE_GROUP_NAME="MyResourceGroup$RANDOM_SUFFIX"
21+
az group create --name $MY_RESOURCE_GROUP_NAME --location $REGION
22+
```
23+
24+
Results:
25+
26+
<!-- expected_similarity=0.3 -->
27+
28+
```JSON
29+
{
30+
"id": "/subscriptions/xxxxx-xxxxx-xxxxx-xxxxx/resourceGroups/MyResourceGroupxxxxxx",
31+
"location": "centralindia",
32+
"managedBy": null,
33+
"name": "MyResourceGroupxxxxxx",
34+
"properties": {
35+
"provisioningState": "Succeeded"
36+
},
37+
"tags": null,
38+
"type": "Microsoft.Resources/resourceGroups"
39+
}
40+
```
41+
42+
### Step 2: Create the Linux Virtual Machine
43+
44+
Next, we create a Linux VM using the Ubuntu LTS image. The VM name is generated using a random suffix for uniqueness. The admin username is set to "azureuser" and SSH keys are automatically generated.
45+
46+
```bash
47+
export VM_NAME="linuxvm$RANDOM_SUFFIX"
48+
export ADMIN_USERNAME="azureuser"
49+
az vm create --resource-group $MY_RESOURCE_GROUP_NAME --name $VM_NAME --image UbuntuLTS --admin-username $ADMIN_USERNAME --generate-ssh-keys
50+
```
51+
52+
Results:
53+
54+
<!-- expected_similarity=0.3 -->
55+
56+
```JSON
57+
{
58+
"fqdns": "",
59+
"id": "/subscriptions/xxxxx-xxxxx-xxxxx-xxxxx/resourceGroups/MyResourceGroupxxxxxx/providers/Microsoft.Compute/virtualMachines/linuxvmxxxxxx",
60+
"location": "centralindia",
61+
"macAddress": "xx-xx-xx-xx-xx-xx",
62+
"powerState": "VM running",
63+
"privateIpAddress": "10.0.0.4",
64+
"publicIpAddress": "20.30.40.50",
65+
"resourceGroup": "MyResourceGroupxxxxxx",
66+
"zones": ""
67+
}
68+
```
69+
70+
### Step 3: Retrieve the VM's Public IP Address
71+
72+
We extract the public IP address of the newly created VM. This value will be used for connecting to the VM via SSH.
73+
74+
```bash
75+
export PUBLIC_IP=$(az vm list-ip-addresses --resource-group $MY_RESOURCE_GROUP_NAME --name $VM_NAME --query "[].virtualMachine.network.publicIpAddresses[0].ipAddress" -o tsv)
76+
echo "Public IP: $PUBLIC_IP"
77+
```
78+
79+
Results:
80+
81+
<!-- expected_similarity=0.3 -->
82+
83+
```text
84+
Public IP: 20.30.40.50
85+
```
86+
87+
### Step 4: Display SSH Command to Connect to the VM
88+
89+
Finally, we output the SSH command that you can use to connect to the Linux VM. Simply copy and run the displayed command in your terminal to access the VM. Note that this command is for demonstration purposes; running it will initiate an interactive SSH session.
90+
91+
```bash
92+
echo "To SSH into the VM, run the following command:"
93+
echo "ssh $ADMIN_USERNAME@$PUBLIC_IP"
94+
```
95+
96+
Results:
97+
98+
<!-- expected_similarity=0.3 -->
99+
100+
```text
101+
To SSH into the VM, run the following command:
102+
103+
```
104+
105+
You have now successfully created a Linux VM in Azure and retrieved the information required to SSH into it. Enjoy exploring your new VM!

0 commit comments

Comments
 (0)