Securely store and access secrets in Azure KeyVault from Docker-based App Service

$ npm i express @azure/identity @azure/keyvault-secrets
$ dotnet new webapi
$ dotnet add package Azure.Identity --version 1.4.1
$ dotnet add package Azure.Security.KeyVault.Secrets --version 4.2.0
@azure/identity vs Azure.Identity
@azure/keyvault-secrets vs Azure.Security.KeyVault.Secrets
export AZURE_TENANT_ID="..."
export AZURE_CLIENT_ID="..."
export AZURE_CLIENT_SECRET="..."
FROM node:14
WORKDIR /usr/src/app
COPY package*.json ./

RUN npm install
# If you are building your code for production
# RUN npm ci --only=production

# Bundle app source
COPY . .

EXPOSE 8080
CMD [ "node", "server.js" ]
version: '3.4'
services:
app:
build:
context: .
dockerfile: ./Dockerfile
ports:
- 8000:8080
environment:
AZURE_TENANT_ID: ${AZURE_TENANT_ID}
AZURE_CLIENT_ID: ${AZURE_CLIENT_ID}
AZURE_CLIENT_SECRET: ${AZURE_CLIENT_SECRET}
env_file: .env
command: sh -c 'npm run start'
docker-compose -f docker-compose.dev.yml up --build
docker-compose -f docker-compose.dev.yml down
version: '3.4'
services:
app:
build:
context: .
dockerfile: ./Dockerfile
ports:
- 80:4001
command: sh -c 'npm run start'

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store