Here it is the code of the function which is pretty much straight forward:
[FunctionName("negotiate")]
public static SignalRConnectionInfo Run(
[HttpTrigger(AuthorizationLevel.Anonymous)]
HttpRequest req,
[SignalRConnectionInfo(
ConnectionStringSetting = "Endpoint=https://myowntestserver.service.signalr.net;AccessKey=mymaskedaccesskey=;Version=1.0;",
HubName = "tracking")]
SignalRConnectionInfo connectionInfo)
{
return connectionInfo;
}
When running this code on Visual Studio 2017, I get the following error message:
[2019-03-27 3:39:14 PM] Error indexing method 'negotiate'
[2019-03-27 3:39:14 PM] Microsoft.Azure.WebJobs.Host: Error indexing method 'negotiate'. Microsoft.Azure.WebJobs.Host: Unable to resolve the value for property 'SignalRConnectionInfoAttribute.ConnectionStringSetting'. Make sure the setting exists and has a valid value.
local.settings.json file looks like this:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
And here it is the host.json file:
{
"version": "2.0"
}
The project file contains the following nuget packages:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AzureFunctionsVersion>v2</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.ServiceBus" Version="3.0.3" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.SignalRService" Version="1.0.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.26" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
With all these configurations in place which seem right, not sure why we should get the error message that I quoted above.
The issue is resolved by updating local.settings.json file per the following example:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"AzureWebJobsDashboard": "UseDevelopmentStorage=true",
"AzureSignalRConnectionString": "Endpoint=Endpoint=https://myowntestserver.service.signalr.net;AccessKey=mymaskedaccesskey=;Version=1.0;""
},
"Host": {
"LocalHttpPort": 7071,
"CORS": "*"
}
}
Also, SignalRConnectionInfo.ConnectionStringSetting should be removed from the attribute.