0

我定义了一个简单的 azure blob 存储触发器并将其部署到 azure。我希望它在名为“mycontainer”的 blob 存储容器中上传文件时记录。

在配置设置中,我在名为“AzureWebJobsStorage”的设置中添加了存储帐户的连接字符串的值。

要查看日志,我转到监控 > 日志 > 文件系统日志。之后,我将两个文件上传到我的 blob 存储帐户,希望显示名称和字节,但没有运气。我需要配置其他东西才能使其正常工作吗?还有其他地方我可以检查以确保该功能正在侦听存储容器吗?

这是我的天蓝色函数 blob 触发器。

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

namespace resume
{
    public static class MyApp
    {
        [FunctionName("MyApp")]
        public static void Run([BlobTrigger("mycontainer/{name}", Connection = "AzureWebJobsStorage")]Stream myBlob, string name, ILogger log)
        {
            log.LogInformation($"C# Blob trigger function Processed blob\n Name: {name} \n Size: {myBlob.Length} Bytes");
        }
    }
}

我还注意到我在实时指标中出现异常,并给出以下错误:

Microsoft.WindowsAzure.Storage.StorageException: No such host is known.
 ---> System.Net.Http.HttpRequestException: No such host is known.
 ---> System.Net.Sockets.SocketException (11001): No such host is known.
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   --- End of inner exception stack trace ---
   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
   at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.DiagnosticsHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
   at System.Net.Http.HttpClient.FinishSendAsyncUnbuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteAsyncInternal[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext, CancellationToken token)
   --- End of inner exception stack trace ---
   at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteAsyncInternal[T](RESTCommand`1 cmd, IRetryPolicy policy, OperationContext operationContext, CancellationToken token)
   at Microsoft.Azure.WebJobs.Host.Queues.Listeners.QueueListener.ExecuteAsync(CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.Storage\Queues\Listeners\QueueListener.cs:line 183
   at Microsoft.Azure.WebJobs.Host.Timers.TaskSeriesTimer.RunAsync(CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Timers\TaskSeriesTimer.cs:line 147

4

1 回答 1

1

我相信这可能是由几件事造成的:

  1. 仔细检查您的存储连接字符串并确保它有效(且完整)。
  2. 确保您指向的存储帐户不是“BlobStorage”类型(使用通用(V2)。我听说非通用存储帐户不适用于触发器。

如果不是这些问题中的任何一个,那么您使用的是什么版本的 Functions?

于 2020-11-14T23:43:39.710 回答