You are developing a secure C# web API that retrieves a database credential secret from Azure Key Vault. You need to automate the rotation of this secret using Azure Event Grid and a custom Azure Function. Which sequence of steps should you perform to configure the automated rotation?
- 1Deploy the Azure Function containing the rotation logic to a Function App.
- 2Enable a system-assigned managed identity for the Function App and assign it the Key Vault Secrets Officer role.
- 3Create an Azure Event Grid subscription for the SecretNearExpiry event that targets the Azure Function endpoint.
- 4Configure the Key Vault secret with an expiration date and define its rotation policy parameters.
Answer
Deploy the Azure Function, enable its system-assigned managed identity and assign the Key Vault Secrets Officer role, create the Event Grid subscription for the SecretNearExpiry event targeting the function endpoint, and configure the secret's expiration and rotation policy parameters.
The correct order begins with deploying the function so that its endpoint is generated. Then, you enable the system-assigned managed identity and grant it Key Vault Secrets Officer permission to allow it to write new secret versions. Next, you link the function to Key Vault by creating the Event Grid subscription. Finally, you configure the rotation policy on the secret itself to schedule when the rotation sequence starts.
Step-by-Step Solution
Key Concept
Azure Key Vault automated secret rotation using Event Grid and Azure Functions.