Set up the DB
Form.io's data model is driven by MongoDB. Deployments to Azure may use MongoDB Atlas or the Azure-native CosmosDB.
Form.io requires a MongoDB-compatible database to run its platform. Refer to the process that matches the anticipate deployment stack:
MongoDB Atlas
Azure CosmosDB
MongoDB Atlas
Before deployment, create an account at MongoDB.com/atlas. Follow the steps provided by MongoDB to create the cluster while observing the guidelines described below.
Performance
When configuring the performance of the cluster, it may be necessary to review the advanced settings. The particular settings selected may depend on the planned deployment. The following baseline standard may be used when determining the application's needs:
For production environments, the dedicated tier may be required.
Consider enabling multi-region replication to create additional instances for greater availability.
Choose a sufficient cluster tier based on the expected usage. M10 is typically sufficient for development. M20 is the recommended baseline for production.
Security
When configuring the security settings in MongoDB Atlas after clicking Create Cluster, refer to the following guidelines:
Record the username and password for use in the connection string later.
Ensure the IP address of the Azure VM is added to the whitelist.
If the deployment requires additional security that would mandate a private endpoint, refer to the MongoDB Documentation regarding connecting cloud services to a private endpoint.
Connection String
From the MongoDB Atlas Project Overview, open the Connect Menu and generate a legacy (standard) connection string. It will appear similar to the following:
mongodb://formio:<db_password>@<node1>,<node2>,<node3>/<dbName>?replicaSet=<replicaSetName>&ssl=true&authSource=admin&retryWrites=true&w=majority&appName=<appName>
Note the following placeholders:
<node1>... : These will correspond to the individual instances of the DB.
<replicaSetName>: The atlas-generated replica set name.
<appName>: Typically formio.
<dbName>: Typically formio (added by us).
Supplying the required info creates a connection string similar to the following, using the example password badPassword:
mongodb://formio:[email protected]:27017,formio-shard-00-01.qa5hm.mongodb.net:27017,formio-shard-00-02.qa5hm.mongodb.net:27017/formio?replicaSet=atlas-6fxuzs-shard-0&ssl=true&authSource=admin&retryWrites=true&w=majority&appName=formio
Note that the database name formio
is added so that the Form.io deployment will initialize with this database instead of the default test
database.
Also observe that ?ssl=true
indicates a database connection over SSL, &retryWrites=true
indicates retryWrites is supported, and uses the admin
database rather than IAM to authenticate.
Record this connection string for later.
Cosmos DB
Follow these instructions to setup a new database.
Go to Cosmos DB in your Azure portal
Create an Azure Cosmos DB for MongoDB (vCore)
We recommend (as does Azure) using a vCore-based DB since it has more comprehensive support for native MongoDB features and certain Form.io functionality may be impaired if using an RU-based DB. Here is documentation regarding migrating from RU to vCore.
Once the DB is created, copy the connection string for use in your Form.io deployment.
mongodb+srv://formiodbusername:<password>@formio-cosmos-db.global.mongocluster.cosmos.azure.com/<db_name>?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=true&maxIdleTimeMS=120000
After copying it, you'll need to add your Form.io database name (
<db_name>
above) and the password. This name (formio
for example) is placed in-betweenformio-cosmos-db.global.mongocluster.cosmos.azure.com/
and?tls=true
. The filled-in connection string should look like this:mongodb+srv://formiodbusername:supersecretpassword@formio-cosmos-db.global.mongocluster.cosmos.azure.com/formio?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=true&maxIdleTimeMS=120000
Last updated
Was this helpful?