Azure / Azure-Functions

1.11k stars 196 forks source link

Visual Studio debugging "Failed to decrypt settings. Encrypted settings only be edited through 'func settings add'". #1454

Open grahambunce opened 4 years ago

grahambunce commented 4 years ago

Create an Azure Functions 2.x C# app and associated function Add local.settings.json, e.g.

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "WEBSITE_MAX_DYNAMIC_APPLICATION_SCALE_OUT": "1"
  },
  "AppSettings": {
    "local.logging.path": "c:\\temp\\diagnostics\\",
  },
  "ConnectionStrings": {
    "management.webhook": "http://localhost:35617",
    "management.circuitbreaker.timespanSeconds": 60
  }
}

Note that the connection string contains an unexpected value ("management.circuitbreaker.timespanSeconds")

Execute similar layout in WebJobs SDK = no issues Execute layout in Azure Functions = fail on startup with "Failed to decrypt settings. Encrypted settings only be edited through 'func settings add'."

Error is incorrect and misleading; nothing to do with encryption (as local.settings.json has "IsEncrypted": false) but is in fact due to a failure to parse the "management.circuitbreaker.timespanSeconds": 60 value.

Expected that the error does not refer to encryption but instead refers to "cannot parse settings file" and preferably with the value that is causing the problem,

joshspicer commented 3 years ago

Seeing this as well when trying to create launch this repo in a GitHub codespace.

Dialog in VsCode:

And the terminal output:

Function Runtime Version: 3.0.14916.0

Failed to decrypt settings. Encrypted settings only be edited through 'func settings add'.
The terminal process "/bin/bash '-c', 'func host start'" terminated with exit code: 1.
JochenVanSeveren commented 1 year ago

I managed to encrypt by running 'func encrypt' But before doing this, you need to make sure IsEncripted is set to false. (I set this to true manually)