【发布时间】:2022-01-08 16:58:26
【问题描述】:
当我向函数发送 HTTP 请求时,它会在控制台输出上显示此错误,并返回 HTTP 500 状态代码,而不会到达函数第一行的断点。
执行“验证”(失败,Id=548b4612-42f8-4e49-886a-da6888045c32, 持续时间 = 343 毫秒)System.Net.Primitives:值不能为空。 (参数“主机”)发生了未处理的主机错误。 System.Net.Primitives:值不能为空。 (参数“主机”)。
功能
[FunctionName("Validate")]
public async Task Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] string req,
[SignalR(HubName = "PubSub")] IAsyncCollector<SignalRMessage> signalRMessageQueue)
{
...
}
host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingExcludedTypes": "Request",
"samplingSettings": {
"isEnabled": true
}
}
}
.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<RootNamespace>ZulaMobile.Lobby.StoreValidation</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
<PackageReference Include="Microsoft.Azure.WebJobs" Version="3.0.30" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.6.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="3.1.21" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\zulamobile-azure-lobby-common\zulamobile-azure-lobby-common.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="Functions\CafeBazaar\" />
<Folder Include="Huawei\" />
</ItemGroup>
</Project>
【问题讨论】:
-
您能从 csproj 发布您的依赖项吗?
-
@misha130 我添加了整个 .csproj。
-
这只发生在本地,对吧?
-
是的,我还没有在 Azure 上尝试过。
-
@AjayKumarGhose-MT 嗨,Ajay,据我所知,这是一个 DI 问题。于是解决了。抱歉回复晚了。
标签: c# azure .net-core azure-functions