Use Terraform to connect ACR with Azure Web App

You can connect an Azure Web App to Docker Hub, Private Repository and also an Azure Container Registry(ACR). Using Terraform you can take it a step further and build your whole infrastructure environment at the same time as connecting these container registries. However, how do you connect them together in Terraform?

I am going to focus on the connection of an ACR, but you can also follow the same method for the other providers.

Why I am using this as an example, is when correcting the other methods they are a simple URL, username and password, but the Azure Container Registry within the portal has a different user interface where it connects natively in the Azure. Why I was learning to do this, I kept getting my ACR connecting like a private repository instead of an actual ACR. Therefore, the method below will have the desired outcome of within the Azure portal the Web App showing it is connected to an ACR.

I will go through the general setup I have got for a simple Web App connecting to an ACR with all of the supporting  elements. I am not showing best practice of having the variables and outputs in separate files as this is not the point of the post, but I would encourage people to do that.

First we will need to create the infrastructure to support the Web App, by connecting to the Azure Resource Manager provider in Terraform:

provider "azurerm" {
  version         = "=2.25.0"
  subscription_id = var.subscription_id
  features {}

This passes a ‘subscription_id’ variable to connect to the correct subscription. We then create the Resource Group to contain all the resources.

variable "resource_group_name" {
  type        = string
  description = "Azure Resource Group Name. "
variable "location" {
  type        = string
  description = "Azure Resource Region Location"

# Create a Resource Group
resource "azurerm_resource_group" "acr-rg" {
  name = var.resource_group_name
  location = var.location  

The next part is to create the Azure Container Registry with your chosen name and the SKU for the service level you would like. For this example we have use the ‘Standard’ to keep it cheap and simple, while using the same location as the Resource Group.

variable "container_registry_name" {
  type        = string
  description = "Azure Container Registry Name"

# Azure Container Regristry
resource "azurerm_container_registry" "acr" {
  name                     = var.container_registry_name
  resource_group_name      =
  location                 = azurerm_resource_group.acr-rg.location
  sku                      = "Standard"
  admin_enabled            = true

For the Web App we will need an App Service Plan to contain the Web App and set the SKU Level. You can see this is the same as before using the same locations and also I am using Linux as the base operating system.

variable "app_plan_name" {
  type        = string
  description = "Azure App Service Plan Name"

# App Plan
resource "azurerm_app_service_plan" "service-plan" {
  name = var.app_plan_name
  location = azurerm_resource_group.acr-rg.location
  resource_group_name =
  kind = "Linux"
  reserved = true  
  sku {
    tier = "Standard"
    size = "S1"

Now is where we declare the Web App itself, but first create the 3 variables we will need. The Web App name, your Registry name and the Tag assigned to your image.

variable "web_app_name" {
  type        = string
  description = "Azure Web App Name"
variable "registry_name" {
  type        = string
  description = "Azure Web App Name"
variable "tag_name" {
  type        = string
  description = "Azure Web App Name"
 default: 'latest'

To link to Docker Registries you need 3 App Settings configured ‘ DOCKER_REGISTRY_SERVER_URL’, ‘ DOCKER_REGISTRY_SERVER_USERNAME’, and ‘DOCKER_REGISTRY_SERVER_PASSWORD’.

These are used to gain the correct access to the registries.

For the ACR, the URL is the ‘Login Server’ and then the username/password is the Admin Username/Password.

These can be found here in the portal, if your ACR is already created.

For example:


A key part to see here is the URL is prefixed with the ‘https’ and it needs to be this, not http as it needs to be secure.

Instead of getting these details manually, we are using Terraform so we have access to these details from the created Azure Container Registry that we can use:

    DOCKER_REGISTRY_SERVER_URL              = "https://${azurerm_container_registry.acr.login_server}"
    DOCKER_REGISTRY_SERVER_USERNAME = azurerm_container_registry.acr.admin_username
    DOCKER_REGISTRY_SERVER_PASSWORD = azurerm_container_registry.acr.admin_password

We now have a connection to the ACR, but need to tell the Web App what registry and tag to look for. As we are using a Linux based server, we configure the ‘linux_fx_version’ in the site config with this pattern below, but for Windows you would use ‘windows_fx_version’.


For an example with a registry name MyRegistry and a tag name MyTag:


Below is the full example of the Web App generation in Terraform. With all these parts together you should have a Resource Group containing a ACR, App Service Plan and a Web App all connected.

# web App
resource "azurerm_app_service" "app-service" {
  name = var.web_app_name
  location = azurerm_resource_group.acr-rg.location
  resource_group_name =
  app_service_plan_id =
  app_settings = {
    # Settings for private Container Registires  
    DOCKER_REGISTRY_SERVER_URL      = "https://${azurerm_container_registry.acr.login_server}"
    DOCKER_REGISTRY_SERVER_USERNAME = azurerm_container_registry.acr.admin_username
    DOCKER_REGISTRY_SERVER_PASSWORD = azurerm_container_registry.acr.admin_password
  # Configure Docker Image to load on start
  site_config {
    linux_fx_version = "DOCKER|${var.registry_name}:${var.tag_name}"
    always_on        = "true"
  identity {
    type = "SystemAssigned"

## Outputs
output "app_service_name" {
  value = "${}"
output "app_service_default_hostname" {
  value = "https://${}"

Is Home Working the New Normal?

Change was always coming for people to be working from home and not from company offices, but it looks like the Covid-19 events have forced this change to be pushed my faster. While some companies are struggling to get working practices in place, some are working with this very well and finding that this might be the new normal. What could normal look like after the pandemic has passed?


Some employers seem to be avert from their employees working from home and I think some of it is due to trust. When your boss can see you, then they can see you doing work, which is what they want you to be doing on their time. However, this puts a piece of distrust in the middle that doesn’t make it a fun place to work, but a duty you have to do. Giving your employee’s trust to get the job done at home or in the office means they will feel respected and more inclined to get the job done. From the employer view you still want to know that the work is getting done, which is to be expected, but this can be done still by putting in Key Performance Indicators(KPIs). As a developer my KPIs are measure by how many backlog tickets I get complete to the expected standard. If these drop then my boss knows I might not be pulling my weight and need to review why I am not performing. This can all be done remotely without having to have a Big Brother camera on my back.

Digital Office.

Another issue that is stopping people today in the pandemic is Technical issues. I know from a friend working in a very large company, they were in the process of trialing people working from home 2 days a week before, but only a portion of people were doing that. This was due to the company employing thousands of employees around the whole global, so they have a very large amount of people to support on a global system, that was never intended when created to support people on unsecure networks at home or even at coffee shops. Therefore they have had to make a large technical shift to get the infrastructure in place, which is no small task, however they are doing it. If you are an older company trying to shift or even a new company starting out, there are hundreds of tools out there to support your company to get the technical set up at a reasonable cost. This doesn’t have to cost with free tooling’s like Slack ( for online chatting, Azure DevOps( for coding, Google Drive( for storing documents and a lot of other options for emailing. These can make your shift cheap, but mainly only for small teams. When you are a larger company this cost can grow, but you would want the support for the larger teams.


I have ready talked about how communication and trust are parts of keeping the team working while you can’t see them. This works well with employee’s that work on their own with some check-ups like developers, but not all industries are like this and even some aspect of development are not as well. For instance if you are trying to have a brain storm session, I normally love getting the whiteboard into play for drawing designs and ideas. However, you shouldn’t really draw on your monitors… in pen, but you can get the whiteboard feature on most chat tools. This is another example of technology taking the physical tools in the office to the digital world.

Then there is the old school managers that prefer that face to face value for conversations. When you have a problem you can stand up and walk over to your colleges desk for some assistance (at 2 meters at the moment). However, with online people are more inclined to send a quick IM on their chat service, brush their hands together and say ‘well at least I tried’ before going to get their 100th coffee break. This is the hardest part I think to overcome, the social and closeness of being near your colleges to collaborate. This is not due to home working not working though, but rather a change of mind set and working practices. I know I prefer to just message people as it is easier to get it off my desk so I can focus on something else, but instead while working from home I am starting to try change my mindset to call people via phone or video chat to get to the conclusion faster. This effort, like any change in a company, needs to come from the top down, so your boss need to encourage it and stick to it as well, so the monkeys follow the banana. The other part of this as mentioned, is using video chat where possible. This can break the wall of just talking to an anonymous person to having the face to face connection of seeing facial expression and context. Also as well as bringing more connection, it means you are forced to put clothes on.


I mentioned some of the costs of setting up a collaborative network of chat and working tools, that don’t always need to cost so much, but they are only some of the costs. There can be costs to your employer if they so choose as some companies choose to pay a contribution to their employee’s internet, electric and heating. These are normal cost that are being used at the office that the company pays for, so why not when you are at your home office? This is where I am on the employers side, as you are saving on travel and possibly lunch costs, I think it is only right you pay for the home costs. If companies do pay for these then it is perk as if you was out at a coffee shop or another location, then you are basically getting free money. Working from home is to benefit both parties, so where they make a saving on your desk costs, you make a saving on travel and food. Where you will need to increase your home costs potentially, the company will be increasing their running cost for the digital office technology. This as you can tell is a give and take partnership between you and your company.

Home or Office.

Personally I think working from home is the future for most industries where possible. It saves on so much and bring more to both sides of the coin, but I do also think that there is a need for a base. I enjoy the flexibility of working from home and I have been able to see my daughter grow up, which I might have missed being in the office. However, I do like to have separation from the home life sometimes and from these four walls. Going into the office now and again, gives me a change of scenery and is great for collaborative meetings. Therefore, I think having the home working 3-4 days a week and then in a hot desk office 1-2 days, is the perfect balance of life. Lets see where it goes from here though…

BadImageFormatException When Running 32/64 Bit Applications in Jet Brains Rider

I posted before about the error of getting BadImageFormatException and how it was associated to the processor settings. The fixed suggested were for Visual Studio only and in recent times I have now started working with Jet Brains Rider, which I then got the same issue, but found the correcting process.

If you do have Visual Studio and have this issue then you can read how to correct it on this post. BadImageFormatException When Running 32/64 Bit Applications in Visual studio

If you are using Jet Brains Rider then you can follow this instead.

  1. Open up your .Net Framework Project in Jet Brains Rider
  2. Select ‘Edit Configuration’ from the top right menu:
  1. Within the new window that opens you can then change the IIS Express path, which currently you can see is using the ‘x86’ version that is 32 bit. Update the path without this to configure the 64 bit version.