Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

WE ARE UNABLE TO RETRIEVE THE MASTER / RUNTIME KEYS FOR AZURE FUNCTION APP


Many a time it happens that we open the Azure Portal and click on an Azure Function App and it started to throw an error on TOP RIGHT corner as “We are not able to retrieve the keys for function” or “We are not able to retrieve the master key for function”.

Now the questions come in mind is “What is this issue?” and then “Why the app suddenly started to show this error?” and then maybe few more like “is this affecting my app?” or “What should I do now?” or “how to get rid of this ?

Let’s discuss all these questions.

1. What does this error mean?

Every Function app has default Admin/Master and function keys which we can see from the “Manage” Tab under the Function app as shown below.

Now when we load the portal website it loads (make an API call) these keys as well to populate them on Manage Tab. These keys normally used internally by the function app. Due to any reason if this API call fails to get the keys from backend it starts to throw the error “We cannot retrieve the runtime master key” or “We are unable to retrieve the keys for the function”.

2. Why this error or what is causing this failure?

When api calls are not able to reach out to the Function App host or function app host is running into issues while performing runtime/ background operations then that is where we get this error. Now, this can have quite a few number of reasons.

  • There is an issue with the code which is written in the Function app function. Maybe some compilation issues.
  • Function apps host.json/function.json is having some incorrect set of settings or the settings not placed properly.
  • Maybe the particular Function you are looking at is fine but the other functions under the Function app are having issues. This may bring down the Function App host resulting in this error.
  • Function app running on consumption plan has some strict limits on the resources which function app can use on the underlying VM. This includes the no of outgoing connections (opened connections at any given point in time), no of processes each function can have, the no of threads we can spawn up at a time etc. Below is the list of limits which are imposed on the consumption plan.

               

  • When a Function app function crosses any of these limits we can expect this issue at that time.
  • In most of the cases when this issue occurs you can expect to see the Manage Tab of the function as shown below.

           

3. What to do to fix this issue?

Reasons for the issue itself explains what we need to check and fix if this issue happens.

  • If you suspect the issue might be in the code then go to KUDU site of your function app and go to Process Explorer and then kill the W3WP.exe process. Once you do this the function’s runtime will create a new process and will try to pick up the function code once again. This will trigger the code compilation once again and you can see the errors in the Logs window in the lower half of the Function app function window.
  • If you are making too many connections from the Function app code, then it is always advisable to handle the disposal of these connections appropriately in the code. If these connections are expected to take more time to respond, then you may have to opt the App Service Plan to run your function app. The reason here is too many connections opened for too long may result in Function app hitting the limit “Connections“. So, either review your code to check why these connections are open for long or chose App Service Plan to host your function app.
  • Likewise, for the other limits shown in the table above we need to make sure we are not running high intensive tasks on Azure Functions on Consumption plan.
  • If you have misspelled the settings in Function.json or the Host.json or if there is an unwanted character, then you need to clean that up.
  • You might have added the property “Functions” in the host json. With this property, we can mention the functions we need to enable. If we have few functions added to this settings then other functions might throw this error as they will not be loaded because of this setting.
  • Check if the app settings “AzureWebJobsDashboard” and “AzureWebJobsStorage” are present and have been set to right storage account with the right set of connection details.
  • If you try to add the keys by yourself here without fixing the actual issue you might see another issue as shown below.

               


    If nothing works, contact Azure App Services Support team.

    Share the post

    WE ARE UNABLE TO RETRIEVE THE MASTER / RUNTIME KEYS FOR AZURE FUNCTION APP

    ×

    Subscribe to Msdn Blogs | Get The Latest Information, Insights, Announcements, And News From Microsoft Experts And Developers In The Msdn Blogs.

    Get updates delivered right to your inbox!

    Thank you for your subscription

    ×