How to create Azure container Instance (ACI) with Private Azure File as Mounted Volume

Herve Khg
2 min readFeb 17, 2021

Last week I’ve decided to try Azure Container Instance for processing a Go script that shares images between container registries (ACR). Previously the script was executed manually on my computer and I needed to automate it in order to save time. Below I will describe to you the steps of writing in terraform code to build this useful stuff.

The creation of image and container registry it’s not described on this post. It’s a prerequistes to build them before.

Step 1: Create the Storage account with File Share

The storage account contains a File share that will store the config files of my script. The volume will be mounted on this File Share.

Step 2: Upload config files on File share

I use a null_ressource that execute an az command because currently terraform (version 0.13.6) do not allow upload on a file share (unlike blob storage)

Step 3: Create the ACI and the subnet

The code below creates the subnet, the network_profile, and the container_group for the Container Image.

Step 4: Create the private endpoint to access storage

This step is the main important. Without it, your Container Instance will not be able to mount the volume (Azure File) and will stay in-state “Waiting”. Terraform will stay in error after 30 minutes. It’s taken me a lot of time to find the problem.

Final Step: Deploy Your code

Launch terraform or terragrunt apply and enjoy !

--

--

Herve Khg

Multi Cloud (Azure/ AWS) Systems/Devops Engineer in France.