Skip to content

πŸš€ A complete Docker-based local environment for Azure development, including Cosmos DB Emulator (with multiple APIs: SQL, MongoDB, Cassandra, Gremlin, Table), Azurite (Blob/Queue/Table), and Azure Functions Runtime.

License

Notifications You must be signed in to change notification settings

AleksNeStu/azure-emulators-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

16 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Azure Emulators Docker Environment

License: MIT Docker Compose Last Updated

πŸš€ A complete Docker-based local environment for Azure development, including Cosmos DB Emulator (with multiple APIs: SQL, MongoDB, Cassandra, Gremlin, Table), Azurite (Blob/Queue/Table), and Azure Functions Runtime.

πŸ“‹ Overview

This project provides a complete local development environment for Azure services using Docker containers. It allows you to develop and test Azure-based applications locally without requiring an Azure subscription.

Services Included

Service Description Port(s) Status
Azure Cosmos DB Emulator Emulates Cosmos DB with multiple APIs (SQL, MongoDB, Cassandra, Gremlin, Table) 8081, 10255 βœ… Tested (MongoDB)
Azurite Emulates Azure Storage (Blob, Queue, Table) 10000-10002 βœ… Tested
Azure Service Bus Emulator Local emulator for Azure Service Bus messaging 9354, 5672 πŸ”„ To be tested
Azure Functions Core Tools Local environment for Azure Functions 7071 πŸ”„ To be tested

πŸš€ Getting Started

Prerequisites

  • Docker and Docker Compose
  • At least 4GB of available RAM (Cosmos DB Emulator requires 3GB)
  • Python 3.8+ for running tests
  • Poetry (version 2.0.0+) for dependency management

Poetry Configuration

Configure Poetry to create the virtual environment in your project directory using Python 3.8:

# Configure Poetry to create virtual environments in the project directory
poetry config virtualenvs.in-project true

# Specify Python 3.12 for the virtual environment
poetry env use python3.12

# Install dependencies (without the root package)
poetry install --no-root

# Activate the virtual environment (for Poetry 2.0.0+)
poetry env activate
# or
source .venv/bin/activate

Quick Start

# Clone this repository
git clone https://github.com/yourusername/azure-emulators-docker.git
cd azure-emulators-docker

# Start all services 
docker-compose up -d

# Start specific services only
docker-compose up -d azurite servicebus

Running Tests

# Run tests using Poetry
poetry run pytest

# Run specific tests
poetry run pytest tests/test_emulators.py

πŸ”Œ Connection Information

⚠️ Security Note: All connection strings and keys shown below are for local development only. They are either publicly known development keys or randomly generated examples. Never use these in production environments.

Azure Cosmos DB Emulator

Azurite (Azure Storage)

DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;
AccountKey=RandomDevKey123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmn==;
BlobEndpoint=http://localhost:10000/devstoreaccount1;
QueueEndpoint=http://localhost:10001/devstoreaccount1;
TableEndpoint=http://localhost:10002/devstoreaccount1;

Azure Service Bus Emulator

  • Connection String: Endpoint=sb://localhost:9354/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=RandomDevSharedKey123456789ABCDEFGHIJKLMNOP=
  • AMQP Endpoint: amqp://localhost:5672

Azure Functions

Windows Native Installation Alternative

While Docker provides a cross-platform solution, Windows users can alternatively install and run the Azure Cosmos DB Emulator directly on their machines for potentially better performance.

Installing the Windows Cosmos DB Emulator

  1. Download the installer from the official Microsoft page
  2. Run the installer and follow the prompts
  3. The emulator will be installed to C:\Program Files\Azure Cosmos DB Emulator\

Running with MongoDB Support

Launch the emulator with MongoDB API support using these command-line arguments:

"C:\Program Files\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" /AllowNetworkAccess /Key=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw== /EnableMongoDbEndpoint=4.0

πŸ“ Configuration

Docker Compose Options

The environment can be customized by modifying the docker-compose.yml file:

# Example: Cosmos DB Emulator configuration
cosmosdb:
  image: mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator
  environment:
    - AZURE_COSMOS_EMULATOR_PARTITION_COUNT=10
    - AZURE_COSMOS_EMULATOR_ENABLE_DATA_PERSISTENCE=true
  mem_limit: 3G

Data Persistence

Data persists between container restarts via Docker volumes:

Volume Purpose
cosmosdb_data Cosmos DB data files
cosmosdb_cert Cosmos DB certificates
azurite_data Azurite storage data

πŸ› οΈ Troubleshooting

Issue Solution
Memory Errors with Cosmos DB Increase the mem_limit value in docker-compose.yml
Certificate Errors Download certificate from https://localhost:8081/_explorer/emulator.pem
Port Conflicts Modify port mappings in docker-compose.yml: "<new-port>:<container-port>"

πŸ“„ License & Contributing

This project is licensed under the MIT License - see the LICENSE file for details.

Contributions are welcome! Please feel free to submit a Pull Request.

About

πŸš€ A complete Docker-based local environment for Azure development, including Cosmos DB Emulator (with multiple APIs: SQL, MongoDB, Cassandra, Gremlin, Table), Azurite (Blob/Queue/Table), and Azure Functions Runtime.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages