Azure文件共享路径与使用ARM模板的容器实例卷路径映射



是否有人成功地将Azure文件共享路径映射到容器卷路径?我特别寻找在azure中安装Allure Docker容器并将容器卷路径映射到Azurefile共享路径。

我使用了ARM模板和yml文件。但是我找不到在Azure文档中定义或解释的挂载卷路径。

我还看到了一个选项,人们可以创建自己的容器并将其托管在Azure容器注册表中,然后他们可以使用docker-compose文件来映射卷路径。这不是我想要的。我不想在ACR中托管容器。我一直使用第三方容器。

{
"$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"
}
}
]
}
}
]
}

我没有看到你的ARM模板有任何问题,它在我这边工作得很好。当您在容器上映射Azure文件共享时,您可以看到该路径中的文件。但是需要注意,路径必须是新路径,否则在映射之前该路径中不存在文件。Azure文件共享将隐藏以前存在的文件。下面是关于将Azure文件共享映射到ACI的示例。

好了,在用Azure容器和Fileshare调试了很多之后,我终于得到了答案。"mountPath"基本上是要映射回Azure Fileshare目录的容器卷路径。但是该路径不需要存在于fileshare目录中。只有根名称/acshare应该与您的fileshare目录匹配。在我的例子中,它是/acshare/projects。修复此问题后,我可以看到卷正确地将文件复制到/acshare/projects目录,我可以重新启动容器或重新创建容器,文件被保留并重新同步回容器。