I have developed Azure Static Web Apps (Blazor Webassembly, Visual Studio 2022 Community) with integrated Google reCAPTCHA Enterprise service. Handling reCAPTCHA Enterprise is done in Azure Functions, which also sends an e-mail (using Sendgrid).
During development, I stored my Google credentials in the local.settings.json file.
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"SendGridApiKey": "<my Sendgrid key>",
"type": "service_account",
"project_id": "<my project_id>",
"private_key_id": "<my private_key_id>",
"private_key": "<my private_key>",
"client_email": "my client_email",
"client_id": "<my client_id>",
"auth_uri": "<auth_uri>",
"token_uri": "<token_uri>",
"auth_provider_x509_cert_url": "<auth_provider_x509_cert_url>",
"client_x509_cert_url": "<client_x509_cert_url>",
"universe_domain": "googleapis.com",
"site_key": "<site_key>"
},
"Host": { "CORS": "*" }
}
The private_key contains 1733 characters, starts with -----BEGIN PRIVATE KEY-----\n, ends with \n-----END PRIVATE KEY-----\n, and has a lot of escape characters and slashes, back-slashes as well \n, /\n, \, /.
During development, everything works fine! But unfortunately NOT in production.
If I store the private_key in the App configuration area, my Google Service will fail authentication. The only way I managed to get it working was to store private_key as a string in my code. All the rest is stored in the App configuration.
I'm sure that the problem arises because of the \n, but I have no idea how to handle that in the configuration value pairs.
Any idea how to manage this?