Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tega #2

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
197 changes: 196 additions & 1 deletion Week 1/LAB1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,200 @@
Quickstart: Create a Linux VM
* https://docs.microsoft.com/en-us/azure/virtual-machines/linux/quick-create-cli

Step 1: Create a Resource Group.
>Here is the input code for creating a resource group:
```
az group create --name myResourceGroup --location eastus

```

> Here is the output code for creating a resource group:

```
{
"id": "/subscriptions/b5549425-9749-48f8-8db1-e22c7d47472d/resourceGroups/myResourceGroup",
"location": "eastus",
"managedBy": null,
"name": "myResourceGroup",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}
```
Step 2: Create a VM
Code input:
```
az vm create
--resource-group myResourceGroup
--name tegasVM
--image UbuntuLTS
--generate-ssh-keys
```

> Here is the output code for creating my virtual machine:

```
{
"fqdns": "",
"id": "/subscriptions/b5549425-9749-48f8-8db1-e22c7d47472d/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/tegasVM",
"location": "eastus",
"macAddress": "00-0D-3A-52-F7-64",
"powerState": "VM running",
"privateIpAddress": "10.0.0.4",
"publicIpAddress": "52.191.113.133",
"resourceGroup": "myResourceGroup",
"zones": ""
}
```

Step 3: Open port 80 for web traffic.

> Code input:

```
az vm open-port --port 80 --resource-group myResourceGroup --name tegasVM
```

Step 4: Connect SSH to VM.
> Code input

```
ssh [email protected]
```
Step 5: Install web server.

> Code input

```
sudo apt-get -y update
sudo apt-get -y install nginx
```

Final Step: View the web server in action.
> Here is a screenshot of the web server in action:

![nginx web server](images/ps-nginx.png)


Quickstart for Bash in Azure Cloud Shell
* https://docs.microsoft.com/en-us/azure/cloud-shell/quickstart
* https://docs.microsoft.com/en-us/azure/cloud-shell/quickstart

## Lab 1: Quickstart for Bash in Azure Cloud Shell
#### Create a Linux VM:

Step 1: Set subscription.
> Here is the input code for setting subscription:

```
az account set --subscription 'Azure subscription 1'
```
Step 2: Create a resource group.
> Here is the input code for a creating resource group:

```
az group create --location eastus --name MyResourcegroup
```
> Here is the output code for a creating resource group:

```
{
"id": "/subscriptions/b5549425-9749-48f8-8db1-e22c7d47472d/resourceGroups/MyResourcegroup",
"location": "eastus",
"managedBy": null,
"name": "MyResourcegroup",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}
```


Step 3: Create a Linux VM
Code input:
```
az vm create
-n myVM
-g MyResourcegroup
--image UbuntuLTS
--generate-ssh-keys
```

> Here is the output code for creating my virtual machine:

```
{
"fqdns": "",
"id": "/subscriptions/b5549425-9749-48f8-8db1-e22c7d47472d/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM",
"location": "eastus",
"macAddress": "00-0D-3A-56-40-4D",
"powerState": "VM running",
"privateIpAddress": "10.0.0.4",
"publicIpAddress": "20.185.182.231",
"resourceGroup": "myResourceGroup",
"zones": ""
}
```

Step 4: SSH into your Linux VM

After searching for VM name in the Azure portal search bar, Open port 80 for web traffic. Click "Connect" to get your VM name and public IP address.

1. ssh cmd to SSH into VM

```
ssh [email protected]
```
2. ssh output:

```
The authenticity of host '20.185.182.231 (20.185.182.231)' can't be established.
ECDSA key fingerprint is SHA256:11CfB7AKCtuVcynsL0Fmnd+eIiXEcfoybmEEv5TaVxA.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '20.185.182.231' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 18.04.6 LTS (GNU/Linux 5.4.0-1063-azure x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

System information as of Tue Nov 16 14:53:23 UTC 2021

System load: 0.08 Processes: 108
Usage of /: 4.6% of 28.90GB Users logged in: 0
Memory usage: 5% IP address for eth0: 10.0.0.4
Swap usage: 0%

0 updates can be applied immediately.



The programs included with the Ubuntu system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by
applicable law.

To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.
```

Step 5: Install web server.

> Code input

```
sudo apt-get -y update
sudo apt-get -y install nginx
```

Final Step: View the web server in action.
> Here is a screenshot of the web server in action:

![nginx web server](images/nginxbash.png)

Done.
Binary file added Week 1/LAB1/images/nginxbash.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Week 1/LAB1/images/ps-nginx.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
189 changes: 187 additions & 2 deletions Week 1/LAB2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,190 @@
Quickstart: Create a Linux VM
* https://docs.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-manage-vm

Quickstart for Bash in Azure Cloud Shell
* https://docs.microsoft.com/en-us/azure/cloud-shell/quickstart
### Step 1: Create a Resource Group.
> Here is the input code for creating my resource group:

```
az group create --location eastus --name MyResourceGroupVM
```
> Here is the output code for creating a resource group:

```
{
"id": "/subscriptions/b5549425-9749-48f8-8db1-e22c7d47472d/resourceGroups/myResourceGroupVM",
"location": "eastus",
"managedBy": null,
"name": "myResourceGroupVM",
"properties": {
"provisioningState": "Succeeded"
},
"tags": null,
"type": "Microsoft.Resources/resourceGroups"
}
```


### Step 2: Create a VM
Code input:
```
az vm create
--resource-group myResourceGroupVM
--name tegasVM
--image UbuntuLTS
--admin-username tega
--generate-ssh-keys
```

> Here is the output code for creating my virtual machine:

```
{
"fqdns": "",
"id": "/subscriptions/b5549425-9749-48f8-8db1-e22c7d47472d/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/tegasVM",
"location": "eastus",
"macAddress": "00-0D-3A-52-F7-64",
"powerState": "VM running",
"privateIpAddress": "10.0.0.4",
"publicIpAddress": "52.191.113.133",
"resourceGroup": "myResourceGroup",
"zones": ""
}
```
### Step 3: Create a VM with a specific VM image
Code input:
```
az vm create
--resource-group myResourceGroupVM
--name tegasVM
--image OpenLogic:CentOS:7.5:latest
--generate-ssh-keys
```

> Here is the output codee:

```
{
"fqdns": "",
"id": "/subscriptions/b5549425-9749-48f8-8db1-e22c7d47472d/resourceGroups/myResourceGroupVM/providers/Microsoft.Compute/virtualMachines/tegasVM",
"location": "eastus",
"macAddress": "00-22-48-28-FB-C3",
"powerState": "VM running",
"privateIpAddress": "10.0.0.5",
"publicIpAddress": "52.170.102.44",
"resourceGroup": "myResourceGroupVM",
"zones": ""
}
```

### Step 4: Create a VM with a specific VM Size
Code input:
```
az vm create
--resource-group myResourceGroupVM
--name myVM3
--image UbuntuLTS
--size Standard_D2_v2
--generate-ssh-keys
```

> Here is the output code:

```
{
"fqdns": "",
"id": "/subscriptions/b5549425-9749-48f8-8db1-e22c7d47472d/resourceGroups/myResourceGroupVM/providers/Microsoft.Compute/virtualMachines/myVM3",
"location": "eastus",
"macAddress": "00-0D-3A-14-21-08",
"powerState": "VM running",
"privateIpAddress": "10.0.0.4",
"publicIpAddress": "13.82.83.216",
"resourceGroup": "myResourceGroupVM",
"zones": ""
}
```

### Step 5: Resize a VM
1. To show the size of my VM:

> Code input:

```
az vm show --resource-group myResourceGroupVM --name tegasVM --query hardwareProfile.vmSize
```

> Here is the output:

```
"Standard_DS1_v2"
```


2. To Change to size of my VM to available size options:
> Code input:

```
az vm resize --resource-group myResourceGroupVM --name tegasVM --size "Standard_B1ms"
```

> Here is a partial output:

```
{
"additionalCapabilities": null,
"applicationProfile": null,
"availabilitySet": null,
"billingProfile": null,
"capacityReservation": null,
"diagnosticsProfile": null,
"evictionPolicy": null,
"extendedLocation": null,
"extensionsTimeBudget": null,
"hardwareProfile": {
"vmSize": "Standard_B1ms",
"vmSizeProperties": null
},

},
"tags": {},
"type": "Microsoft.Compute/virtualMachines",
"userData": null,
"virtualMachineScaleSet": null,
"vmId": "ab10b743-bffc-426d-afc6-259fd69282aa",
"zones": null
}
```

## View and Understand VM States

#### To find the current powerstate of my VM:

>input

```
az vm get-instance-view
--name tegasVM
--resource-group myResourceGroupVM
--query instanceView.statuses[1] --output table
```
>output

```
Code Level DisplayStatus
------------------ ------- ---------------
PowerState/running Info VM running
```
#### To get IP address:
>input

```
az vm list-ip-addresses --resource-group myResourceGroupVM --name tegasVM --output table
```
>output

```
PowerState/running Info VM running
tega@Azure:~$ az vm list-ip-addresses --resource-group myResourceGroupVM --name tegasVM --output table
VirtualMachine PublicIPAddresses PrivateIPAddresses
---------------- ------------------- --------------------
tegasVM 52.170.102.44 10.0.0.5
```
Loading