While running through the (very worthwhile) Azure Functions Challenge, I encountered an error that was new to me, and a quick method of working around/fixing it.
After deploying Challenge 4, I received the following error when trying to open the Function:
“We are not able to retrieve the keys for function … This can happen if the runtime is not able to load your function. Check other function errors.”
It seems this is because I used the same app name multiple times. Encrypted values are stored in your app’s storage which are tied to the app name, and while new keys are generated within the app context when you re-create it, the encrypted values are just carried over in the underlying folder structure.
Deleting the existing files will cause them to be regenerated with values from the new encryption keys, so go ahead and open up Kudu by navigating to:
Change directory to D:\home\data\Functions\secrets, and delete everything in that folder. In my instance, one file, host.json.
Refresh the portal and look in the folder again, and you should find newly regenerated files therein. Your Function should load and work properly as well. Hurrah!