Connect Azure container to two volumes/file shares

Viewed 329

The following command creates a container in Azure that is mapped to a file share/volume:

az container create -g MyResourceGroup --name myapp --image myimage:latest 
 --azure-file-volume-share-name myshare --azure-file-volume-account-name mystorageacct 
 --azure-file-volume-account-key mystoragekey --azure-file-volume-mount-path /mnt/azfile

But I need my container to be mapped to two volumes, not just one. Is this possible?

1 Answers

I do not know if it is possible to do this via azure cli. I do know that you can do this through Azure Resource Manager Templates.

In this example, see how the container group has an array of volumes, while each container can have an array of volume mounts.

{
    "type": "Microsoft.ContainerInstance/containerGroups",
    "apiVersion": "2018-10-01",
    "name": "[parameters('ContainerGroupName')]",
    "location": "australiaeast",
    "identity": {
        "type": "UserAssigned",
        "userAssignedIdentities": {
            "[variables('managedIdentityId')]": {}
        }
    },
    "dependsOn": [
        "[variables('managedIdentityId')]"
    ],
    "properties": {
         "containers": [
         {
             "name": "[parameters('ContainerGroupName')]",
             "properties": {
                 "image": "[parameters('SourceImage')]",
                 "ports": [{"port": 80},{"port": 443}],
                "environmentVariables": [],
                "resources": { "requests": { "memoryInGB": 1.5, "cpu": 1 } },
                 "volumeMounts": [
                       {
                         "name": "httpscertificatevolume",
                         "mountPath": "/https"
                       },
                      {
                        "name": "videofoldervolume",
                        "mountPath": "[variables('videoFolderMountPath')]"
                      }
                  ]
              }
          }
        ],
        "volumes": [{
                        "name": "httpscertificatevolume",
                        "azureFile": {
                            "shareName": "[parameters('HttpsCertificateFileShare')]",
                            "storageAccountName": "[parameters('StorageAccountName')]",
                            "storageAccountKey" : "[parameters('StorageAccountKey')]"
                         }
                    },
                    {
                        "name": "videofoldervolume",
                        "azureFile": {
                            "shareName": "[parameters('VideoFileShare')]",
                            "storageAccountName": "[parameters('StorageAccountName')]",
                            "storageAccountKey" : "[parameters('StorageAccountKey')]"
                        }
                    }
                ]
            }
        }
Related