0

我有一个连接到 blob 容器的简单 blob 侦听器。侦听器(在 Azure 上)显示它正在运行,但未调用该函数。

这是来自控制台的日志。

Azure Functions Core Tools (3.0.2630 Commit hash: ......)
Function Runtime Version: 3.0.13901.0
[7/6/2020 5:24:04 PM] Building host: startup suppressed: 'False', configuration suppressed: 
'False', startup operation id: '.........'
[7/6/2020 5:24:04 PM] Reading host configuration file '.....\host.json'
[7/6/2020 5:24:04 PM] Host configuration file read:
[7/6/2020 5:24:04 PM] {
[7/6/2020 5:24:04 PM]   "version": "2.0",
[7/6/2020 5:24:04 PM]   "logging": {
[7/6/2020 5:24:04 PM]     "applicationInsights": {
[7/6/2020 5:24:04 PM]       "samplingExcludedTypes": "Request",
[7/6/2020 5:24:04 PM]       "samplingSettings": {
[7/6/2020 5:24:04 PM]         "isEnabled": true
[7/6/2020 5:24:04 PM]       }
[7/6/2020 5:24:04 PM]     }
[7/6/2020 5:24:04 PM]   }
[7/6/2020 5:24:04 PM] }
[7/6/2020 5:24:04 PM] Loading functions metadata
[7/6/2020 5:24:04 PM] Reading functions metadata
[7/6/2020 5:24:04 PM] 1 functions found
[7/6/2020 5:24:04 PM] 1 functions loaded
[7/6/2020 5:24:04 PM] Loading extensions from .....\netcoreapp3.1\bin. BundleConfigured: False, 
PrecompiledFunctionApp: False, LegacyBundle: False
[7/6/2020 5:24:04 PM] Loading startup extension 'AzureStorage'
[7/6/2020 5:24:04 PM] Loaded extension 'AzureStorage' (3.0.10.0)
[7/6/2020 5:24:05 PM] Initializing Warmup Extension.
[7/6/2020 5:24:05 PM] Initializing Host. OperationId: '......'.
[7/6/2020 5:24:05 PM] Host initialization: ConsecutiveErrors=0, StartupCount=1, 
OperationId=..........
[7/6/2020 5:24:05 PM] LoggerFilterOptions
[7/6/2020 5:24:05 PM] {
[7/6/2020 5:24:05 PM]   "MinLevel": "None",
[7/6/2020 5:24:05 PM]   "Rules": [
[7/6/2020 5:24:05 PM]     {
[7/6/2020 5:24:05 PM]       "ProviderName": null,
[7/6/2020 5:24:05 PM]       "CategoryName": null,
[7/6/2020 5:24:05 PM]       "LogLevel": null,
[7/6/2020 5:24:05 PM]       "Filter": "<AddFilter>b__0"
[7/6/2020 5:24:05 PM]     },
[7/6/2020 5:24:05 PM]     {
[7/6/2020 5:24:05 PM]       "ProviderName": 
"Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[7/6/2020 5:24:05 PM]       "CategoryName": null,
[7/6/2020 5:24:05 PM]       "LogLevel": "None",
[7/6/2020 5:24:05 PM]       "Filter": null
[7/6/2020 5:24:05 PM]     },
[7/6/2020 5:24:05 PM]     {
[7/6/2020 5:24:05 PM]       "ProviderName": 
"Microsoft.Azure.WebJobs.Script.WebHost.Diagnostics.SystemLoggerProvider",
[7/6/2020 5:24:05 PM]       "CategoryName": null,
[7/6/2020 5:24:05 PM]       "LogLevel": null,
[7/6/2020 5:24:05 PM]       "Filter": "<AddFilter>b__0"
[7/6/2020 5:24:05 PM]     }
[7/6/2020 5:24:05 PM]   ]
[7/6/2020 5:24:05 PM] }
[7/6/2020 5:24:05 PM] FunctionResultAggregatorOptions
[7/6/2020 5:24:05 PM] {
[7/6/2020 5:24:05 PM]   "BatchSize": 1000,
[7/6/2020 5:24:05 PM]   "FlushTimeout": "00:00:30",
[7/6/2020 5:24:05 PM]   "IsEnabled": true
[7/6/2020 5:24:05 PM] }
[7/6/2020 5:24:05 PM] SingletonOptions
[7/6/2020 5:24:05 PM] {
[7/6/2020 5:24:05 PM]   "LockPeriod": "00:00:15",
[7/6/2020 5:24:05 PM]   "ListenerLockPeriod": "00:00:15",
[7/6/2020 5:24:05 PM]   "LockAcquisitionTimeout": "10675199.02:48:05.4775807",
[7/6/2020 5:24:05 PM]   "LockAcquisitionPollingInterval": "00:00:05",
[7/6/2020 5:24:05 PM]   "ListenerLockRecoveryPollingInterval": "00:01:00"
[7/6/2020 5:24:05 PM] }
[7/6/2020 5:24:05 PM] QueuesOptions
[7/6/2020 5:24:05 PM] {
[7/6/2020 5:24:05 PM]   "BatchSize": 16,
[7/6/2020 5:24:05 PM]   "NewBatchThreshold": 8,
[7/6/2020 5:24:05 PM]   "MaxPollingInterval": "00:00:02",
[7/6/2020 5:24:05 PM]   "MaxDequeueCount": 5,
[7/6/2020 5:24:05 PM]   "VisibilityTimeout": "00:00:00"
[7/6/2020 5:24:05 PM] }
[7/6/2020 5:24:05 PM] BlobsOptions
[7/6/2020 5:24:05 PM] {
[7/6/2020 5:24:05 PM]   "CentralizedPoisonQueue": false
[7/6/2020 5:24:05 PM] }
[7/6/2020 5:24:05 PM] HttpOptions
[7/6/2020 5:24:05 PM] {
[7/6/2020 5:24:05 PM]   "DynamicThrottlesEnabled": false,
[7/6/2020 5:24:05 PM]   "MaxConcurrentRequests": -1,
[7/6/2020 5:24:05 PM]   "MaxOutstandingRequests": -1,
[7/6/2020 5:24:05 PM]   "RoutePrefix": "api"
[7/6/2020 5:24:05 PM] }
[7/6/2020 5:24:05 PM] Starting JobHost
[7/6/2020 5:24:05 PM] Starting Host (HostId=........., InstanceId=........., Version=3.0.13901.0, 
ProcessId=14720, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, 
FunctionsExtensionVersion=(null))
[7/6/2020 5:24:05 PM] Loading functions metadata
[7/6/2020 5:24:05 PM] 1 functions loaded
[7/6/2020 5:24:06 PM] Generating 1 job function(s)
[7/6/2020 5:24:06 PM] Found the following functions:
[7/6/2020 5:24:06 PM] BlobStorageListener.BlobListener.Run
[7/6/2020 5:24:06 PM]
[7/6/2020 5:24:06 PM] Initializing function HTTP routes
[7/6/2020 5:24:06 PM] No HTTP routes mapped
[7/6/2020 5:24:06 PM]
[7/6/2020 5:24:06 PM] Host initialized (602ms)
[7/6/2020 5:24:06 PM] Host started (890ms)
[7/6/2020 5:24:06 PM] Job host started
Hosting environment: Production
 Content root path: ........\bin\Debug\netcoreapp3.1
 Now listening on: http://0.0.0.0:7071
 Application started. Press Ctrl+C to shut down.
 [7/6/2020 5:24:11 PM] Host lock lease acquired by instance ID '..........'.

即使我登录到 azure,查看已发布的应用程序并刷新,它告诉我它正在运行,但函数应用程序仍然没有被调用。

请问有人可以指导我有什么问题吗?

4

2 回答 2

0

首先,您最好提供一个示例代码给我们。

假设您使用的是blob trigger azure function,请检查以下可能的原因:

  1. 从输出来看,函数本身似乎没有错误。您应该检查是否有其他函数也在使用相同的 blob 路径。一种快速检查方法是,在这个 azure 函数中,将 blob 路径更改为另一个路径。然后再次运行 azure 函数。

  2. 确保将文件上传到此 azure 函数使用的 blob 路径。

  3. 对于host.json 中的日志级别,请确保其设置正确。

如果您在尝试上述步骤后仍有问题,请告诉我。

于 2020-07-07T05:55:58.927 回答
0

首先尝试调用Http 触发函数作为测试。如果通过这种方式它确实调用了,但Blob Trigger没有调用,那么您的问题可能与Cold Start相关。

如果您使用的是消费计划,Blob 触发器的调用速度往往会更慢,甚至更慢。他们从文档中删除了这个,但据说可能会出现长达 10-15 分钟的延迟。我从来没有找到其他解释。无论如何,请阅读本文

但是您可以考虑其他方法,如此所述:

另一种处理 blob 的方法是编写与正在创建或修改的 blob 对应的队列消息,然后使用队列存储触发器开始处理。

一个更大的解决方法仍然有效,如果您在上传文件时向队列发送一条消息,其中包含到达存储的 blob 的名称,然后使用时间触发器函数定期从队列中检查这些 blob 名称,从存储中下载并处理它们。

不是最好的方法,而是一种方法。

于 2020-07-17T20:04:38.217 回答