跳转到内容
AsterDrive
安全更新:Docker 镜像从 v0.4.0-rc.1 起已修复 FFmpeg MagicYUV 解码器漏洞 CVE-2026-8461(高危),使用旧镜像的实例请立即升级。查看 CVE 公告
安全更新:v0.4.0-beta.3 已修复 WebDAV 请求可导致服务进程终止的问题,旧版本实例请尽快升级。查看安全公告

Azure Blob Storage 存储策略教程

Azure Blob Storage 适合这些场景:

  • 你已经在 Azure 上使用 Storage account 和 Blob container
  • 希望把文件容量、对象持久化和下载带宽交给 Azure 承接
  • 希望 AsterDrive 使用 Azure 官方 Blob SDK 访问对象,而不是把 Azure 当 S3-compatible 存储

如果你用的是 S3、MinIO、R2 或其他 S3-compatible 服务,看 S3 / MinIO / R2 存储策略教程。如果你用腾讯云 COS,并且要接数据万象能力,看 腾讯云 COS 存储策略教程

AsterDrive 里 azure_blob 是独立存储后端,不走 S3 兼容接口。

AsterDrive azure_blob 策略

Azure Blob SDK / SAS URL

Storage account

Blob container

AsterDrive azure_blob 策略

Azure Blob SDK / SAS URL

Storage account

Blob container

几个名字不要混:

AsterDrive 字段Azure 里的概念说明
EndpointBlob service endpoint例如 https://<account>.blob.core.windows.net
Bucket / 容器ContainerAzure 叫 container,不叫 bucket
Access Key / 存储账户名Storage account name不是 Access Key ID
Secret Key / 存储账户密钥Storage account key用于服务端签名 SAS
基础路径Blob name prefix可选,用于把对象放到某个前缀下

Azure Storage account

Container / 访问密钥 / CORS

AsterDrive Azure Blob 存储策略

策略组规则

用户或团队绑定策略组

Azure Storage account

Container / 访问密钥 / CORS

AsterDrive Azure Blob 存储策略

策略组规则

用户或团队绑定策略组

只创建 Azure Blob 存储策略还不够。用户或团队上传时,会先命中策略组,再由策略组规则分配到某条存储策略。

你要做什么入口
创建 Azure Blob 策略管理 -> 存储策略 -> 新建策略
测试 Azure Blob 连接管理 -> 存储策略 -> 测试连接
创建分流规则管理 -> 策略组
给用户绑定策略组管理 -> 用户 -> 用户详情
给团队绑定策略组管理 -> 团队 -> 团队详情
调公开站点地址管理 -> 系统设置 -> 站点配置 -> 公开站点地址

先在 Azure 创建或选择一个 Storage account,例如:

asterdriveprod

再创建一个专用 container,例如:

asterdrive-prod

建议给 AsterDrive 单独规划 prefix:

prod/

这样对象最终会在 container 里按 AsterDrive 的内容寻址路径继续展开。不要让多个 AsterDrive 实例写同一个 prefix,除非你明确知道它们不会互相覆盖或清理对象。

AsterDrive 当前使用 Storage account name 和 account key 访问 Azure Blob。

在 Azure Portal 里找到:

Storage account -> Security + networking -> Access keys

准备这些值:

填到 AsterDrive
Storage account nameAccess Key / 存储账户名
key1 或 key2Secret Key / 存储账户密钥
Blob service endpointEndpoint
Container nameBucket / 容器

如果你的组织使用更细的密钥轮换流程,可以先用 key2 配新策略,验证通过后再切换策略组。不要在有活动上传时直接改正在使用策略的 endpoint、container 或基础路径。

第一次接入建议先用保守路线:

方向建议初始值原因
上传方式relay_stream浏览器不需要直连 Azure Blob,少踩 CORS
下载方式relay_stream下载也先由 AsterDrive 中继,便于排查

确认基本读写没问题后,再考虑切换到:

  • 上传 presigned
  • 下载 presigned

上传时:

浏览器

AsterDrive

Azure Blob

浏览器

AsterDrive

Azure Blob

下载时:

Azure Blob

AsterDrive

浏览器

Azure Blob

AsterDrive

浏览器

好处是入口集中,排查简单。代价是应用节点要承接上传和下载带宽。

Azure Blob 下的 presigned 使用 Azure SAS URL,不是 S3 presigned URL。

上传时:

浏览器

Azure Blob SAS URL

浏览器

Azure Blob SAS URL

下载时:

浏览器

Azure Blob SAS URL

浏览器

Azure Blob SAS URL

好处是减轻 AsterDrive 节点带宽压力。前提是浏览器能访问 Azure Blob endpoint,并且 container CORS 配置正确。

4. 在 AsterDrive 创建 Azure Blob 存储策略

Section titled “4. 在 AsterDrive 创建 Azure Blob 存储策略”

进入:

管理 -> 存储策略 -> 新建策略

选择驱动类型:

Azure Blob

按下面填写:

字段示例说明
Endpointhttps://asterdriveprod.blob.core.windows.netBlob service endpoint,末尾 / 会自动规整
Bucket / 容器asterdrive-prodAzure container name
Access Key / 存储账户名asterdriveprodStorage account name,保存前会 trim
Secret Key / 存储账户密钥...Storage account key,保存前会 trim
基础路径prod/可选,作为 blob name prefix
上传方式初次建议 relay_stream稳定后再切 presigned
下载方式初次建议 relay_stream稳定后再切 presigned

保存前或保存后,先用后台的连接测试确认:

  • AsterDrive 能访问 endpoint
  • container 存在
  • account name 和 key 能完成签名和对象操作
  • 基础路径没有填错
  • 如果使用 presigned,浏览器也能访问这个 endpoint

编辑已有策略时,如果存储账户名或账户密钥字段留空,草稿连接测试会复用这条策略已经保存的凭据。这样你可以先测试 endpoint、container、基础路径、上传方式等变更,不必每次重新粘贴 account key。新建策略没有可复用凭据,仍然必须填完整。

连接测试失败时,后台会显示可用于排查的原因,并隐藏账户密钥等敏感信息。

如果连接测试失败,不要继续把用户切到这条策略。先按下面顺序查:

  1. Endpoint 是否包含 http://https://
  2. Endpoint 是否是 Blob service endpoint
  3. Container 名是否正确
  4. Storage account name 是否正确
  5. Storage account key 是否复制完整
  6. AsterDrive 服务器时间是否准确
  7. 服务器网络是否能访问 Azure Blob endpoint
  8. 如果是私有网络、专线或防火墙,是否允许 AsterDrive 所在网络访问

如果你只使用 relay_stream,浏览器不会直接请求 Azure Blob,CORS 不是第一优先级。

如果要使用 presigned 上传或下载,需要在 Azure Storage account 的 Blob service CORS 中允许 AsterDrive 站点来源。

最少关注:

建议
Allowed originsAsterDrive 的公开站点 origin,例如 https://drive.example.com
Allowed methods至少包含 PUTGETHEAD
Allowed headers至少允许 Content-Typex-ms-blob-typex-ms-versionRange,不确定时先用 * 验证
Exposed headers建议包含 ETagContent-LengthContent-RangeContent-DispositionAccept-Rangesx-ms-request-id
Max age可按你的安全策略设置,例如 600

Allowed origins 要填浏览器访问 AsterDrive 的站点 origin,通常来自:

管理 -> 系统设置 -> 站点配置 -> 公开站点地址

不要填 AsterDrive 后端到 Azure Blob 的内网地址;CORS 判断的是浏览器页面来源。

不要一上来直接改默认策略组。建议先创建一个测试策略组。

进入:

管理 -> 策略组

创建策略组,例如:

Azure Blob Test Group

添加一条规则:

字段建议
存储策略刚创建的 Azure Blob 策略
优先级保持默认或设为最先命中
文件大小范围先覆盖所有大小,方便测试

进入:

管理 -> 用户 -> 用户详情

把测试用户的策略组改成刚才创建的 Azure Blob Test Group

进入:

管理 -> 团队 -> 团队详情

把测试团队的策略组改成 Azure Blob Test Group

团队空间上传时会按团队策略组走,不按个人用户策略组走。

用被绑定到测试策略组的真实账号测试:

  1. 上传一个小文件
  2. 上传一个超过分片阈值的大文件
  3. 下载文件
  4. 分享文件并访问分享链接
  5. 删除文件,再从回收站恢复
  6. 再删除并清理回收站,确认 Azure container 里的对象清理正常

如果你准备启用 presigned,再额外测试:

  1. 把上传方式改成 presigned
  2. 上传小文件和大文件
  3. 确认浏览器可以直接连接 Azure Blob
  4. 如果启用 presigned 下载,确认下载和预览都正常

为了和其他对象存储保持一致,部分界面仍会显示 Bucket。对 Azure Blob 来说,它对应的是 container

为什么 presigned 上传失败但 relay_stream 正常?

Section titled “为什么 presigned 上传失败但 relay_stream 正常?”

relay_stream 只要求 AsterDrive 服务器能访问 Azure Blob。presigned 还要求浏览器能访问 Azure Blob endpoint,并且 CORS 允许这个浏览器来源发起 PUT / GET

优先检查:

  1. 浏览器能否访问 endpoint
  2. Storage account 防火墙是否允许客户端网络
  3. Blob service CORS 是否包含你的 AsterDrive 公开站点 origin
  4. Allowed headers 是否包含 x-ms-blob-type
  5. SAS URL 是否还在有效期内

浏览器直传地址包含短时效授权信息,生产环境应使用 HTTPS Blob service endpoint,避免上传或下载地址通过明文网络传输。

可以直接改已经使用中的 Azure 策略吗?

Section titled “可以直接改已经使用中的 Azure 策略吗?”

不要直接改 endpoint、container 或基础路径。这些字段决定旧文件在哪里。更稳的做法是:

  1. 新建一条 Azure Blob 策略
  2. 创建测试策略组验证
  3. 如果要迁移已有数据,用 管理 -> 存储策略 -> 迁移数据
  4. 完成后再调整用户或团队的策略组
  • Storage account 和 container 已准备好
  • Account name 和 key 已填对,并已通过连接测试
  • 基础路径规划清楚,不和其他实例混用
  • 上传 / 下载方式已按网络条件选择
  • 如果使用 presigned,Blob service CORS 已配置
  • 用测试用户上传、下载、分享、删除、恢复都通过
  • 大文件分片上传通过
  • 生产环境使用 HTTPS endpoint
  • 已确认 Azure 存储容量、请求次数和出站流量费用边界