MongoDB in Azure Container Apps

Rishab Mehta 80 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.
550 questions
{count} votes

Accepted answer
  1. Ranashekar Guda 265 Reputation points Microsoft Vendor
    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.


0 additional answers

Sort by: Most helpful

Your answer

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