How to deploy the MongoDB Atlas Boilerplate
Preview
The MongoDB Atlas Boilerplate allows you to deploy an application integrated with MongoDB Atlas on the edge. Besides, due to the integration with the Atlas Data API, you’re able to create, retrieve, update, and delete items in your collections through standard HTTPS requests.
By using Azion Edge Platform to run your database project, your digital data and assets benefit from edge computing capabilities, including faster delivery, lower latency, and enhanced security.
Requirements
Before using this template, you need to:
- Create a MongoDB account.
- Create a cluster and add a new database.
- Create a collection to be used with this template.
- Active the service Atlas Data API.
- Generate API key in Atlas Service.
- Have a GitHub account to connect with Azion and create your new repository.
- Every push will be deployed automatically to this repository to keep your project updated.
- Enable Edge Functions and Application Accelerator in your Azion account.
- To do so:
You need to activate these modules via Azion Console. To do so:
- Access Azion Console > Account menu
- Select the Billing & Subscriptions option.
- Select the Subscriptions tab.
- Activate the switch for each module.
Deploying the template
You can obtain and configure your template through the Azion Console. To easily deploy it at the edge, click the button below.
DeploySetting up the template
In the configuration form, you must provide the information to configure your application. Fill in the presented fields.
Fields identified with an asterisk are mandatory.
- Connect Azion with your GitHub account.
- A pop-up window will open to confirm the installation of the Azion GitHub App, a tool that connects your GitHub account with Azion’s platform.
- Define your permissions and repository access as desired.
- Select the Git Scope to work with.
- Fill in the fields:
- Application Name *: the name of your edge application on Azion.
- The bucket for storage and the edge function will use the same name.
- Use a unique and easy-to-remember name. If the name has already been used, the platform returns an error message.
- Atlas API Token *: the token to authorize the connection with the AtlasData API.
- Atlas API URL *: the assigned URL endpoint to connect with Atlas Data API.
- Collection Name *: the name of a created collection in the specified database.
- Database Name *: the name of the created database in the MongoDB Atlas data source.
- dataSource Name *: the name of the created MongoDB Atlas data source or cluster.
- Click the Deploy button to start the deployment process.
During the deployment, you’ll be able to follow the process through a window showing off the logs. When it’s complete, the page shows information about the application and some options to continue your journey.
Key configurations
By deploying this template, the script creates:
- An edge application to run your project and manage all your settings.
- An Azion domain to access your edge application. You can also set up a custom domain to run on this edge application.
- An edge function containing custom logic.
- A GitHub repository for your project. The repository includes a GitHub Action that guarantees a continuous deployment workflow.
The execution of this template also includes integration with Mongo DB Atlas and Atlas Data API, acting as a middleware to manage and access your database.
HTTPS requests examples
The integration with the Atlas Data API enables you to access the data using standard HTTPS requests. Acting as a middleware to access and manage your data, the API sits between your cluster and the client requests.
You’re able to create, retrieve, update, and delete items in your collections through any tools that allow you to send standard HTTPS requests, such as your terminal or Postman.
The API has dedicated endpoints according to the operation you want to complete.
Finding a document
Where:
Variable | Required | Type | Description |
---|---|---|---|
dataSource | Yes | String | The name of your data source or cluster |
database | Yes | String | The name of the database in the data source |
collection | Yes | String | The name of a created collection in the specified database |
filter | Yes | Object | A query operator to filter the documents |
Inserting a document
Where:
Variable | Required | Type | Description |
---|---|---|---|
dataSource | Yes | String | The name of your data source or cluster |
database | Yes | String | The name of the database in the data source |
collection | Yes | String | The name of a created collection in the specified database |
filter | No | Object | A query operator to filter the documents |
All the requests return a response in JSON
or EJSON
format, including the information according to the status code: 200 Success
, 400 Bad Request
, and 401 Unauthorized
.
Managing the template
Considering that this initial setup may not be optimal for your specific edge application, all settings can be customized any time you need by using Azion Console.
To manage and edit your edge application’s settings, proceed as follows:
- Access Console.
- On the upper-left corner, select Products menu > Edge Application.
- You’ll be redirected to the Edge Application page. It lists all the edge applications you’ve created.
- Find the edge application related to your template and select it.
- The list is organized alphabetically. You can also use the search bar located in the upper-left corner of the list; currently, it filters only by Application Name.
After selecting the edge application you’ll work on, you’ll be directed to a page containing all the settings you can configure.
Adding a custom domain
The edge application created during the deployment has an assigned Azion domain to make it accessible through the browser. The domain has the following format: xxxxxxxxxx.map.azionedge.net/
. However, you can add a custom domain for users to access your edge application through it.
Learn how to deploy the MongoDB Atlas Boilerplate. Watch the video below: