尝试启动 Azure 机器人功能时出现错误“无法解密设置...”

问题描述 投票:0回答:5

我们有一个机器人端点作为 Azure 功能实现,并且它在 Azure 中运行良好。

我们遵循此流程,使我们能够在本地运行/调试 Azure Function: https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local

特别是以下 PowerShell 命令:

func azure functionapp fetch-app-settings <FunctionAppName>

它看起来运行良好,并将必要的设置放入 local.settings.json 中,该设置在项目构建时输出到 bin 中。但是,当我们启动该函数时(右键单击项目 - 调试 - 启动新实例),它会出现以下错误:

Failed to decrypt settings. Encrypted settings only be edited through 'func settings add'.

在两台机器上我们收到上述解密错误,在两台机器上运行正常。

有什么建议吗?

附注我们并不想在机器之间共享相同的 local.settings.json 文件,我知道这也会产生此类错误。

更新

以下是问题机器上的 local.settings.json 文件的内容,已删除加密值:

{
  "IsEncrypted": true,
  "Values": {
    "AzureWebJobsStorage": "[encrypted content]",
    "AzureWebJobsDashboard": "[encrypted content]",
    "FUNCTIONS_EXTENSION_VERSION": "[encrypted content]",
    "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING": "[encrypted content]",
    "WEBSITE_CONTENTSHARE": "[encrypted content]",
    "WEBSITE_NODE_DEFAULT_VERSION": "[encrypted content]",
    "BotEnv": "[encrypted content]",
    "BotId": "[encrypted content]",
    "MicrosoftAppId": "[encrypted content]",
    "MicrosoftAppPassword": "[encrypted content]",
    "BotStateEndpoint": "[encrypted content]",
    "BotOpenIdMetadata": "[encrypted content]",
    "UseTableStorageForConversationState": "[encrypted content]",
    "BotDevAppInsightsKey": "[encrypted content]",
    "BotDevAppInsightsName": "[encrypted content]",
    "BotDevAppInsightsAppId": "[encrypted content]",
    "AzureWebJobsBotFrameworkDirectLineSecret": "[encrypted content]",
    "AzureWebJobsBotFrameworkDirectLineEndpoint": "[encrypted content]",
    "WEBSITE_USE_PLACEHOLDER": "[encrypted content]",
    "APPINSIGHTS_INSTRUMENTATIONKEY": "[encrypted content]",
    "MSDEPLOY_RENAME_LOCKED_FILES": "[encrypted content]"
  },
  "ConnectionStrings": {}
}
azure azure-functions
5个回答
50
投票

更改IsEncrypted的值如下:

"IsEncrypted": false, 

local.settings.json


7
投票

我遇到了完全相同的问题:

做完后:

func azure functionapp fetch-app-settings

我在

local.settings.file
中只得到了加密的功能设置。使用
func stettings list
进行调试并查看
func settings list --help
显示我可以做到:

功能设置解密

并且成功了!

编辑: 几个月后才回来。在 function.json 中使用显式

"IsEncrypted": false
现在也对我有用,但是使用
func settings decrypt

可能会更好

0
投票

运行不同的运行时版本 v1 和 v2 时遇到同样的问题。检查您是否正在运行相同的函数运行时版本。


0
投票

我设法通过运行“func encrypt”进行加密 但在执行此操作之前,您需要确保 IsEncripted 设置为 false。 (我手动将其设置为 true)


0
投票

有两种可能的情况:

  1. 如果您的项目有

    local.settings.json
    文件,则
    func azure functionapp fetch-app-settings <FunctionAppName>
    命令将遵循
    IsEncrypted
    文件中定义的
    local.settings.json
    属性。如果
    IsEncrypted
    属性设置为
    true
    ,则下载的应用程序设置将为
    Encrypted
    。否则,下载的设置将是
    Decrypted

    例如,假设您的项目中已存在以下

    local.settings.json
    。从 Azure 下载应用程序设置后,结果将是未加密的值。

    {
      "IsEncrypted": false,
      "Values": {
        "FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
        "AzureWebJobsStorage": "UseDevelopmentStorage=true"
      },
      "ConnectionStrings": {}
    }
    
  2. 如果您的项目在运行

    local.settings.json
    命令之前没有
    func azure functionapp fetch-app-settings <FunctionAppName>
    文件,那么您将下载 local.settings.json 文件的
    加密
    版本。您需要运行
    func settings decrypt
    命令来解密文件。

© www.soinside.com 2019 - 2024. All rights reserved.