OPS705 Lab 1

From CDOT Wiki
Revision as of 15:02, 21 January 2023 by Chris.johnson (talk | contribs) (INVESTIGATION 3: Managing a CentOS Linux VM in Azure)
Jump to: navigation, search

LAB PREPARATION

Purpose / Objectives of Lab 1

In this lab, you will login to Microsoft Azure for the first time, navigate your way to DevTest Labs, and spin up two VM images. The main purpose of this lab is to learn how to create Windows and Linux virtual machines using a pre-built image, how to remotely connect to each, and basic management of these VMs from the Azure web interface. These two VMs will be used extensively in your later labs.

While you are working through this lab, it is highly recommended that you write down general notes and commands to help you remember how to do this lab. You may use your notes during tests, so fill it out accordingly!

If you encounter technical issues, please contact your professor via e-mail or in your section's Microsoft Teams group.

Minimum Requirements

Before beginning, you must have:

  1. Attended the Week 1 lectures (or watched the posted recording)
  2. Your Seneca login credentials
  3. A mobile device (phone/tablet) to setup 2FA (two-factor authentication)
  4. Your printed copy of the OPS705 Lab Logbook - Azure PDF

INVESTIGATION 1: Connecting to Your Azure Account

In this investigation, you'll log in to your Seneca-provided Azure account and ensure you have access to our DevTest Labs classroom.

Part 1: Logging In For The First Time

  1. Follow the link to our DevTest Lab in Azure found on Blackboard.
  2. Enter your Seneca credentials. (Same username and password you use for your e-mail)
  3. You'll next be asked to set up two-factor authentication. Do not bypass this step!
  4. Once you've set that up, verify it by logging out and logging back in again.
  5. Conduct a small celebration (pat on the back, a quick jig, perhaps a fist pump) and move on to Investigation 2.

Part 2: Logging In Afterwards

Logging in after initial setup is quite easy.

  1. Navigate to the Azure portal: https://portal.azure.com
  2. Use your Seneca credentials.
  3. Complete 2FA authentication.
  4. Our classroom DevTest Lab will be in your recent list, or you can use the search bar to bring up DevTest Labs by looking for OPS705. (Do not search for Virtual Machines in the search bar. You will find yourself in the wrong area and things will not work.)

INVESTIGATION 2: Managing a Windows Server 2019 VM in Azure

In this investigation, you'll create, configure, and manage a Windows Server 2019 Virtual Machine using Microsoft Azure and a pre-built image. This means no tedious and time-consuming Windows installation! You'll also login to the VM remotely, using Microsoft's Remote Desktop Protocol to share its desktop.

Part 1: Creating A Windows VM From An Image

Figure 1. A partial view of the Basics tab on the VM creation page.

To create your Windows Server 2019 Virtual machine, perform the following steps:

  1. Navigate to DevTest Labs > OPS705 > My virtual machines
  2. Click the + Add button.
  3. Wait for the Choose a base listing to populate. This may take a few moments.
  4. Select the item titled Windows Server 2019 Datacenter (Gen 2). Be careful here! There are many other options.
  5. A new blade, Create lab resource appears.
  6. In the Virtual machine name field, type: yourSenecaUsername-win (you only have 15 characters, you may need to abbreviate)
  7. Username: yourSenecaUsername
  8. Use a saved secret: Unchecked
  9. Password: Your choice, but use the same for all VMs and resources in this course.
  10. Save as default password: Checked.
  11. Virtual machine size: Standard_B2ms
  12. OS disk type: Standard HDD
  13. Leave the remaining options as they are.
  14. Click on the Create button at the bottom of the screen.
  15. You are now back in the My virtual machines blade while Azure creates your personal virtual machine. This may take a few minutes.
  16. When it finishes, you should see a Your deployment is complete. message near the top of the page. Congratulations!
  17. Click on the Go to resource button at the bottom left of the page and move on to the next section of the lab.

Part 2: Accessing Your Windows VM Remotely Using RDP

Figure 2. The Remote Desktop Connection application on Windows.

In this section, we'll discover how to remotely connect to the Windows Server's desktop environment over the Internet from your computer. It's a very simple process.

  1. In the Overview tab for the Virtual Machine created in Part 1, click the Connect button. This will download an RDP profile file (usually vmname.rdp).
  2. Open the RDP file. It should launch the Remote Desktop application and automatically try to connect to your VM.
  3. Upon opening, the VM's URL, port number, and username are automatically provided.
  4. Type the password you used when creating the VM in Part 1.
  5. Accept the certificate warning. (Click yes.)
  6. You should see a login progress screen, and a Windows Server desktop after a few moments.
  7. Congratulations! You've set up a Windows Server VM and logged in remotely.
  8. Open Notepad, and write My name is insertFullName, and I've completed the Lab 1 Windows Server VM investigation! Save the file to your VM's desktop, with the filename yourSenecaUsername.txt.
  9. Do not skip Part 3 at this stage! Otherwise, you'll be bleeding funds by leaving the VM running.

Part 3: Fully Stopping Your Windows Virtual Machine

Figure 3. Overview blade for the winserv VM. Notice its status.

This section is fairly simple. The one thing to never forget: Ensure your VM's status is set to Stopped (Deallocated).

  1. In the Overview blade of your Windows Server VM, click on the Stop button.
  2. A notification will appear in the top right of your browser window, confirming your action.
  3. Don't worry about going into the Windows OS and shutting down first. Azure sends a signal to the VM to shut down safely.
  4. If your VM status says stopped, but does not include the (Deallocated) text, then resources are still being held by the VM and we're still being charged. The stop button will still be available, so click it.

INVESTIGATION 3: Managing a CentOS Linux VM in Azure

In this investigation, we'll create, configure, and manage a CentOS Minimal Virtual Machine using Microsoft Azure. This is a command line only OS, so you'll be using SSH to remotely connect to the VM and issue basic commands. This VM will be used extensively in Lab 2.

Part 1: Creating A CentOS VM From An Image

Figure 4. Searching for a CentOS 7.8 Minimal image.

To create your CentOS VM, follow the steps from Investigation 2, Part 1, but with the following settings:

  1. Choose a base: CentOS-based 7.9
  2. Virtual machine name: yourSenecaUsername-lnx
  3. User name: yourSenecaUsername
  4. Authentication type: Password
  5. Use a saved secret: Unchecked
  6. Password: Same as your Windows Server VM
  7. Save as default password: Checked
  8. Virtual machine size: Standard_B1s
  9. Click on the Advanced Settings tab.
  10. Under IP address, select Public.
  11. Click back to Basic Settings.
  12. Leave all other options as they are.
  13. Click Create!

When deployment is complete, click on the new VM in My virtual machines to verify its status and find the VM's address. Write this down.

Part 2: Accessing Your CentOS VM Remotely Using SSH

Figure 5. Logging in with the Command Prompt from Windows.

We will be accessing our new Linux VM remotely using SSH.

Requirements: An SSH Client

  1. Windows: Use the built-in Command Prompt.
  2. macOS/Linux: Use the built-in Terminal application.

In the Overview tab for the Virtual Machine created in Part 1, look for the IP address or FQDN entry. This is the address you will use to connect in this section. Write it down (Hover over the URL, and you'll see a Copy to clipboard icon).

On Windows Using Command Prompt, or macOS/Linux Using Terminal:

  1. From the command line, type ssh yourSenecaUsername@address, press Enter. (Use the address from the Overview tab).
  2. When prompted for a password, use the one you gave when you created the VM. (You won't see anything as you type here; that's normal.)
  3. If login is successful, you should see a prompt like this: [cjohnson30@cjohnson30-lnx ~]$
  4. To prove you've completed this section, run the following command: hostnamectl
  5. Take a full desktop screenshot of the results in the above step.
  6. To quit, type exit.

Part 3: Downloading OPS705 Lab Files

Figure 6. Lab files downloaded to CentOS.

A number of files have been created for you that you need for the next several labs. These must be downloaded to your CentOS VM using the following steps:

  1. Install git: sudo yum -y install git
  2. Using git, download all lab files into your bin directory: git clone https://github.com/ops705/labs.git ~/bin/
  3. We'll explore how these two commands work in more detail over the next few weeks.
  4. Run the following command to show you've properly downloaded all lab files, and take a screenshot of the result: ls -lh ~/bin

Part 4: Adding Your Professor's Public Key

In this section, you will add your professor's public key to allow them to log in to your Linux VM and run lab checks and perform troubleshooting when needed.

  1. On Blackboard, find your professor's public key in Course Documents and copy the text from inside the file.
  2. Using the following command as your regular user, install your professor's public key on to your Linux VM (substitute <professorID> for the actual public key text): echo "<professorID>" >> ~/.ssh/authorized_keys

Part 5: Fully Stopping your CentOS VM

As with the Windows Server VM, fully deallocating your VM is essential to responsible usage.

  1. Click on the Stop button at the top of the VM's Overview blade.

That's it!

INVESTIGATION 4: Managing Your VMs Directly Through Azure's UI

In this quick investigation, we'll walk through how to directly manage virtual machines from the Azure Dashboard interface on a basic level. This is useful for starting up VMs, shutting them down when unresponsive, and deleting them when you're finished. (Warning: Do not delete either VM created in this lab!)

Important.png
After creating your VMs for the first time, you must log out and log back in to Azure.
When you first create a VM in DevTest Labs (DTL) and it's in a fully running state, you need to log out and log back into the Azure Portal for permissions to be added properly to your account. If you don't, you'll get Permission denied warnings from Azure if you try to do this investigation.

Part 1: Powering On A Virtual Machine

From the DevTest Labs blade:

  1. Click on the My virtual machines menu bar item.
  2. Click on the virtual machine you'd like to manage to move to its Overview blade.
  3. Click the Start menu button near the top.

Part 2: Powering Off A Virtual Machine

From the DevTest Labs blade:

  1. Click on the My virtual machines menu bar item.
  2. Click on the virtual machine you'd like to manage to move to its Overview blade.
  3. Click the Stop menu button near the top.

Remember the difference between the status Stopped and Stopped (deallocated)!

Part 3: Restarting A Virtual Machine

There are two methods to restarting a VM. Either within the OS, or through the Azure Dashboard.

Inside the OS:

  • Windows: Click on Start, and select Power Off.
  • Linux: From the command line (SSH), type sudo reboot

In either OS, you will be disconnected from your remote session. Wait a few minutes while the VM restarts, and reconnect.

From Azure Dashboard:

  1. Click on the Restart button from the VM's Overview blade.
  2. Wait until the VM's status has changed to Running before logging back in.

Part 4: Deleting A Virtual Machine

Deleting a Virtual Machine is useful when you no longer need it long-term, or if there's a catastrophic issue with the OS inside. Be careful! Any saved data inside the VM will be deleted as well!

  1. Navigate to the VM's Overview blade.
  2. If the VM status isn't Stopped (Deallocated), stop the VM. Wait until its status updates.
  3. Click on the Delete button at the top of the blade.

Part 5: A Note About Resource Usage

As mentioned during our lecture and throughout this lab, using resources responsibly is incredibly important. We pay for what we use. While we have a failsafe in place to stop all VMs at 2:00am EST daily, don't rely on it! Fully stop your VMs when you're not using them.

Your total allowed resource allocation has been restricted for this course. This means you can only have two VMs (or services) at a time. If you have two already, you won't be able to add another until you delete one.

Lab Submission

Submit to Blackboard full-desktop screenshots (PNG/JPG) of the following:

  1. Your view of the OPS705 DevTest Labs Overview blade.
  2. The Azure Overview blade for your Windows Server VM.
  3. The Azure Overview blade for your CentOS VM.
  4. The text file created for your Windows VM, open in Notepad.
  5. Your CentOS remote SSH session after running the command: hostnamectl
  6. The list of lab files downloaded to your CentOS VM.

Make sure to fully stop your VMs when you're done!