Skip to content

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

LuBu0505 edited this page Mar 14, 2022 · 1 revision

问题描述

应用服务中发布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

  1. In the Azure portal, navigate to the app.

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

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

    Setting Description
    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 containerhttps://docs.microsoft.com/en-us/azure/app-service/configure-connect-to-azure-storage?pivots=container-linux&tabs=portal#mount-storage-to-linux-container

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!

分类: 【Azure 应用服务】

标签: App ServiceApp Service for Container

Clone this wiki locally