Transfering EC2 instance from AWs ro Azure

Hi Team ,

We would like to transfer our production instance to Azure. from Aws. I would really appreciate help on the steps that i can take to achieve this.

Hi Edwin,

Please provide more details on what your AWS setup looks like. As a general guide, container based deployments can be easily redployed to any cloud provider once data has been transferred.

1 Like

Hi Thankyou @elijah

It is an linux OS EC2 instance. Having with different containers which include,

  1. cht_nginx_1
  2. cht_sentinel_1
  3. cht_api_1
  4. cht_healthcheck_1
  5. cht_couchdb_1
  6. cht_haproxy_1

data stored in couchdb . home directory

Hi @Edwin !

@elijah is correct - the process should be pretty straight forward. You’re running on CHT 4.x in EC2 which means you’re running in Docker Compose. You’ll effectively be doing a backup and a restore, but instead of restoring to EC2, you’ll restore to Azure. The nice part about this is you can test the restore part multiple times before cutting over to the new instance.

Here’s the steps I suggest following, assuming you’re running a similar Azure VM as your EC2 VM (and not migrating to an Azure Kubernetes offering):

  1. Provision a Azure VM that has the same specs as your EC2 instance with the same RAM/CPU/Disk. Ensure it has a public, static IP
  2. Follow the production install docs on the new Azure VM. Ensure it works and there’s no issues. Be sure to use the same version of the CHT as you’re using on EC2. Take your time with this step - make sure the public IP works, make sure everything boots back up when you restart the machine. Make sure it’s up to date with the latest software. Having a DNS entry that is not your production URL will allow you to create a TLS certificate - this will be good for mobile handset testing.
  3. Make a backup of your old EC2 VM, following the backup docs. Be sure to stop all services before you make the backup as mentioned in the docs.
  4. Stop all services on the new Azure VM
  5. Copy the backup from the EC2 VM to the Azure VM. Restore the data by carefully copying the data into the correct directories. You may optionally not restore the compose files - but it is critical you restore the .env file. If you do not restore this file, specifically the COUCHDB_SECRET - all users will have to re-login and re-sync all data.
  6. Start all services on the Azure VM. Test that everything works.
  7. Ensuring that you’ve either copied over the TLS certs, or that you will create new ones - change DNS so your production URL points to Azure.
  8. DNS will take a moment to no longer be cached by the end user CHT apps. They will be unable to connect to the Azure VM until the DNS cache expires, but their CHT app will work offline as CHT is offline first.

Note that in step 3 you stopped all services on EC2 - so no users can connect. You may opt to follow steps 2-6 repeatedly, possibly even re-deploying the VM in step 1 if you get something wrong. This is fine! You have the luxury of not affecting production data. Just be sure that clients do not connect to the EC2 VM and write data to it unless you plan on re-running the backup → restore process.

Best of luck!

2 Likes

Hi @mrjones and @elijah

Thankyou for your help. I started a VM in Azure , Run the containers and directed the data to the new VM. All is working well

1 Like

Edwin,

Wonderful! Glad that all worked out - thanks for the update.

Any surprises or helpful tips you wished you knew before you got started? It’s always nice to share right after the upgrade so your memory is fresh. Thanks!

cheers,
-adj

2 Likes