Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To use MongoDB in Azure App Service through Docker-Compose, follow these steps:

  1. Create a new Docker-Compose file in your project directory and add the following code:
version: "3.8"
services:
  app:
    build: .
    ports:
      - "3000:3000"
    depends_on:
      - db
    environment:
      - MONGODB_URI=mongodb://db:27017/mydatabase
  db:
    image: mongo:latest
    restart: always
    volumes:
      - db_data:/data/db
volumes:
  db_data:
  1. Replace the "mydatabase" with the name of your database that you want to connect to.

  2. Create a new Azure App Service instance and configure it to use Docker-Compose for deployment.

  3. Deploy your application to Azure App Service by uploading your Docker-Compose file.

  4. Verify that your application is running by checking the logs of your Azure App Service instance.

  5. Connect to MongoDB by using the MONGODB_URI environment variable that you defined in your Docker-Compose file.

Now you can use MongoDB in Azure App Service through Docker-Compose.