Azure App Services, the way to run your Golang app
At the time of writing this article Golang is not natively supported in the Azure App Services. My solution described below base on docker images. In the first step I am going to show you how I managed deployment of my app base on the docker image. In the second one, how I automated docker image creation after each commit which is going to redeploy my app in the Azure App Services. Related GitHub repository you can find here.
App Deployment
Steps below require from you to push initial docker image version to your docker repository. This image is needed to deploy app using az cli
. What I am going to do here is to create App Service Plan then deploy my app.
az loginRGNAME=go-cicd-rg
ASPNAME=go-cicd-asp
APPIMAGE=michalsw/simple-web-server:latest
# >> Create App Service planaz appservice plan create \
--name $ASPNAME \
--resource-group $RGNAME \
--sku F1 \
--is-linuxaz appservice plan list -g $RGNAME --output table
# >> Deploy Golang App as a App Serviceaz webapp create --resource-group $RGNAME --plan $ASPNAME --name demogoapp --deployment-container-image-name $APPIMAGEaz webapp list \
-g $RGNAME \
--query "[].{hostName: defaultHostName, state: state}" \
--output table
HostName State
--------------------------- -------
demogoapp.azurewebsites.net Runningaz webapp log show --name demogoapp -g $RGNAMEcurl demogoapp.azurewebsites.net
ok
Automated workflow
To build an automated workflow for my app deployment I am going to use custom containers and GitHub Actions.
Once App Service is deployed (I did it in the previous step) you have to generate deployment credentials (publish profile in this case). Detailed flow is described here.
Configure GitHub repo’s secrets (include docker registry credentials).
Configure workflow file in the /.github/workflows/
directory. For my repo you can find workflow file here.
Push commit and check workflows in GitHub Actions. Examples here.
And that’s it. Simple, isn’t it? Someone may say that it’s not a perfect solution but this is just a proof of concept how you can manage Golang apps if you want to use App Services.