You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Azure中如何配置支持Blob Storage读写的计算资源?

可行的替代方案推荐

1. 直接通过Azure Storage SDK在Linux Web App中读写Blob

这是最适配你原型开发场景的方案,完全不需要依赖路径映射,且消费计划免费额度完全覆盖:

  • 无需修改Web App的挂载配置,直接在应用代码中集成Azure Storage SDK(比如Python的azure-storage-blob、Node.js的@azure/storage-blob)
  • 授权推荐用Managed Identity:在Web App的"标识"设置中开启系统分配的标识,给该标识分配Blob Storage的"存储Blob数据参与者"角色,无需硬编码连接字符串,安全性更高
  • 代码示例(Python):
    from azure.storage.blob import BlobServiceClient
    from azure.identity import DefaultAzureCredential
    
    credential = DefaultAzureCredential()
    blob_service_client = BlobServiceClient(account_url="https://<你的存储账户名>.blob.core.windows.net", credential=credential)
    
    # 上传Blob示例
    container_client = blob_service_client.get_container_client("<容器名>")
    with open("local-file.txt", "rb") as data:
        container_client.upload_blob(name="remote-file.txt", data=data, overwrite=True)
    
    # 下载Blob示例
    blob_client = container_client.get_blob_client("remote-file.txt")
    with open("downloaded-file.txt", "wb") as download_file:
        download_file.write(blob_client.download_blob().readall())
    
  • 优势:复用现有Linux Web App的消费计划,无额外资源成本,操作灵活,支持Blob全生命周期管理(创建、删除、修改等)

2. 结合Azure Functions(消费计划)实现Blob操作

如果你的Web App以前端展示为主,可将Blob读写逻辑剥离到Azure Functions中:

  • Functions使用消费计划,每月有免费额度(100万次执行、400GB秒资源使用),完全满足原型需求
  • 给Functions配置Managed Identity,分配Blob Storage的读写权限,在Functions中实现上传、下载、删除等API接口
  • Web App通过HTTP请求调用Functions接口完成Blob操作
  • 优势:解耦业务逻辑,Functions自动扩缩容,无需管理服务器,运维成本极低

3. 改用Windows Web App(消费计划)

若你更倾向于通过文件系统方式操作Blob,Windows Web App的路径映射支持读写挂载:

  • 在Windows Web App的"配置"->"路径映射"中,添加Azure Blob Storage挂载并选择"读写"权限
  • 挂载后可直接通过文件系统API(如File.ReadAllText、File.WriteAllBytes)操作Blob,无需修改代码逻辑
  • 注意:仅Windows环境支持读写挂载,Linux环境目前仅支持只读

为什么不推荐Linux VM?

相比上述方案,Linux VM需要手动维护服务器(补丁、监控、扩容),且免费额度的VM仅750小时/月(单实例),超出后会产生费用,运维成本远高于Serverless方案,完全不符合原型开发的轻量需求。

内容的提问来源于stack exchange,提问作者oldtimehacker

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.06 20:02:24