Enabling containers to use Azure Virtual Network capabilities with Azure CNI and Azure Virtual Machines.
💡 The documentation implies that CNI is required for containers to use Virtual Network capabilities, however, after finishing this project I discovered that CNI was not required to use Service Endpoints from a Virtual Machine. Maybe it is already installed or something, did not investigate.
Set the .auto.tfvars file:
cp config/template.tfvars .auto.tfvarsCreate the infrastructure:
terraform init
terraform apply -auto-approveConfirm that cloud-init has complete successfully.
Manually select the Service Endpoint Policy as it was having circular dependency issues.
Connect via SSH to the virtual machine.
Run the command to star the app container:
sudo docker run -p 8080:8080 \
    -e 'MSSQL_HOSTNAME=sqls-cni.database.windows.net' \
    -e 'MSSQL_PORT=1433' \
    -e 'MSSQL_USERNAME=dbadmin' \
    -e 'MSSQL_PASSWORD=P4ssw0rd!2023' \
    epomatti/azure-vm-cni-app:arm64Teste the database connection:
curl <vm-ipaddress>:8080/querySet the .env file.
Start the database:
docker run -p 1433:1433 -e ACCEPT_EULA=Y -e SA_PASSWORD=P@ssw0rd.123 mcr.microsoft.com/mssql/server:2022-latestRun the application:
cd app
go run .