Challenge 00 - Prerequisites - Ready, Set, GO!

Home - Next Challenge >

Introduction

Thank you for participating in the MongoDB to Azure DocumentDB Migration What The Hack. Before you can start hacking, you will need to set up some prerequisites.

Prerequisites

In this challenge, you will set up the necessary prerequisites and environment to complete the rest of the hack, including:

Azure Subscription

You will need an Azure subscription to complete this hack. If you don’t have one, get a free trial here…

Setup Development Environment

You will need a set of developer tools to work with the sample application for this hack.

You can use GitHub Codespaces where we have a pre-configured development environment set up and ready to go for you, or you can setup the developer environment on your local workstation using DevContainers.

Use GitHub Codespaces

You must have a GitHub account to use GitHub Codespaces. If you do not have a GitHub account, you can Sign Up Here.

GitHub Codespaces is available for developers in every organization. All personal GitHub.com accounts include a monthly quota of free usage each month. GitHub will provide users in the Free plan 120 core hours, or 60 hours of run time on a 2 core codespace, plus 15 GB of storage each month.

You can see your balance of available codespace hours on the GitHub billing page.

The GitHub Codespace for this hack will let you run the sample MFlix application which uses MongoDB as its database.

NOTE: Make sure you do not sign in with your enterprise managed Github account.

Once you are signed in:

Your Codespace environment should load in a new browser tab. It will take approximately 3-5 minutes the first time you create the codespace for it to load.

You are ready to setup the MongoDB source database. Skip to section: Setup the Source MongoDB Database

NOTE: If you close your Codespace window, or need to return to it later, you can go to GitHub Codespaces and you should find your existing Codespaces listed with a link to re-launch it.

Use Local Workstation

NOTE: You can skip this section if are using GitHub Codespaces!

If you want to setup this environment on your local workstation, expand the section below and follow the requirements listed. We have provided a Dev Container that will load the development environment on your local workstation if you do not want to use GitHub Codespaces.

Click to expand/collapse Local Workstation Setup
Download Student Resources

The Dev Container with the Mflix app is available in a Student Resources package.

The rest of the challenges will refer to the relative paths inside the Codespace or Resources.zip file where you can find the various resources to complete the challenges.

Set Up Local Dev Container

You will next be setting up your local workstation so that it can use Dev Containers. A Dev Container is a Docker-based environment designed to provide a consistent and reproducible development setup. The VS Code Dev Containers extension lets you easily open projects inside a containerized environment.

NOTE: On Windows, Dev Containers run in the Windows Subsystem for Linux (WSL).

On Windows and Mac OS (NOTE: only tested on Apple Silicon):

  • (Windows only) Install the Windows Subsystem for Linux along with a Linux distribution such as Ubuntu. You will need to copy the Resources.zip to your Linux home directory and unzip it there.
  • Download and install Docker Desktop
  • Open the root folder of the Student Resources package in Visual Studio Code
  • You should get prompted to re-open the folder in a Dev Container. You can do that by clicking the Yes button, but if you miss it or hit no, you can also use the Command Palette in VS Code and select Dev Containers: Reopen in Container


Setup MongoDB Source Database

You can choose to deploy a MongoDB instance in Docker container in Azure Container Instances with a deployment script or if you prefer, you can set up the source database in MongoDB Atlas instead manually.

Deploy MongoDB in Azure Container Instances

Login to the Azure CLI from the terminal in your GitHub Codespace or local workstation:

az login

NOTE: If you have access to multiple Azure subscriptions, you may need to switch to the subscription you want to work with.

If you are using GitHub Codespaces, the az login command will use a Device Code to login. If your organization’s Azure policy prevents this, follow these steps first before you run the deployment:

Optional: If you need to, you can specify the resourceGroupName and location as arguments to the deploy-target-db.sh script as follows. Note: It defaults to rg-mflix-documentdb and eastus2 for those, respectively:

  cd infra 
  chmod +x deploy-source-db.sh
  ./deploy-source-db.sh --resourceGroupName <your_resource_group_name> --location westus --administratorLogin mflixadmin --administratorPassword <password>

Deploy MongoDB in Atlas

If you want to deploy to MongoDB Atlas instead, go to this link: Get Started With Atlas.

Run the MFlix Application

The sample MFlix application is implemented as a Node.js application. You will be running this application either within your GitHub Codespace or Dev Container for simplicity. In practice, it would be deployed as a container into Azure.

In a Terminal session in VSCode, navigate to the MFlix folder and run the application:

# Starts up the MFlix web application 
npm start

You should see a message in Visual Studio Code that your Application running on port 5001 is available. Click the Open in Browser button to open the MFlix application. Try it out!

Note: If you need the username and password you chose during the MongoDB deployment, they are stored in the MFlix/.env file in the MFLIX_DB_URI connection string.

Success Criteria

To complete this challenge successfully, you should:

Learning Resources