Skip to content

Instantly share code, notes, and snippets.

@janakiramm
Last active August 24, 2017 07:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janakiramm/8f26db1d339ef3c87342c81fb63e5912 to your computer and use it in GitHub Desktop.
Save janakiramm/8f26db1d339ef3c87342c81fb63e5912 to your computer and use it in GitHub Desktop.
export LOC=eastus
export RG=todoapp
export DB=tododb0708
export REG=todoacr
# Test the app locally
docker run -d --name db mongo
docker run -d -p 80:3000 --link db:db --name todo janakiramm/todo
# Create a Resource Group
az group create --name $RG --location $LOC
# Create CosmosDB database compatible with MongoDB
az cosmosdb create --name $DB --kind MongoDB -g $RG
az cosmosdb list-connection-strings -g $RG --name $DB
export CONNSTR=<Connection_String> # Replace with actual value
# Create Azure Container Registry and a Service Principal
az acr create -g $RG --location $LOC --sku Basic -n $REG
az ad sp create-for-rbac --scopes /subscriptions/<SUBSCRIPTION_ID>/resourceGroups/todoapp/providers/Microsoft.ContainerRegistry/registries/todoacr --role Owner --password Password@123
az acr update -n todoacr --admin-enabled true
az acr credential show -n todoacr
export USR=<appID> # Replace with actual value
export PASSWD=<password> # Replace with actual value
# Login to ACR and push the image
docker pull janakiramm/todo:latest
docker tag janakiramm/todo:latest todoacr.azurecr.io/todo:latest
docker login todoacr.azurecr.io
docker push todoacr.azurecr.io/todo:latest
# Launch the ACI container
az container create \
--name todo \
--resource-group todoapp \
--registry-login-server todoacr.azurecr.io \
--registry-username $USR \
--registry-password $PASSWD \
--image todoacr.azurecr.io/todo \
--environment-variables DB="$CONNSTR" PORT=80 \
--ip-address public \
--port=80
# Launch the ACI container through an ARM template
az group deployment create --name todo --resource-group $RG --template-file azuredeploy.json
# List the containers and access the logs
az container list
az container logs --name todo --container-name todo -g $RG
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment