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

Azure Durable Function:修改Azure存储模拟器端口的问题

修改Azure Durable Function对接自定义端口的存储模拟器

要让Durable Function访问你修改过端口的存储模拟器,核心是通过自定义存储连接字符串指定新端口,具体步骤如下:

1. 构造自定义端口的存储连接字符串

替换默认的UseDevelopmentStorage=true,改用明确指定端口的连接串格式,把Blob、Queue、Table的端口换成你设置的10003、10004、10005:

DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10003/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10004/devstoreaccount1;TableEndpoint=http://127.0.0.1:10005/devstoreaccount1;

注:账号devstoreaccount1和密钥是存储模拟器默认值,无需修改。

2. 更新Durable Function本地配置

打开项目根目录的local.settings.json,在Values节点下更新相关配置项:

  • 如果项目没有单独配置Durable Task存储,只需更新AzureWebJobsStorage
  • 如果配置了DurableTaskStorage,需要同时更新该字段

示例配置:

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10003/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10004/devstoreaccount1;TableEndpoint=http://127.0.0.1:10005/devstoreaccount1;",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "DurableTaskStorage": "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10003/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10004/devstoreaccount1;TableEndpoint=http://127.0.0.1:10005/devstoreaccount1;"
  }
}

3. 重启服务生效

  • 关闭当前运行的Function宿主(VS调试进程或func start命令窗口)
  • 重启Azure存储模拟器
  • 重新启动Durable Function项目,配置即可生效

补充说明

  • 不要使用UseDevelopmentStorage=true,该值会强制指向默认端口,无法识别你修改后的模拟器配置
  • 如果通过环境变量配置,直接将AzureWebJobsStorage(和DurableTaskStorage)设置为上述连接串即可,效果与local.settings.json一致

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.07 12:40:24