Search code examples
azurecontainersazure-rm-templateallureazure-files

Azure fileshare path with container instance volume path mapping using ARM templates


Has anyone had success in mapping Azure fileshare path mapping with Container volume path. I'm specifically looking for Allure Docker container mounting in azure and mapping container volume path to Azurefile share path.

I have used ARM templates and also yml files. but no where I could find mounting volume paths defined or explained in Azure docs online.

Also I saw an option where one can create their own container and host it in Azure container registry and then they can use docker-compose file to map the volume paths. Which is not I'm after. I dont want to host container in ACR. I'm using third party container always.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "containerGroups_tst_tf_allure_report_api_aci_name": {
      "defaultValue": "tst-tf-allure-report-api-aci",
      "type": "String"
    }
  },
  "variables": {},
  "resources": [
    {
      "type": "Microsoft.ContainerInstance/containerGroups",
      "apiVersion": "2019-12-01",
      "name": "[parameters('containerGroups_tst_tf_allure_report_api_aci_name')]",
      "location": "[resourceGroup().location]",
      "properties": {
        "sku": "Standard",
        "containers": [
          {
            "name": "[parameters('containerGroups_tst_tf_allure_report_api_aci_name')]",
            "properties": {
              "image": "frankescobar/allure-docker-service",
              "ports": [
                {
                  "protocol": "TCP",
                  "port": 5050
                }
              ],
              "volumeMounts": [
                {
                  "name": "filesharevolume",
                  "mountPath": "/mnt/acishare/projects"
                }
              ],
              "environmentVariables": [
                {
                  "name": "CHECK_RESULTS_EVERY_SECONDS",
                  "value": 1
                },
                {
                  "name": "KEEP_HISTORY",
                  "value": 1
                },
                {
                  "name": "KEEP_HISTORY_LATEST",
                  "value": 25
                }
              ],
              "resources": {
                "requests": {
                  "memoryInGB": 1,
                  "cpu": 1
                }
              }
            }
          }
        ],
        "initContainers": [],
        "restartPolicy": "OnFailure",
        "osType": "Linux",
        "ipAddress": {
          "ports": [
            {
              "protocol": "TCP",
              "port": 5050
            }
          ],
          "type": "Public"
        },
        "volumes": [
          {
            "name": "filesharevolume",
            "azureFile": {
              "shareName": "acishare",
              "storageAccountName": "acistoragev1",
              "storageAccountKey": "zzzxxxxxxxxxddddddddddddddd"
            }
          }
        ]
      }
    }
  ]
}

Solution

  • Alright after debugging alot with Azure container and Fileshare, I got the answer finally. The "mountPath" is bascially the container volume path which you want to map back to Azure Fileshare directory. But the path does not need to exists on the fileshare directory. just the root name /acishare should match to your fileshare directory. In my case above it is /acishare/projects. After fixing this I can see the volume is correctly copying files to /acishare/projects directory and I can restart container or re-create container, the files are retained and re-sycned back to the container.