Hey there, Welcome to the 8th blog in Microservices series. In our previous blog we have built a CI pipeline for our repository using GitHub Actions. In this blog, we will start on CD (Continuous Deployment).
I have planned this in two blogs, one to setup things required & do manual testing, then to automate it using our favorite GitHub Actions. So, let’s begin.
Steps Involved
- Create Azure Container Registry.
- Login to ACR from cloud shell.
- Push Docker Image to ACR.
- Create Azure App Service.
- Configure App Service to use Docker Image.
- Test our API via requests from POSTMAN.
Create Azure Container Registry
Login to Azure portal using your subscription account. If you’re a student and looking for free subscription, here’s the link. Once you login to Azure, search for Azure Container Registry service. Fill in the information required, and click on Review+Create.

As you can see, our azure container registry is named as helloWorldBlog.azurecr.io. Once you click on Review, Azure validates our configuration for the container registry. If everything’s good, you should see validation passed on the portal.

Now, you can click on Create. It will take few mins before the resource comes online. Once the deployment is done, Azure will notify you the same.

Login to Azure Container Registry
You will need Azure cloud shell to login to ACR. Here’s the link to download. Once Downloaded, run the following command.
az acr login --name <acr-name> --expose-token
In our case, ACR name is helloWorldBlog. Here’s how it looks like.

Once logged in, you would receive an access token. If you’re not new to this blog, you must’ve already installed Docker, else please install from here. Now, we need to authorize our Docker to push and pull images from Azure container registry.
Use the command suggested by Azure Cloud shell to authorize docker.
docker login <acr-name> -u 00000000-0000-0000-0000-000000000000 -p <access-token>
In our case, the ACR name is set to helloworldblog.azurecr.io
docker login helloworldblog.azurecr.io -u 00000000-0000-0000-0000-000000000000 -p <access-token>
Use the access token, you would get as a result of previous command while logging into azure using cloud shell.
Push Image to Docker
Before pushing our Microservice image to Docker, let’s make sure we have the latest image created from latest code. Please pull from this repo if you need to pull latest.
docker build -t helloworldblog.azurecr.io/microservice:latest .
You need to use your Container Registry URL to make push using docker. The name followed by `/` is the name of your image followed by tag. Once the build is successful, let’s push our image to ACR.
docker push helloworldblog.azurecr.io/microservice
Here’s how it looks like,

Make sure you use the proper tag, if you have anything other than latest.
That’s it, we have our images now on cloud container registry. Now, let’s make use of Azure App service to make our service publicly available.
Azure App Service
Now, comeback to Azure portal and now search for Azure Web App service. Once you see it, click on create. Fill in the required information. Here’s the sample for reference.

You can see, we have used `microservices-in-go.azurewebsites.net` as host for our Instance. Choose Docker container as publish profile, and Linux as operating system to make it light weight.
Make sure you choose the free tier available for computational resources, as this is only for educational purposes. Else, you’re free to choose compute size based on your requirement.
As we have set Docker as our publish profile, we need to configure docker image in our App service, click on Next: Docker.
In the following page, use our ACR to pull the docker image, and specify the tag & image you wish to use.

We have used our helloWorldBlog registry, and our microservice image with latest tag to spin the container up in our app service.
If you face any issues using ACR, you need to enable admin on your Azure Container registry. Please use the below command from Azure CLI.
az acr update -n helloworldblog.azurecr.io --admin-enabled true
Once you’re done with configuring Docker Image for our App service, click on Review+Create.
Once your deployment is up, navigate to configuration section of our App service to configure few environment variables for our microservice.
- AZURE_DEPLOYMENT: TRUE
- USER_NAME: admin
- USER_PASS: p@ssword
You can modify USER_NAME & USER_PASS as you wish, those values will be used for Basic Auth in our microservice. If you want to know, how we did it head over to this blog on our series.

Test our deployment using POSTMAN
Open POSTMAN. If you haven’t downloaded yet, Here’s the link to download. Create a new request to get our products, we need to set Authorization header based on the credentials you have created in App Configuration.

Select Basic Authorization in drop-down, and fill in the credentials and hit our app service on https://microservices-in-go.azurewebsites.net/products.
Huhoo, we did it. Our API is now public & deployed on Azure.

But, it’s a tedious process to build an image on every new feature & push it to ACR manually. Let’s automate it in our next blog, using our favorite GitHub Actions (Continuous Deployment). Until then, stay safe. Cheers ✌️.
One response to “Microservices in Go: Part – VIII: Deploy to Azure using ACR & App Service”
[…] In our previous blogs, we used GitHub actions to create Docker image of our codebase on every push happening to master branch. Then, we have seen how to deploy our App on Azure using Azure Container Registry & Azure App services. […]
LikeLike