MongoDB (Preview)

MongoDB is a general purpose, distributed, document data platform which is loved by developers and used across enterprises to run variety of workloads.You can now explore the various endpoints and perform CRUD operations and aggregations on your collection using the MongoDB Connector.
This connector is available in the following products and regions:
Service | Class | Regions |
---|---|---|
Copilot Studio | Premium | All Power Automate regions except the following: - US Government (GCC) - US Government (GCC High) - China Cloud operated by 21Vianet - US Department of Defense (DoD) |
Logic Apps | Standard | All Logic Apps regions except the following: - Azure Government regions - Azure China regions - US Department of Defense (DoD) |
Power Apps | - | Not available |
Power Automate | Premium | All Power Automate regions except the following: - US Government (GCC) - US Government (GCC High) - China Cloud operated by 21Vianet - US Department of Defense (DoD) |
Contact | |
---|---|
Name | MongoDB Support |
URL | https://www.mongodb.com/community/forums/ |
support-operations@mongodb.com |
Connector Metadata | |
---|---|
Publisher | MongoDB Corp |
Website | https://www.mongodb.com |
Privacy policy | https://www.mongodb.com/legal/privacy-policy |
Categories | Data |
MongoDB Connector provides a simple way to connect to MongoDB Atlas via Data APIs hosted using Azure function in your tenant to read and write data to MongoDB Atlas collections. MongoDB connector makes it easy to perform CRUD operations and aggregations on your data in minutes and allows you to query MongoDB to build rich apps and workflows in Power Apps, Power Automate and Logic Apps.
*** Please note that MongoDB deprecated the Atlas Data APIs from September, 2025 and thus use this connector approach to set up an Azure function and use its url and API keys instead of Atlas' ones in your Apps and Flows. ***
Prerequisites
- Configure Atlas Environment
Register for a new Atlas Account here. Follow steps from 1 to 4 (Create an Atlas account, Deploy a Free cluster, Add your IP to the IP access list and Create a Database user) to set up the Atlas environment.
Set Up Azure Function as Atlas Data API To set up the Azure function which will host the code to act as Atlas Data APIs, we have two options - 1. Using GitHub Actions OR 2. Using Zip Deploy
Choose the GitHub actions method, if you are able to fork the current repo, can have GitHub actions enabled in that repo and that you would want to add more APIs and prefer a CI/CD or DevOps set up out of the box. However, if you are looking for a quick and easy way of deployment and just need the Azure function set up to substitute the Atlas Data APIs, go with the Zip deploy option.
Option 1: Set Up Azure function Using GitHub actions
a.Fork the MongoDB repo. Note the new forked repo url. If GitHub actions is NOT enabled by default, enable them by going to the Settings -> Actions -> General in your forked repo and select one of Allow actions/ resusable workflows options.
b.Click the below Deploy to Azure button to have the Azure function created in your tenant.
c. Select or Create your Resource group which will contain the Azure function and its associated components (App Service Plan, Storage Account and App Insights). You can keep the function name and SKU as the defaults or change if you like to follow some specific standards. We recommend that you add your Cluster name to the function app name so that its unique and easy to identify.
Give the MongoDB connection url for the Cluster against which this Azure function will run. This connection string will be saved as an Environmnet variable. Give your forked repo url as GitHub repo. Select Create and it will create the Azure function with the associated resources. Note that at this stage the function app is created, env variables are populated but the actual function is not yet deployed to the function app.
d. To have GitHub actions run from your repo and deploy the function, get the publishing profile from your created Azure function.
It gets downloaded, open it in a Text editor and copy all its contents.
e. Go to your GitHub repo -> Settings -> Secrets and variables -> Actions Click New Respository secret and copy the entire value in your publishing profile to a new secret named "AZUREAPPSERVICE_PUBLISHPROFILE"
f. Make a minor change in README and Commit Changes to invoke GitHub actions which would deploy the python code to the Azure function into your function app. Now you should see the function available in the Functon App and the code in function_app.py deployed.
g. GitHub actions tab in GitHub repo will show the steps in the deployment (including the installation of dependencies) and the result of each step.
Option 2: Set Up Azure function Using ZipDeploy
a. Click the below Deploy to Azure button to have the Azure function created in your tenant.
b. Select or Create your Resource group which will contain the Azure function and its associated components (App Service Plan, Storage Account and App Insights). You can keep the function name and SKU as the defaults or change if you like to follow some specific standards. We recommned that you add your Cluster name to the function app name so that its unique and easy to identify.
Please ** DONOT change ** the packageUrl as its the SAS url of the Storage account which has the zip that needs to be deployed. Select Create and it will create the Azure function app, deploy the azure function along with the associated resources.
How to get credentials
Get the BaseUrl and API Key
a. From the Function App, select your function and click Get function URL . Copy the function url from the beginning till before "/action" as shown in screenshot below. This is the Base Url you will use to invoke any of the MongoDB CRUD/ Aggregate APIs.
b. Go to your Function App -> Under Functions -> App keys , Grab either the _master or default API key for your Azure function This is the API Key you will use along with Base Url to create a MongoDB connection to invoke any of the MongoDB CRUD/ Aggregate APIs.
Get started with your connector
- Once the Prerequisites are completed, Go to PowerAutomate -> Connections. Click on "New Connection" and search for MongoDB in the Search Bar on the top right, as shown below in the screenshot.
- Click on the MongoDB connection and you would see the below popup which asks to enter the API key and the Base URL.
- For the "Base Url" and the "API Key" fields, enter the values retrieved from How to get credentials section above
Use one of the 8 Data APIs for any CRUD operations against your MongoDB Atlas Cluster. For complex queries, use the "Run an Aggregation Pipeline" API to use aggregation stages to massage the output from one stage to another. The flexibility and dynamism of MongoDB allows you to create rich apps and automate any time consuming processes. You keep enhancing the apps by adding more features and fields to the same collection.
Known issues and limitations
As MongoDB does not enforce a schema, the current connector can be used with Power Automate and Logic Apps only, which supports dynamic schema for the API response, which can then be parsed using the "Parse JSON" constructs. It can be used in Power Apps by invoking a Power Automate flow for every MongoDB interaction. You can also continue to use the certified MongoDB connector from the Microsoft Github repository as a Custom connector to use it in Power Apps directly to customize the Response schema as per your MongoDB collection schema.
Restrictions applicable to MongoDB Data operations does apply to the MongoDB connector also. Please refer to this link to know more about the aggregation stages that are not supported under User context of Data APIs.
Please follow this link for the known limitations with the Azure functions like time outs and other service limits for each resource plans.
Common errors and remedies
Typical API response codes apply here also. Any 4XX errors indicate issue with the request from the client. Make sure that the dataSource, database, collection are provided in a valid JSON format. Refer to this Postman Collection for examples. For 5XX errors, make sure the Azure function is up and running and check its trace to further investigate.
Creating a connection
The connector supports the following authentication types:
Default | Parameters for creating connection. | All regions | Not shareable |
Default
Applicable: All regions
Parameters for creating connection.
This is not shareable connection. If the power app is shared with another user, another user will be prompted to create new connection explicitly.
Name | Type | Description | Required |
---|---|---|---|
API Key | securestring | The API Key for this api | True |
BaseUrl | string | The Azure Function url (Example:https://mdb-dataapi-repl.azurewebsites.net/api/mdb_dataapi) | True |
Throttling Limits
Name | Calls | Renewal Period |
---|---|---|
API calls per connection | 100 | 60 seconds |
Actions
Delete Document |
To delete a single document, use the deleteOne endpoint. Use the filter property in the request body to specify the search criteria. If more than one document matches the criteria, only the first match will be deleted. |
Delete Many Documents |
You can use deleteMany to delete multiple documents at once. Use the filter property to specify which documents to delete. Beware that using this API without any filters will delete all the documents in the collection. Use deletemany with care. |
Find Document |
Using the findOne endpoint will let you retrieve a single document from a collection. Use the filter property in the request body to specify the search criteria. If more than one document matches the criteria, only the first match will be returned. |
Find Multiple Documents |
Using the find endpoint, you can fetch multiple documents at once. Use the filter property in the body of the request to specify the criteria on which to filter. If you pass an empty object, all the documents in the collection will be returned. |
Insert Document |
Using the insertOne endpoint, you can add a document to a collection. Use the document property in the request body to specify the document that should be created. |
Insert Multiple Documents |
You can add more than one document at a time by using the insertMany endpoint. In that case, you must use the documents property in the body of the request to specify the array of documents you want to insert into the collection. |
Run Aggregation Pipeline |
You can even run aggregation pipelines with the Data API. To do so, use the aggregate endpoint and specify your pipeline in the pipeline field of the request body. |
Update Document |
You can use the updateOne endpoint to update a single record. Use the filter property in the request body to specify the search criteria. If more than one document matches the criteria, only the first match will be returned. Then use the update field to specify what should be updated. You should use one of the update operators to update your documents. |
Update Multiple Documents |
Using updateMany, you can update all the documents matching a specific filter specified in the body of the request. Use one of the update operators in the update field to update your documents. |
Delete Document
To delete a single document, use the deleteOne endpoint. Use the filter property in the request body to specify the search criteria. If more than one document matches the criteria, only the first match will be deleted.
Parameters
Name | Key | Required | Type | Description |
---|---|---|---|---|
MongoDB Cluster Name
|
dataSource | True | string |
The name of the cluster. |
MongoDB Database Name
|
database | True | string |
The name of the database. |
MongoDB Collection Name
|
collection | True | string |
The name of the collection. |
filter
|
filter | True | object |
A MongoDB Query Filter. The deleteOne action deletes the first document in the collection that matches this filter. |
Returns
Name | Path | Type | Description |
---|---|---|---|
deletedCount
|
deletedCount | integer |
deletedcount |
Delete Many Documents
You can use deleteMany to delete multiple documents at once. Use the filter property to specify which documents to delete. Beware that using this API without any filters will delete all the documents in the collection. Use deletemany with care.
Parameters
Name | Key | Required | Type | Description |
---|---|---|---|---|
MongoDB Cluster Name
|
dataSource | True | string |
The name of the cluster. |
MongoDB Database Name
|
database | True | string |
The name of the database. |
MongoDB Collection Name
|
collection | True | string |
The name of the collection. |
filter
|
filter | True | object |
A MongoDB Query Filter . The deleteMany action deletes all documents in the collection that match this filter. |
Returns
Name | Path | Type | Description |
---|---|---|---|
deletedCount
|
deletedCount | integer |
deletedCount |
Find Document
Using the findOne endpoint will let you retrieve a single document from a collection. Use the filter property in the request body to specify the search criteria. If more than one document matches the criteria, only the first match will be returned.
Parameters
Name | Key | Required | Type | Description |
---|---|---|---|---|
MongoDB Cluster Name
|
dataSource | True | string |
The name of the cluster. |
MongoDB Database Name
|
database | True | string |
The name of the database. |
MongoDB Collection Name
|
collection | True | string |
The name of the collection. |
filter
|
filter | object |
A MongoDB Query Filter. The findOne action returns the first document in the collection that matches this filter. |
|
projection
|
projection | object |
A MongoDB Query Projection. Depending on the projection the returned document will either omit specific fields or include only specified fields or values |
Returns
Name | Path | Type | Description |
---|---|---|---|
document
|
document | object |
document |
Find Multiple Documents
Using the find endpoint, you can fetch multiple documents at once. Use the filter property in the body of the request to specify the criteria on which to filter. If you pass an empty object, all the documents in the collection will be returned.
Parameters
Name | Key | Required | Type | Description |
---|---|---|---|---|
MongoDB Cluster Name
|
dataSource | True | string |
The name of the cluster. |
MongoDB Database Name
|
database | True | string |
The name of the database. |
MongoDB Collection Name
|
collection | True | string |
The name of the collection. |
filter
|
filter | object |
A MongoDB Query Filter.The find action returns documents in the collection that match this filter.If you do not specify a filter, the action matches all document the collection. |
|
projection
|
projection | object |
A MongoDB Query projection.Depending on the projection, the returned documents either omit specific fields or include only specified fields and values. |
|
sort
|
sort | object |
A MongoDB Sort Expression. Matched documents are returned in ascending or descending order of the fields specified in the expression. |
|
limit
|
limit | integer |
The maximum number of matched documents to include in the returned result set. Each request may return up to 50,000 documents. |
|
skip
|
skip | integer |
The number of matched documents to skip before adding matched documents to the result set. |
Returns
Name | Path | Type | Description |
---|---|---|---|
documents
|
documents | array of object |
documents |
items
|
documents | object |
Insert Document
Using the insertOne endpoint, you can add a document to a collection. Use the document property in the request body to specify the document that should be created.
Parameters
Name | Key | Required | Type | Description |
---|---|---|---|---|
MongoDB Cluster Name
|
dataSource | True | string |
The name of the cluster. |
MongoDB Database Name
|
database | True | string |
The name of the database. |
MongoDB Collection Name
|
collection | True | string |
The name of the collection. |
document
|
document | True | object |
An EJSON document to insert into the collection. |
Returns
Name | Path | Type | Description |
---|---|---|---|
insertedId
|
insertedId | string |
insertedId |
Insert Multiple Documents
You can add more than one document at a time by using the insertMany endpoint. In that case, you must use the documents property in the body of the request to specify the array of documents you want to insert into the collection.
Parameters
Name | Key | Required | Type | Description |
---|---|---|---|---|
MongoDB Cluster Name
|
dataSource | True | string |
The name of the cluster. |
MongoDB Database Name
|
database | True | string |
The name of the database. |
MongoDB Collection Name
|
collection | True | string |
The name of the collection. |
documents
|
documents | object |
items |
Returns
Name | Path | Type | Description |
---|---|---|---|
insertedIds
|
insertedIds | array of string |
insertedIds |
Run Aggregation Pipeline
You can even run aggregation pipelines with the Data API. To do so, use the aggregate endpoint and specify your pipeline in the pipeline field of the request body.
Parameters
Name | Key | Required | Type | Description |
---|---|---|---|---|
MongoDB Cluster Name
|
dataSource | True | string |
The name of the cluster. |
MongoDB Database Name
|
database | True | string |
The name of the database. |
MongoDB Collection Name
|
collection | True | string |
The name of the collection. |
pipeline
|
pipeline | object |
items |
Returns
Name | Path | Type | Description |
---|---|---|---|
documents
|
documents | array of object |
documents |
items
|
documents | object |
Update Document
You can use the updateOne endpoint to update a single record. Use the filter property in the request body to specify the search criteria. If more than one document matches the criteria, only the first match will be returned. Then use the update field to specify what should be updated. You should use one of the update operators to update your documents.
Parameters
Name | Key | Required | Type | Description |
---|---|---|---|---|
MongoDB Cluster Name
|
dataSource | True | string |
The name of the cluster. |
MongoDB Database Name
|
database | True | string |
The name of the database. |
MongoDB Collection Name
|
collection | True | string |
The name of the collection. |
filter
|
filter | True | object |
A MongoDB Query Filter.The UpdateOne action modifies the first document in the collection that matches this filter. |
update
|
update | True | object |
A MongoDB Update Expression that specifies how to modify the matched document. |
upsert
|
upsert | boolean |
The Upsert flag only applies if no documents match the specified filter. If true, the updateOne action inserts a new document that matches the filter with the specified update applied to it. |
Returns
Name | Path | Type | Description |
---|---|---|---|
matchedCount
|
matchedCount | integer |
matchedcount |
modifiedCount
|
modifiedCount | integer |
modifiedcount |
Update Multiple Documents
Using updateMany, you can update all the documents matching a specific filter specified in the body of the request. Use one of the update operators in the update field to update your documents.
Parameters
Name | Key | Required | Type | Description |
---|---|---|---|---|
MongoDB Cluster Name
|
dataSource | True | string |
The name of the cluster. |
MongoDB Database Name
|
database | True | string |
The name of the database. |
MongoDB Collection Name
|
collection | True | string |
The name of the collection. |
filter
|
filter | True | object |
A MongoDB Query Filter . The updateMany action modifies all documents in the collection that match this filter. |
update
|
update | True | object |
A MongoDB Update Expression that specifies how to modify matched documents. |
upsert
|
upsert | boolean |
The upsert flag only applies if no documents match the specified filter. If true, the updateMany action inserts a new document that matches the filter with the specified update applied to it. |
Returns
Name | Path | Type | Description |
---|---|---|---|
matchedCount
|
matchedCount | integer |
matchedcount |
modifiedCount
|
modifiedCount | integer |
modifiedcount |