Azure Functions: Function Keys Change After Deploying from VSCode

t. sato 0 Reputation points
2024-10-03T08:03:17.42+00:00

Details:

  • I am using Visual Studio Code with the Azure Functions extension to develop and deploy my Azure Functions.
  • I deploy my functions using the "Deploy to Function App" command in VSCode.
  • Each time I deploy, the function keys (which are used for authentication) change, causing issues with clients that rely on those keys.

Question:

Why are the function keys changing each time I deploy from VSCode, and how can I prevent this from happening? Is there a way to deploy updates to my Azure Functions without overwriting or regenerating the existing function keys?

Any guidance or suggestions would be greatly appreciated.

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

2 answers

Sort by: Most helpful
  1. Pinaki Ghatak 5,600 Reputation points Microsoft Employee Volunteer Moderator
    2024-10-04T11:25:42.8933333+00:00

    Hello @t. sato

    It is expected behavior for function keys to change each time you deploy your Azure Functions from Visual Studio Code using the Deploy to Function App command.

    This is because the deployment process generates a new host key for the function app, which in turn invalidates any existing function keys. To prevent this from happening, you can manually manage your function keys in the Azure portal or by using the Azure Functions Core Tools.

    This way, you can update your function code without overwriting or regenerating the existing function keys. Here are the general steps to manually manage your function keys:

    1. In the Azure portal, navigate to your function app and select the Functions blade.
    2. Select the function for which you want to manage keys.
    3. Select the Manage link for the function, and then select the Function keys tab.
    4. From here, you can add, edit, or delete function keys as needed. Alternatively, you can use the Azure Functions Core Tools to manage your function keys. Here's an example command to add a new function key:

    func azure functionapp keys add --function-name --name --value You can find more information on managing function keys in the Azure Functions documentation.


    I hope that this response has addressed your query and helped you overcome your challenges. If so, please mark this response as Answered. This will not only acknowledge our efforts, but also assist other community members who may be looking for similar solutions.


  2. t. sato 0 Reputation points
    2024-10-05T15:25:24.78+00:00

    0 comments No comments

Your answer

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