Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredJoin us at FabCon Vienna from September 15-18, 2025, for the ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM. Get registered
Hello all,
I have recently started using Microsoft's Fabric and I have created a notebook. The notebook basically does an API call to a URL to get some information and stores them in multiple delta tables. To do the API call we need to authenticate against a URL to get the access token, we do this by using the requests library in python and adding the appropriate information:
# The URL for the Microsoft identity platform token endpoint
url = f"https://login.microsoftonline.com/{tenant_id}/oauth2/v2.0/token"
# The data for the POST request
data = {
"client_id": client_id,
"scope": scope,
"client_secret": client_secret,
"grant_type": "client_credentials"
}
# Make the POST request and get the access token
response = requests.post(url, data=data)
access_token = response.json().get('access_token')
Right now I give the client_id, tenant_id and client_secret in another cell but this is not secure at all. What ways exist to secure this inputs? Azure key vault would be a good solution for example?
Thanks a lot.
Solved! Go to Solution.
Hi @vasotsich
Thanks for using Microsoft Fabric Community.
As I understand that you want to protect security information in Fabric Notebook.
Yes, you are correct Azure key vault would be a good solution for protecting secure information. Certainly! Securing sensitive information such as client_id, tenant_id, and client_secret is crucial, especially when dealing with authentication in your Microsoft Fabric notebook. Azure Key Vault provides a secure and efficient way to manage secrets, ensuring that your credentials remain confidential.
Please refer to the following documentation for more information.
Link: Reading and Writing Secrets in Azure Key Vault Using Microsoft Fabric Notebooks.
I hope this information helps. Please do let us know if you have any further questions.
Thanks.
Hi @vasotsich
Glad that your query got resolved.
Please continue using Fabric Community for any help regarding your queries.
Thanks.
Hi @vasotsich
Thanks for using Microsoft Fabric Community.
As I understand that you want to protect security information in Fabric Notebook.
Yes, you are correct Azure key vault would be a good solution for protecting secure information. Certainly! Securing sensitive information such as client_id, tenant_id, and client_secret is crucial, especially when dealing with authentication in your Microsoft Fabric notebook. Azure Key Vault provides a secure and efficient way to manage secrets, ensuring that your credentials remain confidential.
Please refer to the following documentation for more information.
Link: Reading and Writing Secrets in Azure Key Vault Using Microsoft Fabric Notebooks.
I hope this information helps. Please do let us know if you have any further questions.
Thanks.
Hi Team,
I used to connect to keyvault from databrick by mounting it.
I have done throught the documentation that is provided above, but as i see they are creating keyvault adding secret to KV and then fetching the secret from KV using "mssparkutils.credentials.getSecret"
But I dont see any authentication provided to connect to Keyvault. Can you please help me with this?
Hey are you trying to do this a notebook in Fabric? Is so, you need to import the library first and then the parameters you need. The python code should look something like this:
I tired the suggested already but iam facing this issue, not sure what the root cause iam pretty sure my Keyvault URL is right, But how to know if the fabric has connectivity to this. Since i have enabled fabric free trial from app.powerbi.com directly. I am currently implementing POC.
Error : Py4JJavaError: An error occurred while calling o4789.getSecretWithToken. : java.io.IOException: 401 {"error":{"code":"Unauthorized","message":"AKV10032: Invalid issuer.
From the error you are getting it seems that the user is not authorized to access the key vault or read the secret. You need to set the correct permissions to the vault and then try again.
To connect to KeyVault from notebook, do we need to provide access to users. Cant we use SPN to connect to KeyVault. Because as per our policies we cannot provide read access on keyVault to individual users. May i know to how to connecto KeyVault using SPN .
This might help you but I am not sure: Run a job with a Microsoft Entra ID service principal - Azure Databricks | Microsoft Learn
I See the provided link is for databricks, but what i need is how to authenticate using SPN to connect to key vault from microsoft fabric notebook
Thanks for the information! This is exactly what I was looking for.
Hi @vasotsich
Glad that your query got resolved.
Please continue using Fabric Community for any help regarding your queries.
Thanks.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
70 | |
44 | |
14 | |
12 | |
5 |
User | Count |
---|---|
80 | |
73 | |
27 | |
8 | |
7 |