嗨,我正在使用以下代码在Arm模板中获取功能键和触发器网址作为输出。
> "outputs": {
> "Key": {
> "type": "string",
> "value": "[listsecrets(resourceId('Microsoft.Web/sites/functions',
> variables('funcName'),
> parameters('NameOfService')),'2015-08-01').key]"
> },
> "functionUrl": {
> "type": "string",
> "value": "[listsecrets(resourceId('Microsoft.Web/sites/functions',
> variables('funcName'),
> parameters('NameOfService')),'2015-08-01').trigger_url]"
> } }
我们在“应用程序设置”中将“ AzureWebJobsSecretStorageType”设置为“文件”,因为如果在Function v2中没有它,它就无法工作,当我们执行ARM模板时,它有时会起作用,但有时会抛出以下错误,而不是确定是什么问题,ARM模板有效,因为它可以正常工作,并且我可以看到该功能也已成功部署到Azure门户中,所以不确定为什么它会失败,有任何线索吗?
[错误] BadRequest:{“错误”:{ “ code”:“ BadRequest”, “ message”:“ System.FormatException:无法解密CfDJ8AAAAAAAAAAAAAAAAAAAAAAAAB93sc99M4b_klhBWrLMfQYRpSN9,密钥无效或格式错误---> System.Security.Cryptography.CryptographicException:有效负载为 无效。\ r \ n位于 Microsoft.AspNetCore.DataProtection.Cng.CbcAuthenticatedEncryptor.DecryptImpl(Byte * pbCiphertext,UInt32 cbCiphertext,字节* pbAdditionalAuthenticatedData,UInt32 cbAdditionalAuthenticatedData)\ r \ n位于 Microsoft.AspNetCore.DataProtection.Cng.Internal.CngAuthenticatedEncryptorBase.Decrypt(ArraySegment
1 ciphertext, ArraySegment
1 AdditionalAuthenticatedData)\ r \ n在 Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.UnprotectCore(Byte [] protectedData,布尔allowOperationsOnRevokedKeys,UnprotectStatus& 状态)\ r \ n位于 Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.DangerousUnprotect(Byte [] protectedData,布尔值ignoreRevocationErrors,布尔值& requireMigration,Boolean&was Revoked)\ r \ n位于 Microsoft.AspNetCore.DataProtection.KeyManagement.KeyRingBasedDataProtector.Unprotect(Byte [] protectedData)\ r \ n位于 Microsoft.AspNetCore.DataProtection.DataProtectionCommonExtensions.Unprotect(IDataProtector 保护器,字符串protectedData)\ r \ n在 Kudu.Core.Infrastructure.SecurityUtility.DecryptSecretString(String 内容)在C:\ Kudu中 Files \ Private \ src \ master \ Kudu.Core \ Infrastructure \ SecurityUtility.cs:line 40 \ r \ n ---内部异常堆栈跟踪的结尾--- \ r \ n在 Kudu.Core.Infrastructure.SecurityUtility.DecryptSecretString(String 内容)在C:\ Kudu中 Files \ Private \ src \ master \ Kudu.Core \ Infrastructure \ SecurityUtility.cs:line 45 \ r \ n Kudu.Core.Functions.FunctionManager.d__91.MoveNext() in C:\\Kudu Files\\Private\\src\\master\\Kudu.Core\\Functions\\FunctionManager.cs:line 203\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Kudu.Core.Functions.FunctionManager.<GetFunctionSecretsAsync>d__12.MoveNext() in C:\\Kudu Files\\Private\\src\\master\\Kudu.Core\\Functions\\FunctionManager.cs:line 220\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Kudu.Services.Functions.FunctionController.<GetSecrets>d__12.MoveNext() in C:\\Kudu Files\\Private\\src\\master\\Kudu.Services\\Functions\\FunctionController.cs:line 141\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3
1.MoveNext()\ r \ n --- 从先前引发异常的位置开始的堆栈跟踪结束 --- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)\ r \ n System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)\ r \ n System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext()\ r \ n --- 从先前引发异常的位置开始的堆栈跟踪结束 --- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)\ r \ n System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)\ r \ n System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()\ r \ n --- 从先前引发异常的位置开始的堆栈跟踪结束 --- \ r \ n在System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()\ r \ n --- 从先前引发异常的位置开始的堆栈跟踪结束 --- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)\ r \ n System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)\ r \ n System.Web.Http.Filters.ActionFilterAttribute.d__0.MoveNext()\ r \ n --- 从先前引发异常的位置开始的堆栈跟踪结束 --- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)\ r \ n System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)\ r \ n System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()\ r \ n --- 从先前引发异常的位置开始的堆栈跟踪结束 --- \ r \ n在System.Web.Http.Filters.ActionFilterAttribute.d__5.MoveNext()\ r \ n --- 从先前引发异常的位置开始的堆栈跟踪结束 --- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)\ r \ n System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)\ r \ n System.Web.Http.Filters.ActionFilterAttribute.d__0.MoveNext()\ r \ n --- 从先前引发异常的位置开始的堆栈跟踪结束 --- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)\ r \ n System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)\ r \ n System.Web.Http.Controllers.ActionFilterResult.d__2.MoveNext()\ r \ n --- 从先前引发异常的位置开始的堆栈跟踪结束 --- \ r \ n在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)\ r \ n System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)\ r \ n System.Web.Http.Controllers.ExceptionFilterResult.d__0.MoveNext()“ }
答案 0 :(得分:1)
我发现了造成此情况的原因,这仅是在Function的全新部署期间发生的,即当我删除Function应用程序然后尝试进行部署时,我遇到了此问题,原因是我只是删除Function App而不是存储帐户与此相关,因此旧的存储帐户保留了有关已删除的Function App的一些信息(我认为),并且事情变得一团糟,从我开始使用Function App删除存储帐户的那一刻起,问题就消失了。只是要补充说,存储帐户专用于此功能应用程序,并且未被其他任何人使用。
答案 1 :(得分:0)
根据您的错误消息,我认为功能键看起来像CfDJ8AAAAAAAAAAAAAAAAAAAAAB93sc99M4b_klhBWrLMfQYRpSN9
。但是,这种密钥格式没有任何意义。我已经遇到过几次相同的情况。钥匙看起来就像你的钥匙。
在这种情况下,密钥本身格式错误。有时会发生。因此,唯一的解决方案是更新密钥。然后它将看起来是普通的base-64编码的。