Realm and Microsoft Azure
The Realm solution is incredibly flexible, capable of running on any device, extending any data source, with any Cloud. Here we outline the various steps and best practices to utilize Microsoft Azure as one Cloud solution; additionally, Realm is happy to host and manage your deployment for you, either in our Cloud or your Cloud, via our dedicated and managed Cloud deployment options. Please contact us if you’d like Realm to run the service for you as a dedicated or managed Cloud instance.
Getting Started with Realm Platform on Microsoft Azure
Overview The Realm Platform is a combination of a relational database server and client components connected via a fast and efficient sync protocol to enable real-time, connected apps and services that are responsive and performance irrespective of network status. The Realm Platform has two major components: the Realm Database and the Realm Object Server (ROS). These two components work in conjunction to automatically synchronize data enabling a large number of use cases ranging from offline first apps, field service and data collection apps, mobile services where data availability and user responsiveness is key. In addition through the integration capability with existing backends (SQL, Kafka, etc) Realm Platform is an excellent way to build a modern and real-time service experience while leveraging existing (and sometimes legacy) systems and data sources. To enable data synchronization, the ROS must be properly deployed and hosted. This document will show how easy it is to do this on Microsoft Azure which is already used by many of Realm’s enterprise customers.
Prerequisites
- A Realm Object Server Feature Token (https://realm.io/trial/self-hosted-standard-plan/)
- A Microsoft Azure Account
- An Azure Kubernetes Service (AKS) powered cluster (or the ability to create one)
- Experience developing mobile applications
Setting up the Realm Object Server in Azure In this section of the documents, we’ll show you everything needed to get a Realm Object Server running within your Microsoft Azure account. We’ll start by creating a cluster (if you do not yet have one). Then we’ll configure Helm and Tiller which are needed to easily deploy the server. Finally, you’ll deploy the server using Helm and inspect it to make sure the deployment was successful.
Create a Cluster with Azure Kubernetes Service if you do not already have one
Creating a cluster is easy with AKS. You can use Microsoft’s quickstart guide as a reference. You’ll want to take note of the project and cluster names that you use as you’ll need these later. We recommend a node size between 4-7 for a typical application deployment. For development purposes, feel free to start with a lower node count. It is also important to take note if you are using a RBAC enabled cluster (which is recommended for production applications).
After you create the cluster, we recommend ensuring that you can connect via the kubectl CLI. This is also explained in the quickstart guide. At the time of writing, you can do this from an Azure cloud shell with the following command:
##input your cluster information for connection
az aks get-credentials --resource-group myResourceGroup --name myAKSCluster
##verify connection by getting cluster information
kubectl get nodes
Prepare Helm and Tiller We use a Helm chart to distribute the recommended deployment architecture for the Realm Object Server. As a result, you’ll need to make sure it is configured properly for your environment. Luckily, using Helm and Tiller in Azure is easy, and you will find the process documented here. We recommend using the Azure Cloud Shell which comes with the Helm CLI already installed. After this, you will need to configure Helm which is detailed in the article linked above.
Note: If you are using an RBAC-enabled cluster, you will also need to create a service account to run tiller properly.
Deploy the Realm Object Server via Helm Add the chart repository Our charts are hosted on Github, and can be added to Helm with the following command:
helm repo add realm [https://realm.github.io/charts](https://realm.github.io/charts/ "Realm Helm Charts")
Prepare overrides file You should have access to a Realm Object Server Feature Token. This token must be passed to our Helm chart in order for Realm Object Server to operate. You can do so with an overrides file that preempts the Helm chart’s values file:
overrides.yaml
sync:
featureToken: YOUR_FEATURE_TOKEN_HERE
Deploy Realm Object Server
Once you have created an overrides file, you can use it when deploying:
helm install realm/realm-object-server -f overrides.yaml
When successful, you should see some output similar to:
NAME: foolish-octopus
LAST DEPLOYED: Thu Jun 21 20:11:02 2018
NAMESPACE: default
STATUS: DEPLOYED
RESOURCES:
==> v1/Role
NAME AGE
foolish-octopus-sync-default 1s
==> v1/StatefulSet
NAME DESIRED CURRENT AGE
foolish-octopus-sync-default 1 1 1s
==> v1/RoleBinding
NAME AGE
foolish-octopus-sync-default 1s
==> v1/Service
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
foolish-octopus-realm-object-server NodePort 10.103.219.36 <none> 80:30080/TCP 1s
foolish-octopus-metrics ClusterIP 10.110.66.250 <none> 9081/TCP 1s
foolish-octopus-sync-default ClusterIP 10.105.177.213 <none> 7800/TCP,9080/TCP 1s
==> v1/Secret
NAME TYPE DATA AGE
foolish-octopus Opaque 1 1s
==> v1/ConfigMap
NAME DATA AGE
foolish-octopus 3 1s
==> v1/ServiceAccount
NAME SECRETS AGE
foolish-octopus-sync-default 1 1s
==> v1/Deployment
NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE
foolish-octopus-realm-object-server 1 1 1 0 1s
==> v1/Endpoints
NAME ENDPOINTS AGE
foolish-octopus-sync-default <none> 1s
==> v1/Pod(related)
NAME READY STATUS RESTARTS AGE
foolish-octopus-realm-object-server-547948d998-zgwbq 0/1 ContainerCreating 0 1s
foolish-octopus-sync-default-0 0/1 ContainerCreating 0 1s
As you can see, Helm named our deployment foolish-octopus. You can set your own name for the deployment at installation by using the chart–name parameter.
Check the status of your deployment: To check the status of your deployment simple run the following command and check the individual statuses of each component
helm list
For future reference, you can uninstall Realm Object Server using the following command. If you get stuck, this might be the best course of action, after which you can start over: helm delete –purge foolish-octopus More information for troubleshooting with kubectl can be found here.
Developing a Mobile Application with Realm Sync Once you have a Realm Object Server deployed, we can start to synchronize data between mobile apps via shared Realm databases. We support the following mobile development platforms:
- Native iOS: Swift, Objective-C
- Native Android: Java, Kotlin
- Cross-Platform: Xamarin, React Native
Start by Creating a Sample ToDo List Application The majority of our users start by following our basic ToDo app tutorial. Below you’ll find links for the major platforms:
Learn More of our Best Practices for Building an App with Realm Once you have some familiarity with how to develop with Realm, we strongly recommend reading over our detailed guide on how to properly build an app using Realm sync. This guide goes through important topics from architectural decisions to optimizing reads and writes. We consider this a must read for anyone who wants to build a highly scalable production application using the Realm Platform. https://docs.realm.io/sync/additional-resources/how-to-build-an-app-with-realm-sync