我已经写了一个Azure定时器函数应用程序,一切都运行得很好:编译和运行,但当我正在努力支持ApplicationInsights时,当我的应用程序启动时,我得到了以下错误。
A host error has occurred during startup operation '3cec5467-dfe8-4965-84a5-65f44b217bce'.
System.Security.Cryptography.CryptographicException: An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information.
---> System.InvalidOperationException: The key ring does not contain a valid default protection key. The data protection system cannot create a new key because auto-generation of keys is disabled.
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.CreateCacheableKeyRingCore(DateTimeOffset now, IKey keyJustAdded)
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.Microsoft.AspNetCore.DataProtection.KeyManagement.Internal.ICacheableKeyRingProvider.GetCacheableKeyRing(DateTimeOffset now)
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.GetCurrentKeyRingCore(DateTime utcNow, Boolean forceRefresh)
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingProvider.GetCurrentKeyRing()
at Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Protect(Byte[] plaintext)我不知道从哪里开始。我重新创建了一个计时器函数应用程序,并将我的代码重新添加到其中,但仍然得到相同的错误。欢迎提出任何建议。
发布于 2021-03-03 22:48:29
我找到了错误的原因。这非常奇怪,没有任何意义。
这是我的local.settings.json文件。如果我将拼写"CONTAINER_NAME“或"CONTAINERNAME”作为键,则会导致错误。如果我只是将它重命名为其他名称,我不会出错。这没有任何意义。我通过重构我的function应用程序发现了这一点。"CONTAINER_NAME“和"LOG_FILENAME”是我添加到设置文件的最后两个项目,因为我正在写入Azure Blob存储。
{
"IsEncrypted": false,
"Values": {
"SQLCONNSTR_DefaultConnection": "",
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "dotnet",
"FUNCTIONS_EXTENSION_VERSION": "~3",
"WEBSITE_RUN_FROM_PACKAGE": 1,
"CALICO_SFTP_URL": "",
"PORT": 22,
"USER_NAME": "",
"PASSWORD": "",
"SOURCE_DIRECTORY": "",
"ERROR_DIRECTORY": "",
"ARCHIVE_DIRECTORY": "",
"SOURCE_FILE": "",
"KEY_VAULT_URL": "",
"PRIVATE_KEY": "",
"PARAPHRASE": "",
"CONTAINER_NAME": "",
"LOG_FILENAME": ""
}
}感谢每一个愿意提供帮助的人和你的建议。希望有人能理解这种行为。
https://stackoverflow.com/questions/66448264
复制相似问题