Hi Aizha Akmat,
Welcome to the Microsoft Q&A and thank you for posting your query here.
When a managed identity used by your PostgreSQL Flexible Server to access the Customer Managed Key (CMK) gets deleted, just recreating the identity with the same name isn’t enough to fix everything.
You need to update the PostgreSQL server itself to use the new or recovered managed identity explicitly. This means going to the server’s data encryption settings in the Azure portal and selecting the new identity there, then saving the changes.
Also, make sure the new managed identity has the right permissions on the Key Vault where the CMK is stored. It should at least have the “Key Vault Crypto Service Encryption User” role, which allows it to access the key securely.
You mentioned updating the server locks, which is one way to trigger the system to re-check and revalidate the identity and key connections. This step is useful and part of the process, but it won’t work unless the new identity is properly linked to the server as mentioned.
After making those updates, it might take up to an hour for the server to finish validating everything and return to a healthy state where your database is accessible again.
To be precise:
- Recreate or recover the managed identity
- Update the PostgreSQL server configuration to use this new identity
- Assign correct key permissions in Key Vault to that identity
- Use the lock update or a server update to trigger revalidation
- Wait up to 60 minutes for revalidation to complete
If all these steps are done, the server should come back to a ready state, and your access through the CMK should be restored.
If still you issue has persisted, please share required details in private message
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
References: