azure - Azure Function App Container Failing to Start at Minikube Container 错误:函数“EventHubCSharpFunc”的侦听器无法启动
问题描述
我使用 Visual Studio Code 创建了一个非常简单的 Azure functionApp,它什么都不做,只是记录接收到的消息(Function App 在 Azure 中侦听 Eventhub 消息)。当我在本地调试函数应用程序时,这很有效并且可以很好地托管。但是,当我将它作为容器发布到 minikube 中时,它会引发以下错误:
The listener for function 'EventHubCSharpFunc' was unable to start.
Microsoft.Azure.WebJobs.Host.Listeners.FunctionListenerException: The listener for function 'EventHubCSharpFunc' was unable to start. ---> Microsoft.Azure.EventHubs.Processor.EventProcessorConfigurationException: Encountered error while fetching the list of EventHub PartitionIds ---> System.Net.Sockets.SocketException: Resource temporarily unavailable
at Microsoft.Azure.EventHubs.Amqp.AmqpEventHubClient.CreateConnectionAsync(TimeSpan timeout)
at Microsoft.Azure.Amqp.FaultTolerantAmqpObject`1.OnCreateAsync(TimeSpan timeout)
at Microsoft.Azure.Amqp.Singleton`1.CreateValue(TaskCompletionSource`1 tcs, TimeSpan timeout)
at Microsoft.Azure.Amqp.Singleton`1.GetOrCreateAsync(TimeSpan timeout)
at Microsoft.Azure.EventHubs.Amqp.Management.AmqpServiceClient.OpenRequestResponseLinkAsync(String type, String address, Nullable`1 entityType, String[] requiredClaims, TimeSpan timeout)
at Microsoft.Azure.EventHubs.Amqp.Management.AmqpServiceClient.OpenLinkAsync(TimeSpan timeout)
at Microsoft.Azure.Amqp.FaultTolerantAmqpObject`1.OnCreateAsync(TimeSpan timeout)
at Microsoft.Azure.Amqp.Singleton`1.CreateValue(TaskCompletionSource`1 tcs, TimeSpan timeout)
at Microsoft.Azure.Amqp.Singleton`1.GetOrCreateAsync(TimeSpan timeout)
at Microsoft.Azure.EventHubs.Amqp.Management.AmqpServiceClient.GetRuntimeInformationAsync()
at Microsoft.Azure.EventHubs.Amqp.AmqpEventHubClient.OnGetRuntimeInformationAsync()
at Microsoft.Azure.EventHubs.EventHubClient.GetRuntimeInformationAsync()
at Microsoft.Azure.EventHubs.Processor.PartitionManager.GetPartitionIdsAsync()
--- End of inner exception stack trace ---
at Microsoft.Azure.EventHubs.Processor.PartitionManager.GetPartitionIdsAsync()
at Microsoft.Azure.EventHubs.Processor.PartitionManager.GetPartitionIdsAsync()
at Microsoft.Azure.EventHubs.Processor.PartitionManager.InitializeStoresAsync()
at Microsoft.Azure.EventHubs.Processor.PartitionManager.StartAsync()
at Microsoft.Azure.EventHubs.Processor.EventProcessorHost.RegisterEventProcessorFactoryAsync(IEventProcessorFactory factory, EventProcessorOptions processorOptions)
at Microsoft.Azure.WebJobs.EventHubs.EventHubListener.StartAsync(CancellationToken cancellationToken) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Extensions.EventHubs\Listeners\EventHubListener.cs:line 46
at Microsoft.Azure.WebJobs.Host.Listeners.FunctionListener.StartAsync(CancellationToken cancellationToken, Boolean allowRetry) in C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Listeners\FunctionListener.cs:line 68
我试图检查我的集群是否可以访问互联网,但我能够成功地从 minikube 中的其他容器 ping 互联网 IP。
public static class EventHubCSharpFunc
{
[FunctionName("EventHubCSharpFunc")]
public static async Task Run([EventHubTrigger("containertestevthub", Connection = "EventGridPerfEventHun_RootManageSharedAccessKey_EVENTHUB")] EventData[] events, ILogger log)
{
var exceptions = new List<Exception>();
foreach (EventData eventData in events)
{
try
{
string messageBody = Encoding.UTF8.GetString(eventData.Body.Array, eventData.Body.Offset, eventData.Body.Count);
// Replace these two lines with your processing logic.
log.LogInformation($"C# Event Hub trigger function processed a message: {messageBody}");
await Task.Yield();
}
catch (Exception e)
{
// We need to keep processing the rest of the batch - capture this exception and continue.
// Also, consider capturing details of the message that failed processing so it can be processed again later.
exceptions.Add(e);
}
}
// Once processing of the batch is complete, if any messages in the batch failed processing throw an exception so that there is a record of the failure.
if (exceptions.Count > 1)
throw new AggregateException(exceptions);
if (exceptions.Count == 1)
throw exceptions.Single();
}
}
解决方案
查看“ EventHubCSharpFunc 无法启动”和“资源暂时不可用”,请尝试从您的 APP POD连接到EventHub。
请验证您的连接和凭据是否在您的 APP POD中正常工作。您可以在此处和此处找到有关如何将凭据作为机密传递到您的 POD 或基于现有 Docker 凭据创建机密的 更多信息。
出于故障排除目的,请使用以下命令从集群中获取更多信息:
kubectl log <your_pod_with_application>
kubectl describe <your_pod_with_application>
kubectl get events
kubectl get all --all-namespaces
推荐阅读
- python - 在 macOS 上导入 matplotlib 时出现运行时错误
- office-js - 使用集中部署发布时,包含自定义功能的加载项仍出现在 Office 2016/2019 中
- python - forloop 中的子图不会出现在 Python 中
- django - 使用 django-select2 在下拉菜单中显示不同的值
- bash - 'sh' 环境不尊重 PATH 扩展,用户的本地 PATH 无效?
- node.js - 我不明白为什么错误显示“找不到模块”?
- c# - 如何打开多个excel文件并在DataGridView中打开它们
- python - 在熊猫中删除文本并保留数字
- ms-access - Microsoft Jet BIT 字段
- java - 有时它会创建一个错误,因为没有构造函数,有时它可以