Forum Discussion
How to store secrets/access secrets using User Data Functions
- Anonymous1 year ago
Hi cstoddard
Thank you for posting in the Microsoft Fabric Community. Also thankyou lbendlin for your inputs.To securely store and access secrets within User Data Functions (UDFs) in Microsoft Fabric, the best approach is to integrate Azure Key Vault (AKV) with Managed Identities. This ensures that sensitive information, such as API keys, is never hardcoded in your UDFs.
First, enable Managed Identity for your Fabric workspace, then grant it the "Key Vault Secrets User" role in AKV. This allows Fabric to authenticate securely and retrieve secrets without needing to store credentials in code.
If Managed Identities are not available in your setup, an alternative is using environment variables to securely store authentication details. Avoid hardcoding secrets at all costs, as it poses security risks.
For detailed guidance on securing credentials in Microsoft Fabric, refer to Microsoft Docs on Fabric Security. This approach follows security best practices and ensures your API keys and other sensitive data remain protected.
If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.
Thankyou.
Agreed. After much testing - UDFs do not inherit any workspace/author/user identity. There is no way to use for tokens. Other than using plain text api keys directly in the UDF code, or possibly setting them into the env os variables - which is insane, since both export plain-text via XMLA and persist into repos.
lbendlin - Notebooks inherit the author identify, and use that to get tokens. No such luck in UDFs.
- vojtechsima7 months agoSuper User
R1k91 amazing work! I did try your solution and can confirm from my end it works.