简体   繁体   English

Azure 函数 System.Net.Primitives:值不能是 null。 (参数“主机”)

[英]Azure Functions System.Net.Primitives: Value cannot be null. (Parameter 'host')

When I send an HTTP request to the function, It shows this error on console output, and returns HTTP 500 status code without hitting the the break point of function's first line. When I send an HTTP request to the function, It shows this error on console output, and returns HTTP 500 status code without hitting the the break point of function's first line.

Executed 'Validate' (Failed, Id=548b4612-42f8-4e49-886a-da6888045c32, Duration=343ms) System.Net.Primitives: Value cannot be null.执行“验证”(失败,Id=548b4612-42f8-4e49-886a-da6888045c32,持续时间=343ms)System.Net.Primitives:值不能是 null。 (Parameter 'host') An unhandled host error has occurred. (参数“主机”)发生了未处理的主机错误。 System.Net.Primitives: Value cannot be null. System.Net.Primitives:值不能是 null。 (Parameter 'host'). (参数“主机”)。

在此处输入图像描述

Function Function

[FunctionName("Validate")]
public async Task Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] string req,
[SignalR(HubName = "PubSub")] IAsyncCollector<SignalRMessage> signalRMessageQueue)
{
    ...
}

host.json主机.json

{
"version": "2.0",
"logging": {
  "applicationInsights": {
    "samplingExcludedTypes": "Request",
    "samplingSettings": {
      "isEnabled": true
    }
  }
}

.csproj .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>

I tried to reproduce the same issue but it worked fine at my end.我试图重现同样的问题,但它在我的最后运行良好。 Followed by this MS DOC & demo GitHub project,随后是这个MS DOC和演示GitHub项目,

  • Created a Signal IR in Azure portal.在 Azure 门户中创建了一个 Signal IR。

Open the download folder from my VS Code-从我的 VS Code 打开下载文件夹-

And added the following packages into my local here is my .csproj file并将以下包添加到我的本地这是我的.csproj文件

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <AzureFunctionsVersion>v3</AzureFunctionsVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.6.0" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.11" />
  </ItemGroup>
  <ItemGroup>
    <None Update="content\index.html">
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </None>
    <None Update="host.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Update="local.settings.json">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <CopyToPublishDirectory>Never</CopyToPublishDirectory>
    </None>
  </ItemGroup>
</Project>

And make sure that you have added your connection string in your local settings.json which have to copy from portal from Azure signalIR > Keys>Connection string.并确保您已在local settings.json中添加了连接字符串。json 必须从Azure signalIR > Keys>Connection string.

在此处输入图像描述

在此处输入图像描述

Here are some screenshot for reference output:以下是一些截图供参考 output: 在此处输入图像描述

在此处输入图像描述

Note: If still facing the same issue you can try to Un install the Azure function V3 and install it again.注意:如果仍然遇到同样的问题,您可以尝试Azure function V3并重新安装。

For more information please refer this SO THREAD .有关更多信息,请参阅此SO THREAD

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 System.ArgumentNullException:值不能为 null。(参数“connectionString”)asp.net 核心 Docker-compose - System.ArgumentNullException: Value cannot be null. (Parameter 'connectionString') asp.net Core Docker-compose System.ArgumentNullException: &#39;值不能为空。 参数名称:提供者&#39; - System.ArgumentNullException: 'Value cannot be null. Parameter name: provider' AspNetCore.Authorization: System.ArgumentNullException: '值不能为 null。(参数 'configure')' - AspNetCore.Authorization: System.ArgumentNullException: 'Value cannot be null. (Parameter 'configure')' System.ArgumentNullException:“值不能是 null。 参数名称:实体” - System.ArgumentNullException: “Value cannot be null. Parameter name: entity” System.ArgumentNullException:&#39;值不能为null。 参数名称:键 - System.ArgumentNullException: 'Value cannot be null. Parameter name: key' System.ArgumentNullException:值不能为 null。(参数“connectionString”) - System.ArgumentNullException: Value cannot be null. (Parameter 'connectionString') Winform: System.ArgumentNullException: &#39;值不能为空。 (参数&#39;流&#39;)&#39; - Winform: System.ArgumentNullException: 'Value cannot be null. (Parameter 'stream')' System.ArgumentNullException: &#39;值不能为空。 参数名称:items&#39; - System.ArgumentNullException: 'Value cannot be null. Parameter name: items' System.ArgumentNullException: '值不能是 null。 参数名称:providerInvariantName' - System.ArgumentNullException: 'Value cannot be null. Parameter name: providerInvariantName' Azure 函数:值不能为空。 参数名称:来源 - Azure function: Value cannot be null. Parameter name: source
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM