我遇到了 Azure blob 触发函数导致函数主机崩溃的问题。这似乎是存储连接字符串或我如何使用 Azurite 的问题。我正在处理的其他计时器或 HTTP 触发函数在“UseDevelopmentStorage=true”设置和 Azurite blob 服务运行时工作正常。
对于使用 Azurite 存储模拟器在我的开发环境中工作的 blob 触发器函数可能存在什么问题,我感到很困惑。
任何关于我缺少什么或在哪里看的建议?
这是我在功能主机启动后大约 10 到 20 秒收到的错误消息:
发生了未处理的异常。主机正在关闭。Microsoft.WindowsAzure.Storage:无法建立连接,因为目标机器主动拒绝。System.Net.Http:无法建立连接,因为目标机器主动拒绝。System.Private.CoreLib:无法建立连接,因为目标机器主动拒绝了它。
blob 触发器函数的 function.json 文件如下所示:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "outcontainer/{name}",
"connection": "AzureWebJobsStorage"
}
]
}
local.settings.json 文件有这个:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "python"
}
}
这是启用了 --verbose 开关的控制台的输出:
[9/23/2020 6:28:36 PM] Job host started
Functions:
BlobTrigger1: blobTrigger
Hosting environment: Production
Content root path: C:\sources\AzureBlobTriggerTest
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[9/23/2020 6:28:37 PM] LanguageWorkerConsoleLog INFO: Starting Azure Functions Python Worker.
[9/23/2020 6:28:37 PM] LanguageWorkerConsoleLog INFO: Worker ID: d4160c17-a9f0-461d-af04-18623c45a51b, Request ID: fdf8841e-8564-4f4e-a983-91553451cd9d, Host Address: 127.0.0.1:51168
[9/23/2020 6:28:37 PM] LanguageWorkerConsoleLog INFO: Successfully opened gRPC channel to 127.0.0.1:51168
[9/23/2020 6:28:37 PM] LanguageWorkerConsoleLog INFO: Detaching console logging.
[9/23/2020 6:28:37 PM] Switched to gRPC logging.
[9/23/2020 6:28:37 PM] Received WorkerInitRequest, request ID fdf8841e-8564-4f4e-a983-91553451cd9d
[9/23/2020 6:28:37 PM] Worker process started and initialized.
[9/23/2020 6:28:37 PM] Received FunctionLoadRequest, request ID: fdf8841e-8564-4f4e-a983-91553451cd9d, function ID: dc522140-aa0a-453b-8767-4aedf88435e4
[9/23/2020 6:28:37 PM] Successfully processed FunctionLoadRequest, request ID: fdf8841e-8564-4f4e-a983-91553451cd9d, function ID: dc522140-aa0a-453b-8767-4aedf88435e4
[9/23/2020 6:28:41 PM] Host lock lease acquired by instance ID '0000000000000000000000002B956994'.
[9/23/2020 6:29:09 PM] An unhandled exception has occurred. Host is shutting down.
[9/23/2020 6:29:09 PM] Microsoft.WindowsAzure.Storage: No connection could be made because the target machine actively refused it. System.Net.Http: No connection could be made because the target machine actively refused it. System.Private.CoreLib: No connection could be made because the target machine actively refused it.
[9/23/2020 6:29:09 PM] Stopping host...
[9/23/2020 6:29:09 PM] Stopping JobHost
[9/23/2020 6:29:09 PM] Stopping the listener 'Microsoft.Azure.WebJobs.Host.Listeners.CompositeListener' for function 'BlobTrigger1'
[9/23/2020 6:29:09 PM] Stopped the listener 'Microsoft.Azure.WebJobs.Host.Listeners.CompositeListener' for function 'BlobTrigger1'
[9/23/2020 6:29:09 PM] Job host stopped
[9/23/2020 6:29:09 PM] Host shutdown completed.