Azure Function Apps: “Unable to retrieve the Master/Runtime keys” OR “The function runtime is unable to start”.



While working with Azure Functions users might encounter error in the Azure portal while clicking on a Function App. You might see one of these errors in the upper right hand corner of the portal:

“We are not able to retrieve the keys for function”

or

“We are not able to retrieve the master key for function”.

or

“The function runtime is unable to start. Please check the runtime logs for any errors or try again later.”

1   2

In this post, we will discuss symptoms of the error, the cause and how to resolve the issue.

Symptoms

Every function app has a default Admin/Master and function keys. This is visible under the “Manage” section of a Function app as shown below. When the portal starts to load, an API call is made to populate the keys. If these API calls fail then it would result in the following error on the portal:

“We cannot retrieve the runtime master key” or “We are unable to retrieve the keys for the function” or “The function runtime is unable to start. Please check the runtime logs for any errors or try again later.”

3

Also, in most of the cases you may also see nothing being populated under the Manage section. It might look like this.

4

Cause

The API calls can fail due to several reasons. Here are few of them:

  • Issues with the application code/Compilation errors/Runtime issues.
  • Function apps host.json/function.json contains incorrect settings.
  • AzureWebJobsDashboard” and “AzureWebJobsStorage” app setting in the portal is missing or is pointing to an invalid storage account.
  • Other functions under one function app might have issues and can affect other functions under the same function app. This can impact the function app host.
  • Function app using consumption plan has quota restrictions on usage of system resources of the underlying VM. Below is the list of limits which are imposed on the consumption plan.

               image


      Resolution

      Here are few ways on this issue can be addressed:

      1. If you suspect the application code, then

        • browse the KUDU site of your function app.
        • Under Process Explorer, right click and kill the W3WP.exe process.

      This will trigger a restart of the process and also this will result in a compilation of the code by the Functions runtime. Any error (code/compilation) would be visible under the Logs window (lower half ) of the Function app.

      2. The function running under Consumption plan is creating too many outbound connections. Under such scenarios, is advisable to ensure the connections are disposed of appropriately.

      If these connections are expected to take more time to respond, then it may hit the connections quota limit described above.

      NOTE: For such scenarios it is advisable to switch to Dedicated App Service Plan to run your function app. The function app will have to be re-created and re-deployed as switching of ASP from consumption plan to dedicated plan is currently not available.

      Ensure that the functions are not running any intensive task on a consumption plan. This may cause it hit other restrictions which are described above.

      3. If the settings inside Function.json or Host.json is misspelled or if there is any additional character, then this can cause the above-mentioned error. Please review the files and ensure that we have the right entries.

      4. Adding property “functions” in host.json to selectively enable few functions will cause the other functions to throw this error. Either add all the functions here or if there is a need of disabling few and enabling the rest then disable the functions from the UI is a preferred method.

      5

      5. Ensure that the app settings for “AzureWebJobsDashboard” and “AzureWebJobsStorage” are present and have been set to use the correct storage account. Check the credentials too.

      MORE INFORMATION

      If you try to add the function keys manually then you might see another error as shown below:

      clip_image002[4]

      If nothing works, then contact Azure App Services Support team.

      Comments (2)

      1. samant kumar says:

        Really helpful..

      2. Upto some extent this has helped, but there are still some issues which I have been facing. Haven’t got any solution to them…

      Skip to main content