How to deploy an Azure Files storage share into a container using a json template

Zubin Sethna 41 Reputation points
2025-05-04T06:48:23.44+00:00

In my storage account I've created an Azure Files share that I want to add to a Linux container that I already have deployed. What I want to do is redeploy the container using an ARM template with the file share mounted. How exactly to do this?

The existing template for the container looks like this (some fields anonymised) :

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "containerGroups_tds_name": {
            "defaultValue": "tds",
            "type": "String"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.ContainerInstance/containerGroups",
            "apiVersion": "2024-10-01-preview",
            "name": "[parameters('containerGroups__name')]",
            "location": <azure location>",
            "properties": {
                "sku": "Standard",
                "containers": [
                    {
                        "name": "[parameters('containerGroups__name')]",
                        "properties": {
                            "image": "[concat(<image name>), ':latest')]",
                            "command": [
                                "/bin/bash",
                                "-c",
                                "echo Hello; service apache2 restart; sleep infinity"
                            ],
                            "ports": [
                                {
                                    "protocol": "TCP",
                                    "port": 80
                                },
                                {
                                    "protocol": "TCP",
                                    "port": 19390
                                }
                            ],
                            "environmentVariables": [],
                            "resources": {
                                "requests": {
                                    "memoryInGB": 1.5,
                                    "cpu": 1
                                }
                            }
                        }
                    }
                ],
                "initContainers": [],
                "imageRegistryCredentials": [
                    {
                        "server": "<server>",
                        "username": "<uname>"
                    }
                ],
                "restartPolicy": "OnFailure",
                "ipAddress": {
                    "ports": [
                        {
                            "protocol": "TCP",
                            "port": 80
                        }
                    ],
                    "ip": "<ip address>",
                    "type": "Public",
                    "dnsNameLabel": "[concat(parameters('containerGroups__name'), '<something>')]",
                    "autoGeneratedDomainNameLabelScope": "TenantReuse"
                },
                "osType": "Linux"
            }
        }
    ]
}

For the storage account I have the share name, storage account name and the storage account key. Plus of course the mount point inside the Linux container where I want to access the storage. So how can I do this?

Azure Container Instances
Azure Container Instances
An Azure service that provides customers with a serverless container experience.
757 questions
0 comments No comments
{count} votes

Accepted answer
  1. Markapuram Sudheer Reddy 2,050 Reputation points Microsoft External Staff Moderator
    2025-05-05T05:18:21.2233333+00:00

    Hi Zubin Sethna

    Try updating your existing ARM template to include the Azure File Share configuration. This involves adding a volumes section at the container group level and a volumeMounts section inside the container definition.

    User's image

    To mount an Azure file share as a volume in Azure Container Instances, you require: the storage account name, the share name and the storage access key.

    User's image

    Once deployment is completed, you can verify by connecting to container and execute, df -hUser's image

    Please check below documentation for more information:

    https://learn.microsoft.com/en-us/azure/container-instances/container-instances-volume-azure-files

    https://learn.microsoft.com/en-us/azure/templates/microsoft.containerinstance/containergroups?pivots=deployment-language-bicep

    If the information is helpful, please click on "Accept Answer" and "Upvote"

    If you have any queries, please do let us know, we will help you.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.