AnnouncementIntroducing MongoDB 8.0, the fastest MongoDB ever! Read more >>

Migrating Parse with Microsoft Azure and MongoDB Cloud Manager

  1. Configure Subnets and Network Security Groups
  1. Provision Ubuntu 14.04 Servers with Azure
  1. Configure MongoDB with Cloud Manager
  1. Deploy Parse Server to Azure VM
  1. Test Parse Server
  1. Migrate From Parse API

  1. Configure Subnets and Network Security Groups


Requirements

  • Credit Card
  • Phone Number
  • Azure Subscription

Overview

Using Azure, we will want to first create the networks that we will be provisioning, as well as configure the traffic between them in a way that keeps our database deployments secure. Conceptually, we will be configuring our deployment to reflect the diagram below. Diagram

The specifications we recommend for running MongoDB on Azure will exceed the core quota restrictions imposed by Microsoft on their Azure free trial subscription. To provision machines suitable for migrating Parse to a performant system, consider purchasing a paid Azure subscription.

Instructions

  1. Create a virtual network in Azure (mongo-resource-group)
  2. Create two subnets in the virtual network with address ranges as below Diagram
  3. Create two Network Security Groups (parse-server and mdb-parse) and configure inbound rules for each one as per the diagrams below.

Diagram

Diagram - Note that 54.85.224.0/20 corresponds to the public IP range of the Parse migration servers. Allowing traffic from this address space is required for the Parse migration process.

  1. Under mongo-resource-group > Settings > Subnets associate your two subnets with the appropriate network security groups as below. Diagram

  2. You have now configured your virtual network and created two subnets into which we will be provisioning our servers with Azure.

  1. Provision Ubuntu 14.04 Servers with Azure

Requirements

  • File Storage, Data Storage, and Data Transfer Rate from Parse dashboard

Before you begin

Size your Instances

During this stage, you will provision Microsoft Azure instances to run your database processes. To help you best size your deployment, we have created a sizing chart. To use the worksheet, first get your Data Storage, and Data Transfer Rate per month from the Parse dashboard.

Choose the cell in the sizing chart that matches your usage profile. Note this down, as we will use it later in the instructions to determine which machine to provision. All sizes in this chart correspond to the size of the premium storage disk to be attached to your VM.

 Low Data Transfer RateHigh Data Transfer Rate
Parse Data Storage < 4GBDS3, 128GBDS4, 512GB
Parse Data Storage > 4GBDS3, 512GBDS4, 512GB
Azure instance sizing chart

Instructions

  1. Sign in to portal.azure.com
  2. Under New > Compute > Ubuntu Server 14.04 LTS create a new virtual machine using Resource manager

Image

  1. Configure the machine, using the Azure Instance Sizing Guide to determine which instance type to launch, and which storage to attach.

Image Image

  1. Ensure that you deploy your instances into the mdb-subnet as configured in the previous stage of the guide.

Image

  1. Review and deploy the instance.

Image

  1. We will now need to attach a premium storage disk and mount it on our Ubuntu VM. Navigate to All resources > mdb-parse-0 > Settings > Disks and select Attach new.
  2. Choose a disk size corresponding to your deployment on the Azure Instance Sizing Chart above.

Image
8. ssh into your newly provisioned Azure instance using the username and password provided during creation. 9. Initialize the disk on your VM

sudo fdisk /dev/sdc
# when prompted enter 'n' for new partition
# then enter          'p' for primary
# then enter          '1' for 1st partition
# then enter          ''  for default first sector
# then enter          ''  for default last sector

Image

# then enter          'p' to review new partition
# then enter          'w' to finalize and write your changes

Image

  1. Make the file system on the device.
sudo mkfs -t ext4 /dev/sdc1   # note partition number appended to device id

Image 11. Create the data directory and mount the premium storage disk there.

sudo mkdir /data
sudo mount /dev/sdc1 /data
  1. Use sudo -i blkid to determine the UUID associated with your device Image

  2. Modify /etc/fstab to automatically mount disk on reboot.

sudo sed -i -e "\$aUUID=<SDC1-UUID>   /data   ext4   defaults   1   2" /etc/fstab
  1. Mount and unmount the device to make sure the configuration is properly set-up. If everything is properly configured, there should be no errors.
sudo umount /data
sudo mount /data
  1. Repeat steps 2-14 to provision 2 more instances, named “mdb-parse-1” and “mdb-parse-2” respectively.

  1. Configure MongoDB with Cloud Manager

Requirements

  • SSL Certificate from trusted Certificate Authority (for secure deployment)
  • MongoDB Cloud Manager Account

Before you begin

Generate SSL Certificates

For a secure deployment, one should enable TLS/SSL for traffic between the MongoDB database and the application server, as well as for traffic between the members of a MongoDB replica set.

For development purposes, you can configure a local certificate authority and generate your own certificates with openssl for the hosts provisioned by Cloud Manager.

Self-signed certificates, however, are still vulnerable to man-in-the-middle attacks and secure deployments should use an SSL/TLS certificate from a trusted Certificate Authority.

Instructions

  1. Log into Cloud Manager and navigate to Deployment > Agents > Downloads & Settings from the main dashboard.
  2. Under Automation click the link for Ubuntu (12.X, 14.X) - DEB and follow the instructions to install an automation agent on each of the virtual machines provisioned in the previous step.

Image

  1. Change ownership of the /data directory to the mongodb user on all virtual machines to allow automation to provision correctly
sudo chown mongodb:mongodb /data
  1. Once all agents have been installed, navigate to Deployment > Servers, and verify that you see the three servers which you installed the automation agents on.
  2. Click the ellipses on one of your servers and click Install Monitoring Agent.

Image

  1. Click Review & Deploy, then Confirm & Deploy.
  2. Click +Add and select New Replica Set.

Image

  1. Configure your replica set as below:

Image

  1. Ensure that each server contains one mongodb-rs member

Image

  1. Click Review & Deploy, then Confirm & Deploy.
  2. Click the Modify wrench icon to open the Replica Set editor.
  3. Expand Advanced Options, and click the Add Option button.
  4. Add the option:
    • Startup Option: “failIndexKeyTooLong”
    • Value: false
  5. It is strongly recommended that you configure TLS/SSL for your deployment before migrating from Parse. Instructions on how to do this can be found in the Cloud Manager documentation
  6. Click Apply, and again Review & Deploy your changes.
  7. We will now configure a user for you to connect to your database with. Click on Authentication & Users on the left side of the UI.
  8. Click Add user and create a new user with the specs below. Don't forget to save the password!
    • database: “admin”
    • username: “testuser”
    • roles: root@admin
  9. Construct an internally usable MongoDB Connection String. First, record the three replica set members’ hostnames and ports visible in Cloud Manager. We will then combine the hostnames with their respective ports, separated by commas, along with the username and password, replica set name (replicaSet) and SSL parameters as below:
mongodb://testuser:testpass@<HOSTNAME-0>:27017,<HOSTNAME-1>:27017,<HOSTNAME-2>:27017/parse?replicaSet=mongodb-rs&ssl=true

More detailed information on the connection string format can be found in the MongoDB documentation.

  1. Deploy Parse Server to Azure VM

Requirements

  • Internally visible MongoDB connection string as constructed in previous section

Instructions

  1. Provision a Ubuntu Server 14.04 Azure VM with the D1 instance size.

Image

  1. Ensure that the new parse-server virtual machine is provisioned on the “parse-subnet” subnet configured earlier.

Image

  1. ssh into newly provisioned machine and install Node.JS and git.
curl -sL https://deb.nodesource.com/setup_5.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo apt-get install -y git
  1. Clone the parse-server github repository for the latest code.
git clone https://github.com/ParsePlatform/parse-server.git
  1. Configure environment variables for run. Replace <MONGO-CONNECTION-STRING> with the connection string obtained earlier, and replace <APP-ID> and <MASTER-KEY> with the appropriate values for your deployment.
# configure environment variables and run.
export PARSE_SERVER_DATABASE_URI='<MONGO-CONNECTION-STRING>'
export PARSE_SERVER_APPLICATION_ID='<APP-ID>'
export PARSE_SERVER_MASTER_KEY='<MASTER-KEY>'
  1. Run the Node.JS application
npm install
npm start
  1. Get the public IP address of your parse-server instance from the Azure portal and use curl to test that everything is functioning properly.
curl -X POST \
  -H "X-Parse-Application-Id: ${MY_PARSE_APP_ID}" \
  -H "X-Parse-Master-Key: ${MY_PARSE_MASTER_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
  http://<PARSE-SERVER-PUBLIC-IP>:1337/parse/classes/GameScore
curl -X GET \
  -H "X-Parse-Application-Id: ${MY_PARSE_APP_ID}" \
  -H "X-Parse-Master-Key: ${MY_PARSE_MASTER_KEY}" \
  http://<PARSE-SERVER-PUBLIC-IP>:1337/parse/classes/GameScore

  1. Test Parse Server

Please use your standard application tests to ensure all functionality works on your new, open source Parse infrastructure. The open source parse-server package does not cover the complete feature set offered by Parse, and your application may not function exactly the same as before. The Parse migration guide has more details on the differences between Parse and parse-server in "Section 8 - Compatibility Issues". We urge users to read these sections carefully and test their apps thoroughly before moving forward with a full migration. If you are interested in getting help with this process, or learning more about your options for running your own MongoDB deployment, our professional services team is here to speak with you.

  1. Migrate From Parse API

Requirements

  • MongoDB replica set on Azure
  • Access to Parse admin dashboard
  • User with admin privileges on MongoDB replica set

Instructions

  1. Go to the new Parse dashboard, navigate to App Settings and click on Migrate to external database.

    Image

  2. Provide the MongoDB connection string which we constructed earlier, but replace the internally resolvable hostnames with publicly resolvable IP addresses as below. Ensure that the database pointed to by your connection string is empty.

mongodb://testuser:testpass@<HOST-IP-0>:27017,<HOST-IP-1>:27017,<HOST-IP-2>:27017/parse?replicaSet=mongodb-rs&ssl=true
  1. Click the Begin the migration button.

Image

  1. Ensure that data is written to your MongoDB Replica Set.