Post

KodeKloud Azure Engineer Level 1

Perform administrative tasks in the CLI for a fictional company.

KodeKloud Azure Engineer Level 1

The Nautilus DevOps team is strategizing the migration of a portion of their infrastructure to the Azure cloud. Recognizing the scale of this undertaking, they have opted to approach the migration in incremental steps rather than as a single massive transition. To achieve this, they have segmented large tasks into smaller, more manageable units. This granular approach enables the team to execute the migration in gradual phases, ensuring smoother implementation and minimizing disruption to ongoing operations. By breaking down the migration into smaller tasks, the Nautilus DevOps team can systematically progress through each stage, allowing for better control, risk mitigation, and optimization of resources throughout the migration process.

1. Create SSH Key Pair for Azure Virtual Machine

For this task, create an SSH key pair with the following requirements:

  • The name of the SSH key pair should be xfusion-kp.
  • The key pair type must be rsa.
  • ssh-keygen -t rsa -b 2048 -f ~/.ssh/xfusion-kp

2. Create an Azure Virtual Machine

The Nautilus DevOps team is planning to migrate a portion of their infrastructure to the Azure cloud incrementally. As part of this migration, you are tasked with creating an Azure Virtual Machine (VM). The requirements are:

  • Use the existing resource group. az group list
  • The VM name must be devops-vm, it should be in West US region.
  • Use the Ubuntu 22.04 LTS image for the VM.
  • The VM size must be Standard_B1s.
  • Attach a default Network Security Group (NSG) that allows inbound SSH (port 22).
  • Attach a 30 GB storage disk of type Standard HDD.
  • The rest of the configurations should remain as default.
  • After completing these steps, make sure you can SSH into the virtual machine.
az vm create \
  --resource-group <RESOURCE_GROUP_NAME> \
  --name devops-vm \
  --image Ubuntu2204 \
  --size Standard_B1s \
  --admin-username <username> \
  --admin-password <password> \
  --location westus \
  --authentication-type password \
  --os-disk-size-gb 30 \
  --storage-sku StandardHDD_LRS \
  --nsg-rule SSH

3. Create a Virtual Network (VNet) in Azure

Create a Virtual Network (VNet) named datacenter-vnet in the East US region with any IPv4 CIDR block.

az network vnet create \
  --name datacenter-vnet \
  --resource-group <RESOURCE_GROUP_NAME> \
  --location eastus \
  --address-prefix 10.1.0.0/16 \
  --subnet-name default \
  --subnet-prefix 10.1.0.0/24

4. Create a Virtual Network (IPv4) in Azure

Create a Virtual Network (VNet) named datacenter-vnet in the East US region with 192.168.0.0/24 IPv4 CIDR.

az network vnet create \
  --name datacenter-vnet \
  --resource-group <RESOURCE_GROUP_NAME> \
  --location eastus \
  --address-prefix 192.168.0.0/24 \
  --subnet-name default \
  --subnet-prefix 192.168.0.0/25

5. Create a Virtual Network (IPv6) in Azure

Your Azure subscription must have IPv6 support enabled, and the IPv6 address space must be assigned or allowed. Azure typically only allows manually specified IPv6 prefixes if:

  • You have BYOIP (Bring Your Own IP)
  • Or you’ve configured an IPv6 range via Microsoft
  • Otherwise, attempting to use a manual IPv6 prefix will fail.
az network vnet create \
  --name nautilus-vnet \
  --resource-group <RESOURCE_GROUP_NAME> \
  --location eastus \
  --address-prefixes 192.168.10.0/24 2600:abcd:1234::/48 \
  --subnet-name default \
  --subnet-prefixes 192.168.10.0/25 2600:abcd:1234::/64 \
  --stack DualStack

6. Create a Subnet in Azure Virtual Network

1
2
3
4
5
6
7
8
# Create the Virtual Network with subnet
az network vnet create \
  --name nautilus-vnet \
  --resource-group <RESOURCE_GROUP_NAME> \
  --location eastus \
  --address-prefix 10.0.0.0/16 \
  --subnet-name nautilus-subnet \
  --subnet-prefix 10.0.1.0/24

7. Create a Public IP Address for Azure VM

1
2
3
4
5
6
az network public-ip create \
  --name devops-pip \
  --resource-group <RESOURCE_GROUP_NAME> \
  --location eastus \
  --allocation-method Static \
  --sku Standard

8. Delete Azure Virtual Machine Using Console

1
2
3
4
5
6
7
8
9
# Delete the VM
az vm delete \
  --name devops-vm \
  --resource-group <RESOURCE_GROUP_NAME> \
  --yes

az vm show \
  --name devops-vm \
  --resource-group <RESOURCE_GROUP_NAME>

9. Delete Azure Virtual Machine Using CLI

1
2
3
4
5
6
7
8
9
# Delete the VM
az vm delete \
  --name devops-vm \
  --resource-group <RESOURCE_GROUP_NAME> \
  --yes

az vm show \
  --name devops-vm \
  --resource-group <RESOURCE_GROUP_NAME>

10. Delete a Virtual Network (VNet) in Azure

1
2
3
4
5
6
7
8
9
10
11
12
13
# Find which resource group the vm is in
az network vnet list \
  --query "[?name=='nautilus-vnet'].{Name:name,ResourceGroup:resourceGroup,Location:location}" \
  -o table

# Delete the vnet
az network vnet delete \
  --name nautilus-vnet \
  --resource-group <RESOURCE_GROUP_NAME>

# Verify
az network vnet list \
  --query "[?name=='nautilus-vnet']"

11. Add and Manage Tags for Azure Virtual Machines

1
2
3
4
5
6
7
8
# Find the resource group
az vm list \
  --query "[?name=='nautilus-vm'].{Name:name,ResourceGroup:resourceGroup}"

az vm update \
  --name nautilus-vm \
  --resource-group "KML_RG_MAIN-4531D963C9DF4D7D" \
  --set tags.Environment=devqqqaa

12. SSH into an Azure Virtual Machine

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Verify the VM is running
az vm get-instance-view \
  --name devops-vm \
  --resource-group <RESOURCE_GROUP_NAME> \
  --query "instanceView.statuses[?starts_with(code,'PowerState/')].displayStatus" \
  -o tsv

# Get Public IP
az vm list-ip-addresses \
  --name devops-vm \
  --resource-group <RESOURCE_GROUP_NAME> \
  -o table

# Delete the defaults under:
/root/.ssh/authorized_keys

# Copy the public key to the root user on the vm
ssh azureuser@<VM_PUBLIC_IP> "sudo mkdir -p /root/.ssh && sudo chmod 700 /root/.ssh"
scp /root/.ssh/id_rsa.pub azureuser@<VM_PUBLIC_IP>:/tmp/root_id_rsa.pub
ssh azureuser@<VM_PUBLIC_IP> "sudo sh -c 'cat /tmp/root_id_rsa.pub >> /root/.ssh/authorized_keys && chmod 600 /root/.ssh/authorized_keys && rm /tmp/root_id_rsa.pub'"

13. Attach Managed Disk to Azure Virtual Machine

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# View subscriptions
az account list --output table

# Get the resource group
az group list --output table

# Get the resources
az resource list --resource-group kml_rg_main-76a5353ab82c4226 --output table

# Verify the vm is running
az vm list --show-details --output table

# Attach the disk
az vm disk attach \
  --resource-group kml_rg_main-76a5353ab82c4226 \
  --vm-name nautilus-vm \
  --name nautilus-disk

# Verify disk is attached
az vm show \
  --resource-group kml_rg_main-76a5353ab82c4226 \
  --name nautilus-vm \
  --query "storageProfile.dataDisks[].name" \
  -o tsv #Returns nautilus-disk

14. Attach Network Interface Card (NIC) to Azure Virtual Machine

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# Get the resource group
az group list -o table

rg=<resource_group>

# Stop the VM
az vm deallocate \
  --resource-group kml_rg_main-2d36d4a7006746af \
  --name xfusion-vm

# Attach the nic
az vm nic add \
  --resource-group $rg \
  --vm-name xfusion-vm \
  --nics xfusion-nic

# Start the vm
az vm start \
  --resource-group $rg \
  --name xfusion-vm

# Verify nic is attached
az vm show \
  --resource-group $rg \
  --name xfusion-vm \
  --query "networkProfile.networkInterfaces[].id" \
  -o table

15. Attach Public IP to Azure Virtual Machine

1

16. Change Azure Virtual Machine Size Using Console

1

17. Create and Attach Managed Disks in Azure

1

18. Create and Configure Network Security Group (NSG) in Azure

1

19. Create a Private Azure Blob Storage Container

1

20. Create a Public Azure Blob Storage Container

1

21. Backup and Delete Azure Storage Blob Container

1

22. Copy Data to an Azure Blob Storage Container

1

23. Convert Public Azure Blob Container to Private

1

24. Create Azure SQL Database

1

25. Backup an Azure SQL Database

1

26. Deploy Azure Resources Using ARM Template

1

27. Create VM using Azure CLI

1

28. Change Azure Virtual Machine Size Using CLI

1

29. Create a Public Blob Container Using Azure CLI

1

30. Create a Private Blob Container Using Azure CLI

1
This post is licensed under CC BY 4.0 by the author.

Trending Tags