Hello Administracion Enerworks DI,
Welcome to Microsoft Q&A!
We are very sorry for the delay in giving you a response to your topic in this forum. If you still have the same inquiry, it is possible to route IoT Hub messages to Azure Cosmos DB using the MongoDB API. Azure IoT Hub supports routing messages directly to Cosmos DB, and this includes both the NoSQL API and the MongoDB API.
To set this up, you can configure Cosmos DB as a custom endpoint within the IoT Hub. This involves creating routing rules to send data directly to the defined Cosmos DB endpoint.
In case you need it, to set up routing from Azure IoT Hub to Cosmos DB using the MongoDB API, follow these steps:
- Create a Cosmos DB Account:
- In the Azure portal, create a new Cosmos DB account and select the MongoDB API.
- Set up your database and collection within this account.
- Configure IoT Hub:
- Open your IoT Hub in the Azure portal.
- Navigate to Message Routing under the Messaging section.
- Add a Custom Endpoint:
- Click on Custom endpoints and select Add.
- Choose Cosmos DB as the endpoint type.
- Fill in the required details, such as the Cosmos DB account, database, and collection you created earlier.
- Create a Routing Rule:
- After adding the custom endpoint, go back to the Message Routing section.
- Click on Add to create a new routing rule.
- Define the source (e.g., device messages), condition (optional), and select the custom endpoint you created.
- Save and Test:
- Save your routing rule and test the setup by sending messages from your IoT devices to ensure they are correctly routed to your Cosmos DB collection.
I hope the information provided was useful. Additionally, please kindly note that if we do not receive a response to this thread within 4 business days, we will consider it closed. In case you have the same question, and the information provided was not useful, feel free to create another thread and we will be more than happy to help you.
Regards,
Gao
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".