Forum Discussion
Fabric - Setting a tenant on notebooks
- 1 year ago
If you need to access a Key Vault in a different tenant, you’ll need to ensure that:
1. The managed identity of your Fabric workspace has been granted access to the Key Vault in the target tenant.
2. The Key Vault’s access policies or RBAC settings allow access from your managed identity.
Use Fabric’s Secret Management
Azure Fabric provides built-in secret management capabilities. Instead of accessing the Key Vault directly from your notebook, consider storing the secret in Fabric’s secret management and accessing it from there:from notebookutils import mssparkutils
secret_value = mssparkutils.secrets.get("your-secret-name", "your-secret-scope")
print(secret_value)
Hi Soobramoney
The error you’re encountering suggests that the `DefaultAzureCredential` is unable to authenticate using any of the available methods when you specify a different tenant. This is likely because the Fabric notebook environment doesn’t have access to the credentials for the other tenant.
Instead of using `DefaultAzureCredential`, you can create a service principal in the target tenant and use its credentials to authenticate:
from azure.identity import ClientSecretCredential
from azure.keyvault.secrets import SecretClient
tenant_id = 'target_tenant_id'
client_id = 'service_principal_client_id'
client_secret = 'service_principal_client_secret'
credential = ClientSecretCredential(tenant_id, client_id, client_secret)
vault_url = 'https://vault.azure.net/'
client = SecretClient(vault_url=vault_url, credential=credential)
Please see if this is helpful
- Soobramoney1 year ago
Advocate I
Hi nilendraFabric ,
If we implement this, will it not expose the client_id and client_secrete in the notebooks? I'm trying not to hardcode any credentials hence why i'm trying to use key vault.