Azure IoT Edge Blob Storage离线启动失败问题咨询
问题
使用Azure IoT Edge Blob Storage时,IoT Edge服务器启动时可能处于无网络环境,但需要Blob Storage保持可访问。当前遇到的问题:无网络时Blob Storage模块无法启动,但若先联网启动再离线则可正常运行。
Blob Storage模块启动日志
Starting Azure Blob Storage on IoT Edge, version 1.4.1.0. Unhandled exception. System.AggregateException: One or more errors occurred. (One or more errors occurred. (Transient network error occurred, please retry.)) ---> System.AggregateException: One or more errors occurred. (Transient network error occurred, please retry.) ---> Microsoft.Azure.Devices.Client.Exceptions.IotHubCommunicationException: Transient network error occurred, please retry. ---> System.Net.Sockets.SocketException (104): Connection reset by peer at Microsoft.Azure.Devices.Client.Transport.Mqtt.MqttTransportHandler.OpenAsyncInternal(CancellationToken cancellationToken) at Microsoft.Azure.Devices.Client.Transport.Mqtt.MqttTransportHandler.OpenAsync(CancellationToken cancellationToken) at Microsoft.Azure.Devices.Client.Transport.ProtocolRoutingDelegatingHandler.OpenAsync(CancellationToken cancellationToken) at Microsoft.Azure.Devices.Client.Transport.ErrorDelegatingHandler.<>c__DisplayClass22_0.<<ExecuteWithErrorHandlingAsync>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.Azure.Devices.Client.Transport.ErrorDelegatingHandler.ExecuteWithErrorHandlingAsync[T](Func`1 asyncOperation) --- End of inner exception stack trace --- at Microsoft.Azure.Devices.Client.Transport.ErrorDelegatingHandler.ExecuteWithErrorHandlingAsync[T](Func`1 asyncOperation) at Microsoft.Azure.Devices.Client.Transport.RetryDelegatingHandler.<>c__DisplayClass32_0.<<OpenAsyncInternal>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.Azure.Devices.Client.Transport.RetryDelegatingHandler.EnsureOpenedAsync(CancellationToken cancellationToken) at Microsoft.Azure.Devices.Client.Transport.RetryDelegatingHandler.<>c__DisplayClass23_0.<<EnableTwinPatchAsync>b__0>d.MoveNext() --- End of stack trace from previous location where exception was thrown --- at Microsoft.Azure.Devices.Client.Transport.RetryDelegatingHandler.EnableTwinPatchAsync(CancellationToken cancellationToken) at Microsoft.Azure.Devices.Client.InternalClient.SetDesiredPropertyUpdateCallbackAsync(DesiredPropertyUpdateCallback callback, Object userContext, CancellationToken cancellationToken) at Microsoft.Azure.Devices.Client.InternalClient.SetDesiredPropertyUpdateCallbackAsync(DesiredPropertyUpdateCallback callback, Object userContext) at Microsoft.Azure.Devices.BlobStorage.IoT.ModuleTwinConfigurationProvider.Initialize() --- End of inner exception stack trace --- at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Microsoft.Azure.Devices.BlobStorage.IoT.ModuleTwinConfigurationProvider..ctor(ModuleClient iotModuleClient) at Microsoft.Azure.Devices.BlobStorage.IoT.ModuleTwinConfigurationSource.Build(IConfigurationBuilder builder) at Microsoft.Extensions.Configuration.ConfigurationBuilder.Build() at Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration() at Microsoft.Extensions.Hosting.HostBuilder.Build() at Microsoft.AzureStack.Services.Storage.FrontEnd.Program.BuildServices(String[] args) --- End of inner exception stack trace --- at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at System.Threading.Tasks.Task.Wait() at Microsoft.AzureStack.Services.Storage.FrontEnd.Program.Main(String[] args)
Edge Agent日志
Module 'azureblobstorageoniotedge' scheduled to restart after 05m:00s (02m:29s left). Empty edge agent config was received. Attempting to read config from backup(/tmp/edgeAgent/backup.json) instead
解决方案与说明
核心原因:Azure IoT Edge Blob Storage模块启动时默认需要连接IoT Hub获取模块孪生配置,无网络时无法完成孪生同步,导致启动失败。而先联网启动后离线时,模块已缓存孪生配置,因此能正常运行。
配置修改方案:
- 为Blob Storage模块添加本地配置覆盖,将必要配置参数直接写入模块环境变量,避免启动时依赖IoT Hub孪生同步。
- 关键配置包括
storageAccountName、storageAccountKey、blobStorageEndpoint等,可在部署清单的模块env字段中指定。示例片段:"azureblobstorageoniotedge": { "version": "1.4.1", "type": "docker", "status": "running", "restartPolicy": "always", "settings": { "image": "mcr.microsoft.com/azure-blob-storage/iotedge:1.4.1", "createOptions": {} }, "env": { "storageAccountName": { "value": "your-local-storage-account" }, "storageAccountKey": { "value": "your-local-storage-key" }, "blobStorageEndpoint": { "value": "http://azureblobstorageoniotedge:11002" } } }
Edge Agent配置优化:
- 确保Edge Agent的
backup.json包含完整模块配置,无网络时能正确加载备份启动模块。可在联网部署完成后,验证/tmp/edgeAgent/backup.json内容完整性。 - 调整Edge Agent重启策略,设置
restartPolicy为on-failure并调整重试间隔,避免因临时网络问题频繁重启模块。
- 确保Edge Agent的
场景支持说明:
- 离线启动Blob Storage模块的场景是支持的,但需通过本地配置覆盖孪生依赖,不能完全依赖IoT Hub同步配置。只要模块启动时能获取必要存储配置,即可在离线状态下正常提供服务。
内容的提问来源于stack exchange,提问作者Alovantous
相关产品推荐
相关产品推荐

