问题描述

应用服务中发布Docker Container,如何添加卷(如Azure File Share)以便永久存储文件

 

问题解答

App Service可以通过门户配置Mount Storage,用于添加卷(Volumes)。 操作办法见:https://docs.microsoft.com/en-us/azure/app-service/configure-connect-to-azure-storage?pivots=container-linux&tabs=portal#mount-storage-to-linux-container

Mount storage to Linux container

In the Azure portal, navigate to the app.

From the left navigation, click Configuration > Path Mappings > New Azure Storage Mount.

Configure the storage mount according to the following table. When finished, click OK.

SettingDescription

Name

Name of the mount configuration. Spaces are not allowed.

Configuration options

Select Basic if the storage account is not using service endpoints or private endpoints. Otherwise, select Advanced.

Storage accounts

Azure Storage account.

Storage type

Select the type based on the storage you want to mount. Azure Blobs only supports read-only access.

Storage container or Share name

Files share or Blobs container to mount.

Access key (Advanced only)

Access key for your storage account.

Mount path

Directory inside the Linux container to mount to Azure Storage. Do not use / or /home.

Note

Adding, editing, or deleting a storage mount causes the app to be restarted.

 

但是,如果使用的Multi-Container部署的App Service,还需要再Compose yaml file文件中指定 Mount的文件夹Path。

version: '3.1'

services:

nginx:

image: nginx:latest

ports:

- 8080:80

volumes:

- storagecustomid:/test/mount

 

参考资料

使用自定义容器将自定义软件迁移到 Azure 应用服务: https://docs.microsoft.com/zh-cn/azure/app-service/tutorial-custom-container?pivots=container-linux

在 Azure 容器实例中装载 Azure 文件共享:https://docs.microsoft.com/zh-cn/azure/container-instances/container-instances-volume-azure-files

Mount storage to Linux container:https://docs.microsoft.com/en-us/azure/app-service/configure-connect-to-azure-storage?pivots=container-linux&tabs=portal#mount-storage-to-linux-container

精彩内容

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。