John Liu Blog

Every drop counts

Data API Builder notes

Docker Desktop We can deploy Data API Builder (DAB) using Docker Compose in Docker Desktop. An example compose file: version: '3' services: DAB-AutoGen: image: "mcr.microsoft.com/azure-databases/data-api-builder:latest" container_name: DAB-AutoGen ports: - "5002:5000" extra_hosts: - "host.docker.internal:host-gateway" volumes: - c:\DataAPIBuilder\Samples\:/App/DAB-Configs command: ["--ConfigFileName", "/App/DAB-Configs/dab-config-AutoGen.json"] DAB-AutoGen2: image: "mcr.microsoft.com/azure-databases/data-api-builder:latest" container_name: DAB-AutoGen2 ports: - "5003:5000" extra_hosts: - "host.docker.internal:host-gateway" volumes: - c:\DataAPIBuilder\Samples\dab-config-AutoGen.json:/App/dab-config.json Azure Container Instance We can also deploy the container in Azure Container Instance (ACI). The DAB configuration files need to be store in Azure File Share.

Run container in Azure VM

We can run container (using Docker Desktop) inside Azure VM. Following are some considerations for the setup. Not all Azure VM support container. D4_v5 and above VM support nested virtulization. When creating the Zure VM, ensure the security type on the Basic tab is set to “Standard”, not “Trusted Launch”. Trusted Launch does not support Nested Virtualization. Azure Portal default to Trusted Launch. After VM is created, turn Windows featur “Windows Hypervisor Platform” on.

Azure Cosmos DB Emulator

We can use Azure CosmosDB emulator to simulate Azure CosmosDB without actually connect to Azure environment. The emulator is running inside a container. To setup the container using the latest image: docker run -it --name cosmosDB -p 8081:8081 mcr.microsoft.com/cosmosdb/linux/azure-cosmos-emulator This will create a container named cosmosDB and the emulator access port is 8081. When .Net code connect to the emulator, you might receive error about “The SSL connection could not be established” and “The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot”.

Docker Cheat Sheet

Docker command cheat sheet from twitter. Process Management Show all running docker containers docker ps Show all docker containers docker ps -a Run a container docker run <image>:<tag> Run a container and connect to it docker run -it <image>:<tabe> Run a container in the background docker run -d <image>:<tag> Stop a container docker stop <container> Kill a container docker kill <container> Volumes & Ports List volumes docker volume ls Create a volume

Docker notes

Get help docker --help List all existing containers (without truncating result string) docker ps -a --no-trunc Start a container (containner name is case sensitive) docker start <container name> Show current downloaded images docker images To download an image from a registry (use :latest or :1.2.3 tag for specific version) docker pull <docker_image>:latest To create and run a containner (use create instead of run to just create a containner) docker run -it --name DataApiBuilder -v "c:\DataAPIBuilder\Samples:/App/Samples" -p 5004:5000 mcr.