Azure Function App Container无法在Minikube启动容器错误:函数的侦听器';EventHubCSharpFunc';无法启动
我使用VisualStudio代码创建了一个非常简单的Azure functionApp,它只记录收到的消息(Function App在Azure中侦听Eventhub消息)。当我在本地调试函数应用程序时,它可以很好地运行和托管。但是,当我将其作为容器发布到minikube中时,它抛出以下错误:Azure Function App Container无法在Minikube启动容器错误:函数的侦听器';EventHubCSharpFunc';无法启动,azure,kubernetes,minikube,Azure,Kubernetes,Minikube,我使用VisualStudio代码创建了一个非常简单的Azure functionApp,它只记录收到的消息(Function App在Azure中侦听Eventhub消息)。当我在本地调试函数应用程序时,它可以很好地运行和托管。但是,当我将其作为容器发布到minikube中时,它抛出以下错误: The listener for function 'EventHubCSharpFunc' was unable to start. Microsoft.Azure.WebJobs.Host.List
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
我试图检查我的群集是否可以访问internet,但我成功地从minikube中的其他容器ping internet 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();
}
}
public静态类EventHubCSharpFunc
{
[函数名(“EventHubCSharpFunc”)]
公共静态异步任务运行([EventHubTrigger(“ContainerTestVthub”,Connection=“EventGridPerfEventHun\u RootManageSharedAccessKey\u EVENTHUB”)]EventData[]事件,ILogger日志)
{
var exceptions=新列表();
foreach(事件中的事件数据EventData)
{
尝试
{
string messageBody=Encoding.UTF8.GetString(eventData.Body.Array、eventData.Body.Offset、eventData.Body.Count);
//用处理逻辑替换这两行。
LogInformation($“C#事件中心触发器函数处理了一条消息:{messageBody}”);
等待任务;
}
捕获(例外e)
{
//我们需要继续处理批处理的其余部分-捕获此异常并继续。
/同时,考虑捕获处理失败的消息的细节,以便以后可以再次进行处理。
例外情况。添加(e);
}
}
//批处理完成后,如果批处理中的任何消息处理失败,将抛出异常,以便记录失败。
如果(exceptions.Count>1)
抛出新的AggregateException(异常);
if(exceptions.Count==1)
抛出异常;
}
}
查看“EventHubCSharpFunc无法启动”和“资源暂时不可用”,请尝试从应用程序盒连接到Eventhub
请验证你的连接和凭据是否在你的应用程序内工作。
您可以找到有关如何将凭据作为机密传递到POD中的更多信息,或者基于现有Docker凭据创建一个机密
出于故障排除目的,请使用以下命令从群集获取更多信息:
kubectl log <your_pod_with_application>
kubectl describe <your_pod_with_application>
kubectl get events
kubectl get all --all-namespaces
kubectl日志
库贝特尔描述
kubectl获取事件
kubectl获取所有--所有名称空间
查看“EventHubCSharpFunc无法启动”和“资源暂时不可用”,请尝试从应用程序盒连接到Eventhub
请验证你的连接和凭据是否在你的应用程序内工作。
您可以找到有关如何将凭据作为机密传递到POD中的更多信息,或者基于现有Docker凭据创建一个机密
出于故障排除目的,请使用以下命令从群集获取更多信息:
kubectl log <your_pod_with_application>
kubectl describe <your_pod_with_application>
kubectl get events
kubectl get all --all-namespaces
kubectl日志
库贝特尔描述
kubectl获取事件
kubectl获取所有--所有名称空间
I在dockerhub-Harkiratiit/azurefunceventhubI托管容器映像在dockerhub-Harkiratiit/azurefunceventhub托管容器映像