Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting error "Failed to decrypt settings..." when trying to start Azure bot function

We have a bot endpoint implemented as an Azure function and it's running fine within Azure.

We've followed this process to enable us to run/debug the Azure Function locally: https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local

In particular, the following PowerShell command:

func azure functionapp fetch-app-settings <FunctionAppName>

It appears to run fine and put the necessary settings into local.settings.json, which is output to bin when the project is built. However, when we start the function (Right click project - Debug - Start new instance) it gives this error:

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

On two machines we are getting the above decryption error, on two machines it is running fine.

Any suggestions?

P.S. We are not trying to share the same local.settings.json file between machines, which I understand would also yield this sort of error.

UPDATE

Here is the content of the local.settings.json file from a problem machine, with encrypted values removed:

{
  "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": {}
}
like image 521
Michael12345 Avatar asked Feb 18 '18 21:02

Michael12345


2 Answers

Change the falue of IsEncrypted as follows :

"IsEncrypted": false, 

in local.settings.json

like image 64
Richard Barat Avatar answered Oct 21 '22 18:10

Richard Barat


I had exactly the same problems:

After doing :

func azure functionapp fetch-app-settings

I got only encrypted function settings in local.settings.file. Debugging with func stettings list and looking at func settings list --help revealed that i can do:

func settings decrypt

and worked!

EDIT: Just coming back some months later. Using the explicit "IsEncrypted": false in function.json works for me now as well, however it may be better to use func settings decrypt

like image 26
PlagTag Avatar answered Oct 21 '22 18:10

PlagTag