AzureSignalR-samples icon indicating copy to clipboard operation
AzureSignalR-samples copied to clipboard

Local.Setting.Json issues - ConnectionString

Open BC89 opened this issue 3 years ago • 4 comments

There's definitely some real flakiness when binding values from the local setting file. When using Azure functions input bindings it appears that keyVault or other complex objects (i.e. serilog setting) screws things up wherein the keyvault magic isn't performed or the AzureSignalRConnectionString doesn't bind to the function params. If other complex objects are in the values section, AzureSignalRConnectionString doesn't bind. Very frustrating.

	```
	<PackageReference Include="Azure.Extensions.AspNetCore.Configuration.Secrets" Version="1.2.2" />
	<PackageReference Include="Azure.Identity" Version="1.7.0-beta.1" />
	<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.3.0" />
	<PackageReference Include="Azure.Storage.Blobs" Version="12.14.0-beta.1" />
	<PackageReference Include="Microsoft.Azure.NotificationHubs" Version="4.1.0" />

		<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.0-preview.7.22376.2" />
		<PackageReference Include="Microsoft.EntityFrameworkCore.Cosmos" Version="7.0.0-preview.7.22376.2" />
		<PackageReference Include="Microsoft.Extensions.Options.DataAnnotations" Version="7.0.0-preview.7.22375.6" />


		<PackageReference Include="Microsoft.IdentityModel.Protocols" Version="6.22.1" />
		<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.22.1" />

		<PackageReference Include="Serilog" Version="2.12.0-dev-01543" />
		<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.1-dev-10301" />
		<PackageReference Include="Serilog.Settings.Configuration" Version="3.3.1-dev-00337" />
		<PackageReference Include="Serilog.Sinks.AzureTableStorage" Version="6.0.0-dev-00146" />
		<PackageReference Include="Serilog.Sinks.Console" Version="4.0.2-dev-00890" />

{ "IsEncrypted": false, "Values": {

"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",

"Environment": "Development",

"AesIV": "https://star-development.vault.azure.net/secrets/AesIV/",
"AesKey": "https://star-development.vault.azure.net/secrets/AesKey/",
"AgolAppID": "https://star-development.vault.azure.net/secrets/AgolAppID/",
"AgolAppSecret": "https://star-development.vault.azure.net/secrets/AgolAppSecret/",
"AgolPwrd": "https://star-development.vault.azure.net/secrets/AgolPwrd/",
"AgolUrl": "https://star-development.vault.azure.net/secrets/AgolUrl/",
"AgolUser": "https://star-development.vault.azure.net/secrets/AgolUser/",
"AgolViewerUrl": "https://star-development.vault.azure.net/secrets/AgolViewerUrl/",
"AgolWebmapId": "https://star-development.vault.azure.net/secrets/AgolWebmapId/",
"AppVersion": "https://star-development.vault.azure.net/secrets/AppVersion/",
"AzureWebJobsDashboard": "https://star-development.vault.azure.net/secrets/AzureWebJobsDashboard/",
"AzureWebJobsStorage": "https://star-development.vault.azure.net/secrets/AzureWebJobsStorage/",
"CosmoCollectionName": "https://star-development.vault.azure.net/secrets/CosmoCollectionName/",
"CosmoCollectionUserSettings": "https://star-development.vault.azure.net/secrets/CosmoCollectionUserSettings/",
"CosmoDBName": "https://star-development.vault.azure.net/secrets/CosmoDBName/",
"CosmosDBAccountEndpoint": "https://star-development.vault.azure.net/secrets/CosmosDBAccountEndpoint/",
"CosmosDBAccountKey": "https://star-development.vault.azure.net/secrets/CosmosDBAccountKey/",
"CosmosDBAccountKeyRW": "https://star-development.vault.azure.net/secrets/CosmosDBAccountKeyRW/",
"NotifHubEpoint": "https://star-development.vault.azure.net/secrets/NotifHubEpoint/",
"NotifHubName": "https://star-development.vault.azure.net/secrets/NotifHubName/",
"PhotoConainter": "https://star-development.vault.azure.net/secrets/PhotoConainter/",
"PhotoConainterName": "https://star-development.vault.azure.net/secrets/PhotoConainterName/",
"PhotoThumbsConainterName": "https://star-development.vault.azure.net/secrets/PhotoThumbsConainterName/",
"SignalRTargetMethod": "https://star-development.vault.azure.net/secrets/SignalRTargetMethod/",
"TokenAudience": "https://star-development.vault.azure.net/secrets/TokenAudience/",
"TokenIssuer": "https://star-development.vault.azure.net/secrets/TokenIssuer/",

"CosmosDBCollectionV2": "https://star-development.vault.azure.net/secrets/CosmosDBCollectionV2/",
"CosmosDBNameV2": "https://star-development.vault.azure.net/secrets/CosmoDBNameV2/",

"AzureSignalRConnectionString": "Endpoint=https://starsignalr.service.signalr.net;AccessKey=RRHmDcZ8spdxkEuCPXZXIkaADHsenZjdS3+1xSYchZc=;Version=1.0;"

},

"Serilog": { "Using": [ "Serilog.Sinks.Console", "Serilog.Sinks.File", "Serilog.Sinks.AzureBlobStorage" ], "MinimumLevel": { "Default": "Information", "Override": { "Microsoft": "Warning", "System": "Warning" } }, "WriteTo": [ { "Name": "Console", "Args": { "writeInBatches": "true" } } ] }

}

BC89 avatar Sep 01 '22 18:09 BC89

This seems to be a functions host problem, could you open an issue here https://github.com/Azure/azure-functions-host/issues ?

Y-Sindo avatar Sep 02 '22 03:09 Y-Sindo

I can do that certainly but have some doubts. When I do get the string from keyvault and the magic conversion happens from url to actual encoded connection string, it never binds correctly. That doesn't seem like a host issue but a binding problem because the string is correct at that point.

Thx!

BC89 avatar Sep 02 '22 19:09 BC89

I can do that certainly but have some doubts. When I do get the string from keyvault and the magic conversion happens from url to actual encoded connection string, it never binds correctly. That doesn't seem like a host issue but a binding problem because the string is correct at that point.

Thx!

Do you mean using a key vault URL instead of the actual connection string in the AzureSignalRConnectionString? It's not supported.

Y-Sindo avatar Sep 03 '22 02:09 Y-Sindo

You might want to use identity-based connection instead:

  • https://devblogs.microsoft.com/azure-sdk/introducing-azure-identity-support-in-the-azure-functions-signalr-extension-beta/#:~:text=The%20Azure%20Functions%20SignalR%20extension%20enables%20serverless%20integration,version%201.7.0-beta.1%20for.NET%2C%20which%20introduces%20Azure%20Identity%20integration.

Y-Sindo avatar Sep 03 '22 03:09 Y-Sindo