1

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. (Parameter 'host') An unhandled host error has occurred. System.Net.Primitives: Value cannot be null. (Parameter 'host').

enter image description here

Function

[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>
5
  • Could you post your dependencies from the csproj? Commented Dec 2, 2021 at 8:12
  • @misha130 I added the whole .csproj. Commented Dec 2, 2021 at 8:21
  • This only happens locally, right? Commented Dec 2, 2021 at 8:57
  • Yes, I didn't try it on Azure yet. Commented Dec 2, 2021 at 9:01
  • @AjayKumarGhose-MT Hi Ajay, It was a DI problem as far as I remember. So it resolved. Sorry for late reply. Commented Jan 14, 2022 at 9:07

1 Answer 1

0

I tried to reproduce the same issue but it worked fine at my end. Followed by this MS DOC & demo GitHub project ,

  • Created a Signal IR in Azure portal .

Open the download folder from my VS Code-

And added the following packages into my local here is my .csproj file

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

enter image description here

enter image description here

Here are some screenshot for reference output: enter image description here

enter image description here

Note: If still facing the same issue you can try to Un install the Azure function V3 and install it again .

For more information please refer this SO THREAD .

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.