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/
I hope this helps! Let me know if you have any further questions or need additional assistance.