Skip to content

Instantly share code, notes, and snippets.

@NileshGule
Last active February 15, 2018 16:49
Show Gist options
  • Save NileshGule/ddea94fdebc5fff19a0eedc2ab75a2e1 to your computer and use it in GitHub Desktop.
Save NileshGule/ddea94fdebc5fff19a0eedc2ab75a2e1 to your computer and use it in GitHub Desktop.
Commands for Azure meet up on 25th Jan 2018

Azure Meetup 25 January 2018

Generate SSH key pair

ssh-keygen –t rsa

Azure Resource template

Login to Azure account (not required in case of cloud shell)

az login

Set subscription ID (not required in case of cloud shell)

az account set --subscription "Visual Studio Enterprise"

az account set --subscription "Azure Pass"

Create resource group

az group create \
--name swarmresourcegroup \
--location "Southeast Asia"

Create deployment using local template file and parameters

time az group deployment create \
    --name "coredemo" \
    --resource-group "swarmresourcegroup" \
    --template-file azuredeploy.json \
    --parameters parameters.json

Build images locally

docker-compose --file docker-compose-build.yml build

Run images locally

docker-compose --file docker-compose-build.yml up

Visualize Docker Swarm using Portainer

Open SSH tunnel to Swarm endpoint in SE Asia

ssh -fNL 2375:localhost:2375 -p 2200 [email protected]

Set DOCKER_HOST environment variable

export DOCKER_HOST=:2375

change availability of Swarm Master node

docker node update --availability=active swarmm-master-coredemo-0

Create Portainer Service

docker service create \
   --name portainer \
   --publish 9000:9000 \
   --constraint 'node.role == manager' \
   --mount type=bind,src=/var/run/docker.sock,dst=/var/run/docker.sock \
   portainer/portainer \
   -H unix:///var/run/docker.sock

Visualize Swarm Resources

http://swarmagent.southeastasia.cloudapp.azure.com:9000/

Reset availability of Swarm Master node to Pause

docker node update --availability=pause swarmm-master-coredemo-0

Access MVC app & WebAPI using agent node

http://swarmagent.southeastasia.cloudapp.azure.com

http://swarmagent.southeastasia.cloudapp.azure.com:8080/api/keyvalue

Delete resources at the end

az group delete --name swarmresourcegroup --yes--no-wait
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment