automatically rotate azure openai api key

Rajnish Soni 60 Reputation points
2023-11-15T07:02:26.1266667+00:00

We have our openai instances deployed on azure. We want to rotate the openai api key using python or terraform. do we have such mechanism implemented. please guide.

Azure OpenAI Service
Azure OpenAI Service
An Azure service that provides access to OpenAI’s GPT-3 models with enterprise capabilities.
4,081 questions
{count} votes

Accepted answer
  1. Ramr-msft 17,826 Reputation points
    2023-11-17T12:35:07.75+00:00

    Rajnish Soni Thanks for the details, In Azure Open AI key and Endpoint section have regenerate the keys in the case of compromise or to comply with organization’s key rotation process. Two keys are provided to allow for continued access to the service while other key is being rotated.

    Here simple bit of code using the OpenAI Python SDK. In the code provide a prompt to the model and ask it to complete it for me and use one of the API keys to authenticate to it.

    https://journeyofthegeek.com/2023/04/02/authentication-in-azure-openai-service/

    But you can utilise AAD-based tokens as well, as AOAI is based on the Azure Cognitive-aligned platform. So, if you will generate a Bearer token in Azure AD and pass it over to the same Azure OpenAI endpoint, but using slightly different header's key "Authorization", then you would be able to retrieve the same data.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

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.