Share via

MongoDB in Azure Container Apps

Rishab Mehta 85 Reputation points
2025-02-13T12:42:17.1+00:00

Hello, I need to run MongoDB as an Azure Container App, and I have a couple questions.

How do I ensure that the data doesn't disappear if the container goes down? I saw people saying to connect a file storage system, but if that is the answer does anyone have some examples/tutorials on how to do so?

If I have other containers running in Azure, how do I allow them to connect with the MongoDB container?

Thanks for the help!

Azure Container Apps
Azure Container Apps

An Azure service that provides a general-purpose, serverless container platform.


Answer accepted by question author

Ranashekar Guda 2,905 Reputation points Moderator
2025-02-13T16:10:57.5566667+00:00

Hi @Rishab Mehta,
Welcome to the Microsoft Q&A Platform! Thank you for asking your question here.
To run MongoDB as an Azure Container App while ensuring data persistence and enabling connectivity with other containers, follow these steps:

1)Ensuring Data Persistence:

  • Create an Azure Storage Account and a file share.
  • Mount the Azure File Share to your MongoDB container to store data outside the container, ensuring persistence even if the container restarts or crashes.
  • Ensure your MongoDB configuration points to the mounted volume for data storage (e.g., /data/db).

2)Connecting Other Containers to MongoDB:

  • Deploy your MongoDB container and other containers within the same Azure Container App environment or virtual network to allow them to communicate.
  • Ensure that the MongoDB container exposes the default port (27017) so that other containers can connect to it.
  • Use the MongoDB container's service name in connection strings from other containers. Azure Container Apps supports built-in service discovery for easy connection using the container name.

For additional clarification, please refer to the following documentations:

https://learn.microsoft.com/en-us/azure/container-apps/

https://learn.microsoft.com/en-us/azure/container-apps/networking?tabs=workload-profiles-env%2Cazure-cli

I hope this helps! Let me know if you have any further questions or need additional assistance.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.