Azure Storage Blob触发器未唤醒睡眠功能

问题描述 投票:1回答:1

此问题类似于Azure Blob Storage trigger Function not firing

但是,他们的问题是他们的Azure功能不能立即唤醒,给人的印象是,它实际上并没有处理来自Azure Blob存储的触发器,而实际上是在10分钟之后,这完全符合MS docs的说法。

https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-trigger?tabs=csharp

我的问题不同。我的Blob现在已经在容器中坐了9个小时,但仍未得到处理。

它所做的只是将消息发布到ServiceBus。

[FunctionName("IncomingFileDetected")]
[return: ServiceBus("incoming-file-received", EntityType = Microsoft.Azure.WebJobs.ServiceBus.EntityType.Topic)]
public static IncomingFile Run(
    [BlobTrigger("incoming-files/{filename}", Connection = "ConnectionStrings:MutableStorage")]
    Stream contents,
    string filename,
    ILogger log)
{
    log.LogInformation($"Detected new blob file: {filename}");
    return new IncomingFile(filename);
}

没有消息出现在服务总线中。

现在,在9个小时之后,我重新启动了功能应用程序,并且在大约10分钟内处理了Blob。

azure triggers azure-functions azure-storage-blobs
1个回答
1
投票

更新:

感谢Peter Morris的分享,问题出在服务计划是d1。因此,首先请确保您基于三种计划:消费计划,高级计划和应用程序服务计划。当使用天蓝色函数时,即使仅进行测试,也应使用消耗计划。生产中最小的是S1,通常用于测试。

原始答案:

下面的代码对我来说很好用。甚至消费计划都没问题。

using System;
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

namespace FunctionApp35
{
    public static class Function1
    {
        [FunctionName("Function1")]
        [return: ServiceBus("test", Connection = "ServiceBusConnection")]
        public static string Run([BlobTrigger("samples-workitems/{name}", Connection = "str")]Stream myBlob, string name, ILogger log)
        {
            log.LogInformation($"C# Blob trigger function Processed blob\n Name:{name} \n Size: {myBlob.Length} Bytes");
            string a = "111111111111111";
            return a;
        }
    }
}

这是我的本地设置:

{
    "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "DefaultEndpointsProtocol=https;AccountName=0730bowmanwindow;AccountKey=lti/ThmF+mw9BebOacp9gVazIh76Q39ecikHSCkaTcGK5hmInspX+EkjzpNmvCPWsnvapWziHQHL+kKt2V+lZw==;EndpointSuffix=core.windows.net",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "str": "DefaultEndpointsProtocol=xxxxxx",
    "ServiceBusConnection": "Endpoint=sb://bowmantestxxxxxx"
  }
}

str来自这个地方:

enter image description here

ServiceBusConnection来自此位置:

enter image description here

enter image description here

并且请注意,触发天蓝色函数后,将不会从容器中删除斑点。另外,请不要忘记在服务总线主题中创建至少一个订阅。

enter image description here

将功能部署到天蓝色后,上述所有方法也都可以正常工作。(与本地的区别在于,您需要在配置设置中添加设置,而不是在local.settings.json中添加设置)

enter image description here

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.