Forum Discussion
Access Key-vault in notebooks
- 2 years ago
Hi AdarshPanasri @can you try this blog and see if it fits your scenario? https://www.syntera.ch/blog/2023/10/18/how-to-access-azure-key-vault-secrets-from-fabric-notebook/
We now have the option to use a service principal! Fabric Notebook: Key Vault Access with Service Principal
- x_mark_x6 months agoAdvocate II
do-sc , this is a great article but even after following the steps to the T, i still get a "403 Caller is not authorized to perform action on resource" error when running the notebook in the pipeline.
Do you have any suggestions on how to solve/troubleshoot this issue?- do-sc6 months agoFrequent Visitor
Oh hi Mark!
I assume you have read the section about troubleshooting in the blog? Sometimes it can take a while to reflect the permissions from the Key Vault. Double check the permission level of the Service Principal on the Key Vault and ensure that the Pipeline is using the Notebook connection of your Service Principal. If you run the Notebook in the context of your user without having given additional permissions it can also result in the 403. Just beeing the owner on the Key Vault will not allow you to get a secret!
If it is still not working I would try to call the Key Vault with your Service Principal credentials directly to see if you could get through. Maybe some other policy like a firewall is preventing you from accessing the secret and everything else is set up correctly: https://learn.microsoft.com/en-us/azure/key-vault/general/developers-guide#authenticate-to-key-vault-in-code- x_mark_x6 months agoAdvocate II
do-sc , thank you for your reply.
After some further trials and errors, I got it working based on the article mentioned above.
I noticed that while I followed every step, I used my own code for the retrieval and more precisely I used the notebookutils.mssparkutils.credentials.getSecret method instead of usingnotebookutils.credentials.getSecret.
As mssparkutils is an older library, and notebookutils practically replaced it (https://learn.microsoft.com/en-us/fabric/data-engineering/notebook-utilities), I guess that the getSecret method got an update as well, so it can use the custom connections, while the old version does not support that feature.
Anyways, thank you for your help 🙂