【应用服务 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

 

附录一:容器app service 如何添加启动参数 --privileged

可以在App Service的Configuration 配置页面中对启动命令一项中根据需求进行设置。如设置 –privileged = true

设置保存后,通过kudu( https://<your app service name>.scm.chinacloudsites.cn/ )站点进入bash页面,查看Logfiles中的日志文件。可以查看到docker run指令中已经包含了 –privileged=ture 参数。

 

 

 

参考文档

 

将 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.

 

 

相关文章
|
20天前
|
存储 安全 数据安全/隐私保护
【Azure Function App】在Function App中使用System Managed Identity访问Storage Account
本文介绍了如何在Azure Function中使用托管身份(Managed Identity)替代AzureWebJobsStorage连接函数应用到存储账户,以提高安全性并减少Access Key的使用。具体步骤包括:1) 启用系统分配的身份;2) 为函数应用授予存储访问权限,添加必要角色(如Storage Blob Data Contributor);3) 配置`AzureWebJobsStorage__blobServiceUri`参数指定Blob Service Uri。完成后删除旧配置,即可通过Managed Identity访问Storage Account。
77 20
|
3月前
|
应用服务中间件 Linux nginx
【Azure App Service】基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?
基于Linux创建的App Service是否可以主动升级内置的Nginx版本呢?Web App Linux 默认使用的 Nginx 版本是由平台预定义的,无法更改这个版本。
154 77
|
2月前
|
存储 安全 开发工具
【Azure Storage Account】利用App Service作为反向代理后续 ---- 隐藏 SAS Token
本文介绍了如何通过App Service作为反向代理,将SAS Token追加到请求URL中,以避免直接在代码或配置文件中存储SAS Token带来的安全性和维护问题。具体步骤包括修改App Service的web.config Rewrite规则,将SAS Token添加到转发的URL中;并在.NET SDK中仅使用不包含SAS Token的Uri进行Blob操作。这样既提高了安全性,也简化了SAS Token的管理。
58 16
|
2月前
|
存储 XML 开发工具
【Azure Storage Account】利用App Service作为反向代理, 并使用.NET Storage Account SDK实现上传/下载操作
本文介绍了如何在Azure上使用App Service作为反向代理,以自定义域名访问Storage Account。主要内容包括: 1. **设置反向代理**:通过配置`applicationhost.xdt`和`web.config`文件,启用IIS代理功能并设置重写规则。 2. **验证访问**:测试原生URL和自定义域名的访问效果,确保两者均可正常访问Storage Account。 3. **.NET SDK连接**:使用共享访问签名(SAS URL)初始化BlobServiceClient对象,实现通过自定义域名访问存储服务。
|
8月前
|
Oracle Java 关系型数据库
Linux下JDK环境的配置及 bash: /usr/local/java/bin/java: cannot execute binary file: exec format error问题的解决
如果遇到"exec format error"问题,文章建议先检查Linux操作系统是32位还是64位,并确保安装了与系统匹配的JDK版本。如果系统是64位的,但出现了错误,可能是因为下载了错误的JDK版本。文章提供了一个链接,指向Oracle官网上的JDK 17 Linux版本下载页面,并附有截图说明。
Linux下JDK环境的配置及 bash: /usr/local/java/bin/java: cannot execute binary file: exec format error问题的解决
|
8月前
|
Docker 容器
14 response from daemon: open \\.\pipe\docker_engine_linux: The system cannot find the file speci
14 response from daemon: open \\.\pipe\docker_engine_linux: The system cannot find the file speci
165 1
|
9月前
|
应用服务中间件 Linux 网络安全
【Azure 应用服务】App Service for Linux 环境中为Tomcat页面修改默认的Azure 404页面
【Azure 应用服务】App Service for Linux 环境中为Tomcat页面修改默认的Azure 404页面
102 5
|
9月前
|
存储 Linux 开发工具
【Azure App Service】本地Git部署Python Flask应用上云(Azure App Service For Linux)关键错误
【Azure App Service】本地Git部署Python Flask应用上云(Azure App Service For Linux)关键错误
|
9月前
|
存储 Linux 网络安全
【Azure App Service】.NET代码实验App Service应用中获取TLS/SSL 证书 (App Service Linux/Linux Container)
【Azure App Service】.NET代码实验App Service应用中获取TLS/SSL 证书 (App Service Linux/Linux Container)
|
9月前
|
存储 开发框架 监控
【Azure Logic App】添加 Storage Account 来提升 Logic App 的性能
【Azure Logic App】添加 Storage Account 来提升 Logic App 的性能