gpt4 book ai didi

c# - Azure blob 触发器未触发?

转载 作者:行者123 更新时间:2023-12-02 08:25:42 24 4
gpt4 key购买 nike

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

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

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

这是我的 azure 函数 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

最佳答案

我认为这可能是由以下几个原因引起的:

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

如果不是这些问题,您使用的是哪个版本的 Functions?

关于c# - Azure blob 触发器未触发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64839740/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com