Following my previous post on ASP.NET Core RC2, Docker and HipChat Connect add-on I wanted to learn the next step which is to deploy my Docker container on the Microsoft Azure Cloud!
Due to a known issue and to avoid to have issues with credentials you need to follow the instructions on the following page “Creating a Work or School identity in Azure Active Directory to use with Windows VMs“
KNOWN ISSUE: There is a known issue with Azure Active Directory causing stored credentials to expire within hours rather than 14 days when the user logs in with personal Microsoft Account (formerly Live ID) instead of an Active Directory account. Currently, there is no ETA for resolution, however in the meanwhile, you can create an AAD account and login with that as a workaround.
Now to get ready to deploy we need first the following:
- Get an Azure account on Azure
- Get Azure subscription id from Subscriptions link
Then we need to create a machine on the Azure cloud which will host our Docker containers. For that we will use Docker Machine, you can read more about it on this web page “Use Docker Machine with the Azure driver“.
Using Docker for Windows, I execute the following docker-machine command to create the machine
After a couple of minutes, we can check on the Azure cloud portal, All resources menu, that Azure created everything for us
Finally, we need to get the configuration to talk to that machine, and it’s Docker daemon
Then execute the last line which will configure our local environment
& “C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe” env hipchatconnect | Invoke-Expression
Now each docker commands will be executed by the machine hosted on Azure cloud.
Easy and awesome!
Next step is to have a Docker container to deploy! We will use the container from my previous post “ASP.NET Core RC2, Docker and HipChat Connect add-on“.
First, we need to build an image using the following command
Then we need to get the public IP of our machine on the Azure portal
We can run the container on Azure cloud with
docker run -d -p 80:5000 -e NGROK_URL=’http://188.8.131.52' hipchatconnect
To be able to connect to our connector on the HTTP port 80, we will need to configure the firewall
and finally, connect to it!
What a great experience to be able to create a machine in the Azure Cloud from the command line and deploy our software so quickly!
Now that it works we will need to tackle the next issue, which is to expose the container through https because HipChat Connect needs it so that the add-on can be installed in HipChat. But that’s for another post.