带有 Eventhub 触发器的 Azure 函数失败并显示 "Encountered error while fetching the list of EventHub PartitionIds -> Unauthorized"
Azure Function with Eventhub Trigger fails with "Encountered error while fetching the list of EventHub PartitionIds -> Unauthorized"
有几个 Whosebug 帖子有类似的问题,但是 none 其中有授权错误问题。
我遇到了问题运行 Azure 中国 上带有 C# 代码的 Azure 函数和 eventhub 触发器。相同的代码在 Azure 全局上运行良好。
触发器的连接字符串是正确的,我尝试使用 Listen
和 Manage
权限,同样的问题。
感谢任何帮助。
这里是完整的错误信息:
Microsoft.Azure.WebJobs.Host.Listeners.FunctionListenerException: The listener for function 'FilterFunctionEventhubTrigger' was unable to start.
---> Microsoft.Azure.EventHubs.Processor.EventProcessorConfigurationException: Encountered error while fetching the list of EventHub PartitionIds
---> System.UnauthorizedAccessException: Unauthorized
at Microsoft.Azure.EventHubs.Amqp.Management.AmqpServiceClient.GetRuntimeInformationAsync()
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)
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
--- End of inner exception stack trace --
这是我的 csproj
文件。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<RootNamespace>sss_af_filter</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Messaging.EventHubs" Version="5.6.0" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.18.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="4.0.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="4.2.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.27" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
问题是 VNet 中缺少子网。
有几个 Whosebug 帖子有类似的问题,但是 none 其中有授权错误问题。
我遇到了问题运行 Azure 中国 上带有 C# 代码的 Azure 函数和 eventhub 触发器。相同的代码在 Azure 全局上运行良好。
触发器的连接字符串是正确的,我尝试使用 Listen
和 Manage
权限,同样的问题。
感谢任何帮助。
这里是完整的错误信息:
Microsoft.Azure.WebJobs.Host.Listeners.FunctionListenerException: The listener for function 'FilterFunctionEventhubTrigger' was unable to start.
---> Microsoft.Azure.EventHubs.Processor.EventProcessorConfigurationException: Encountered error while fetching the list of EventHub PartitionIds
---> System.UnauthorizedAccessException: Unauthorized
at Microsoft.Azure.EventHubs.Amqp.Management.AmqpServiceClient.GetRuntimeInformationAsync()
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)
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
--- End of inner exception stack trace --
这是我的 csproj
文件。
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<RootNamespace>sss_af_filter</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Messaging.EventHubs" Version="5.6.0" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.18.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="4.0.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="4.2.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Logging.ApplicationInsights" Version="3.0.27" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.Data.SqlClient" Version="4.8.2" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
问题是 VNet 中缺少子网。