【问题标题】:How do I get Azure Function App to get invoked如何让 Azure Function App 被调用
【发布时间】:2020-10-26 21:55:23
【问题描述】:

我有一个连接到 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,查看已发布的应用程序并刷新,它告诉我它正在运行,但函数应用程序仍然没有被调用。

请有人指导我什么是错的?

【问题讨论】:

  • 请向我们展示您的代码。
  • 我想看看你是否解决了这个问题?

标签: azure-functions blob azure-blob-storage azure-function-app azure-blob-trigger


【解决方案1】:

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

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

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

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

  3. 对于 host.json 中的log level,请确保其设置正确。

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

【讨论】:

    【解决方案2】:

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

    Blob 触发器的调用速度往往较慢,如果您使用 Consumption Plan,则调用速度会更慢。他们从文档中删除了这个,但据说可能会出现长达 10-15 分钟的延迟。我从来没有找到其他解释。无论如何,请read this

    但您可以考虑其他方式,如here 所述:

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

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

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

    【讨论】:

      猜你喜欢
      • 2021-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-06
      • 2020-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多