How to get authenticated for managing Azure Function keys?

Javid Gahramanov 11 Reputation points
2022-12-19T08:46:57.973+00:00

Hello!
I am trying to consume https://github.com/Azure/azure-functions-host/wiki/Key-management-API from deployed function.
I am getting 401 Unauthorized error when the triggered function itself tries to create a function key programmatically.
Found some examples of getting token from Kudu Endpoint with deployment creds. But in kudu page of the function there is no such APIs. functions/admin/token

Please give some detail which authentication options are available.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 30,326 Reputation points Microsoft Employee Moderator
    2022-12-21T22:49:59.76+00:00

    Hi @Javid Gahramanov ,

    The Key Management API is decorated with the admin key policy. So, you'll need to pass an equivalent host key to the endpoint in order to get around the 401 error you're getting. You can also utilize x-functions-key in the HTTP header instead appending the key to code= in the url. I was able to get a 200 by passing the _master host key in the HTTP header.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.