1. 程式人生 > 其它 >【應用服務 App Service】App Service For Linux 中如何掛載一個共享資料夾呢? Mount Azure Storage Account File Share

【應用服務 App Service】App Service For Linux 中如何掛載一個共享資料夾呢? Mount Azure Storage Account File Share

問題描述

使用Linux作為伺服器執行Web App時,如何將 Storage Account 作為本地共享裝載到 App Service for Linux / Container 中的應用呢?

問題解答

根據官網介紹, App Service For Linux / Container 是可以通過配置完成Mount Azure Storage Account的blob或者是File Share 到Linux環境中的。 它主要的優勢有以下四點:

  1. 為App Service 應用配置永久性儲存,並單獨管理儲存。
  2. 使靜態內容(如視訊和影象)可隨時用於App Service應用。
  3. 將應用程式日誌檔案寫入 Azure 檔案共享,或將較舊的應用程式日誌存檔到 Azure 檔案共享。
  4. 跨多個應用或與其他 Azure 服務共享內容。

操作步驟可以詳細參考:以本地共享(容器)形式裝載 Azure 儲存 - Azure App Service | Microsoft Docs

新增 Azure Storage Mount 的內容說明如下:

名稱(Name) :裝載配置的名稱。 不允許空格。
配置選項 (Configuration options): 如果儲存帳戶未使用服務終結點或專用終結點,則選擇“基本”。 否則,選擇“高階”。
儲存帳戶 (Storage accounts):Azure 儲存帳戶。
儲存型別 (Storage type):根據要裝載的儲存選擇型別。 Azure Blob 僅支援只讀訪問。


儲存容器 / 共享名(Storage container / Share name) :要裝載的檔案共享或 Blob 容器。
訪問金鑰(僅高階)(Access Key) :儲存帳戶的訪問金鑰。
裝載路徑(Mount path) :要裝載到 Azure 儲存的 Linux 容器中的目錄。 不要使用 / 或 /home。

問題驗證

在App Service門戶中,進入SSH頁面(https://<yourappservicename>.scm.chinacloudsites.cn/webssh/host),執行df –h 顯示檢視File Share是否Mount成功。

在/appcontent目錄中新建檔案test1.txt,然後在Storage Account中檢視檔案是否存在

也可以在SSH中通過 tcpping 來檢視App Service Storage Account之間的網路連通性

tcpping <Storageaccount>.file.core.chinacloudapi.cn 

參考文件

將 Azure 儲存作為本地共享裝載到應用服務中的容器應用https://docs.microsoft.com/zh-cn/azure/app-service/configure-connect-to-azure-storage?tabs=portal&pivots=container-linux#mount-storage-to-linux-container

Linux df command - displays number of free disk blocks and free files :https://docs.oracle.com/cd/E23823_01/html/816-5166/df-1m.html#REFMAN1Mdf-1m

-h
Like -k, except that sizes are in a more human readable format. The output consists of one line of information for each specified file system. This information includes the file system name, the total space allocated in the file system, the amount of space allocated to existing files, the total amount of space available for the creation of new files by unprivileged users, and the percentage of normally available space that is currently allocated to all files on the file system. All sizes are scaled to a human readable format, for example, 14K, 234M, 2.7G, or 3.0T. Scaling is done by repetitively dividing by 1024.

This option overrides the -b, -e, -g, -k, -n, -t, and -V options. This option only works on mounted filesystems and can not be used together with -o option.

-k
Prints the allocation in kbytes. The output consists of one line of information for each specified file system. This information includes the file system name, the total space allocated in the file system, the amount of space allocated to existing files, the total amount of space available for the creation of new files by unprivileged users, and the percentage of normally available space that is currently allocated to all files on the file system. This option overrides the -b, -e, -n, and -t options.

-l
Reports on local file systems only. This option is used only for mounted file systems. It can not be used with the -o option.

當在複雜的環境中面臨問題,格物之道需:濁而靜之徐清,安以動之徐生。 雲中,恰是如此!