You can emulate selected Azure services locally using the LocalStack Azure Docker image. Before you begin, you must export a valid LOCALSTACK_AUTH_TOKEN, which unlocks Azure emulation features.
Refer to the LocalStack Auth Token documentation (e.g. the Auth Token guide) to obtain your token and set it as an environment variable.
- Docker installed and running
- (Recommended) Docker Compose (v2+)
- LocalStack account with a valid authentication token
- Sufficient disk space for the LocalStack persistent volume
docker pull localstack/localstack-azureYou can start the Azure emulator using one of the following methods:
- lstk CLI
- Raw
docker run - Docker Compose
Make sure the lstk CLI is installed (brew install localstack/tap/lstk or npm install -g @localstack/lstk).
# Set the authentication token
export LOCALSTACK_AUTH_TOKEN=<your_auth_token>
# Start the LocalStack Azure emulator
lstk start --type azure
# Route all Azure CLI calls to the LocalStack Azure emulator
lstk az start-interceptionThis:
- Exports your auth token
- Starts the LocalStack Azure emulator (
--type azure) and waits until it is ready - Routes all Azure CLI calls to the emulator
To stop:
lstk stopRun the container directly:
docker run \
--rm -it \
-p 4566:4566 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v ~/.localstack/volume:/var/lib/localstack \
-e LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN:?} \
localstack/localstack-azureNotes:
-p 4566:4566exposes the LocalStack edge port- Mounting the Docker socket enables starting sidecar containers if needed
- The
~/.localstack/volumemount persists state across restarts - The
:?syntax in${LOCALSTACK_AUTH_TOKEN:?}fails fast if the variable is unset
Create a docker-compose.yml:
version: "3.8"
services:
localstack:
container_name: localstack-main
image: localstack/localstack-azure
ports:
- "127.0.0.1:4566:4566"
environment:
- LOCALSTACK_AUTH_TOKEN=${LOCALSTACK_AUTH_TOKEN:?}
volumes:
- "./volume:/var/lib/localstack"Start the service:
docker compose up(Or with legacy syntax: docker-compose up)
To run detached:
docker compose up -dStop and remove:
docker compose downAfter startup, you can:
- Check logs:
lstk logs --follow, ordocker logs -f localstack-mainwith Docker Compose - Curl the edge endpoint:
curl -s localhost:4566/_localstack/health | jq
Set the auth token once per shell session:
export LOCALSTACK_AUTH_TOKEN=<your_auth_token>For shells like Fish:
set -x LOCALSTACK_AUTH_TOKEN <your_auth_token>For PowerShell:
$Env:LOCALSTACK_AUTH_TOKEN = "<your_auth_token>"- Stop containers (
lstk stop,docker stop <id>, ordocker compose down) - Remove persisted state if needed:
rm -rf ~/.localstack/volume # or for compose: rm -rf ./volume
| Issue | Suggestion |
|---|---|
| Auth error | Confirm token validity & export |
| Port already in use | Change mapping (e.g. -p 4567:4566) |
| State not persisting | Verify volume mount path |
| lstk starts another emulator | Start it with lstk start --type azure |
- Explore available Azure service endpoints through the LocalStack documentation
- Script integration tests against
http://localhost:4566 - Combine with Terraform / SDK clients pointing to the LocalStack endpoint
- Proxy the Azure CLI to the emulator with
lstk az, or runlstk az start-interceptionto intercept allazcalls (see the lstk GitHub repository)