Forum Discussion
Connect to Azure App Configuration from Notebook using Workspace Identity
- 6 months ago
Hi Anonymous
Thank you for contacting the Microsoft Fabric community forum.This issue occurs because Microsoft Fabric notebooks do not provide access to the IMDS endpoint. As a result, ManagedIdentityCredential does not function, and any credential chain that depends on IMDS—including DefaultAzureCredential, even with a client_id—will fail.
Fabric workspace identity is different from Managed Identity. It uses OIDC workload identity, so you need to use WorkloadIdentityCredential instead.
The main issue here is this line: os.environ.get("AZURE_FEDERATED_TOKEN_FILE", "xx")
When the notebook session uses workspace identity, Fabric automatically sets AZURE_FEDERATED_TOKEN_FILE. By specifying a default value like "xx", you replace the correct value with an invalid path, causing the error:
token_file_path must be passed in or set AZURE_FEDERATED_TOKEN_FILE
To resolve this, first enable workspace identity in the Fabric workspace settings and restart the notebook session to ensure environment variables are set.
Next, set up the necessary permissions on the App Configuration resource by assigning the Fabric workspace identity the App Configuration Data Reader role or higher.
Then, use WorkloadIdentityCredential without passing any manual parameters. Fabric will automatically set AZURE_TENANT_ID, AZURE_CLIENT_ID, and AZURE_FEDERATED_TOKEN_FILE, so you do not need to set them yourself.
Here is an example of how the code should look in a Fabric notebook:
from azure.appconfiguration import AzureAppConfigurationClient
from azure.identity import WorkloadIdentityCredential
endpoint = " https://<your-app-config-name>.azconfig.io "
credential = WorkloadIdentityCredential()
client = AzureAppConfigurationClient(endpoint, credential)
setting = client.get_configuration_setting(key="test1")
print(setting.value)
With workspace identity enabled and the correct RBAC permissions, this code will authenticate and retrieve values from Azure App Configuration successfully.
If you have any further questions, please let us know and we’ll be happy to help.
Best Regards,
Microsoft Fabric Community Support Team.
Hi Anonymous
Thank you for contacting the Microsoft Fabric community forum.
This issue occurs because Microsoft Fabric notebooks do not provide access to the IMDS endpoint. As a result, ManagedIdentityCredential does not function, and any credential chain that depends on IMDS—including DefaultAzureCredential, even with a client_id—will fail.
Fabric workspace identity is different from Managed Identity. It uses OIDC workload identity, so you need to use WorkloadIdentityCredential instead.
The main issue here is this line: os.environ.get("AZURE_FEDERATED_TOKEN_FILE", "xx")
When the notebook session uses workspace identity, Fabric automatically sets AZURE_FEDERATED_TOKEN_FILE. By specifying a default value like "xx", you replace the correct value with an invalid path, causing the error:
token_file_path must be passed in or set AZURE_FEDERATED_TOKEN_FILE
To resolve this, first enable workspace identity in the Fabric workspace settings and restart the notebook session to ensure environment variables are set.
Next, set up the necessary permissions on the App Configuration resource by assigning the Fabric workspace identity the App Configuration Data Reader role or higher.
Then, use WorkloadIdentityCredential without passing any manual parameters. Fabric will automatically set AZURE_TENANT_ID, AZURE_CLIENT_ID, and AZURE_FEDERATED_TOKEN_FILE, so you do not need to set them yourself.
Here is an example of how the code should look in a Fabric notebook:
from azure.appconfiguration import AzureAppConfigurationClient
from azure.identity import WorkloadIdentityCredential
endpoint = " https://<your-app-config-name>.azconfig.io "
credential = WorkloadIdentityCredential()
client = AzureAppConfigurationClient(endpoint, credential)
setting = client.get_configuration_setting(key="test1")
print(setting.value)
With workspace identity enabled and the correct RBAC permissions, this code will authenticate and retrieve values from Azure App Configuration successfully.
If you have any further questions, please let us know and we’ll be happy to help.
Best Regards,
Microsoft Fabric Community Support Team.