Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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
I’m a DevOps engineer automating CI/CD deployments to a Microsoft Fabric Dev/Test workspace using Azure DevOps. We are using a service principal (service account) for authentication.
✅ Authentication completes successfully, but during the deployment stage, we receive the following error:
DefaultAzureCredential failed to retrieve a token from the included credentials.
This happens when the deployment script (deploy.py) runs, even though the service principal is authenticated earlier in the pipeline.
To build a secure, automated Azure DevOps pipeline that:
Solved! Go to Solution.
Hi @Shiva3 ,
Great question—this is a common stumbling block when automating Fabric deployments with Azure DevOps and service principals. Here’s a detailed breakdown and best practices:
Different Contexts in Pipeline:
Authentication might succeed during the initial stages (e.g., in Azure DevOps tasks), but when the deployment script (deploy.py) runs, it could be executed in a different context or environment variable scope. The DefaultAzureCredential flow checks multiple credential sources and may not pick up your service principal as expected during the script run.
Missing Environment Variables:
Ensure that all required environment variables (AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET) are available in the context where deploy.py executes—not just in the pipeline, but for any subprocesses as well.
Token Caching/Expiration:
If there’s a delay or context switch, the acquired token may expire or not be forwarded properly between steps.
User vs. Service Principal Permissions:
Sometimes, the initial authentication uses a user identity, but the deploy script is forced to use a service principal, which may lack certain permissions on the Fabric workspace or resources.
Required Permissions:
Double-check that your service principal has all the necessary permissions on the Fabric workspace (Contributor or higher, Data Admin roles if needed).
Supported SDK/CLI:
Make sure you’re using the latest Azure SDKs compatible with Microsoft Fabric, and that your service principal is granted necessary RBAC roles both in Azure and in Fabric itself.
Service Connection in Azure DevOps:
If using an Azure Resource Manager service connection, verify that it’s set to use the correct service principal and that it’s available to all pipeline tasks and scripts.
Best Practice:
Set the required environment variables explicitly in the pipeline before running your Python deployment script, so DefaultAzureCredential always picks up the correct credentials.
Example YAML snippet:
- task: Bash@3 env: AZURE_CLIENT_ID: $(servicePrincipalId) AZURE_TENANT_ID: $(tenantId) AZURE_CLIENT_SECRET: $(servicePrincipalKey) inputs: targetType: 'inline' script: | python deploy.py
Python (deploy.py) snippet:
from azure.identity import DefaultAzureCredential from azure.mgmt.resource import ResourceManagementClient credential = DefaultAzureCredential() client = ResourceManagementClient(credential, "<subscription_id>") # ... your deployment logic ...
Extra Tips:
Let me know if you need a full working pipeline example or if you hit any other errors—happy to help you troubleshoot further!
The issue has been resolved by adding an additional step—logging into Azure CLI using a service account to complete the DefaultAzureCredential authentication flow. Multi-Factor Authentication (MFA) has been disabled for this service account, and currently, the CI/CD deployment is functioning as expected.
Concern:
However, I’m concerned about the upcoming change:
⚠️ Starting July 1, 2025, MFA will be gradually enforced for Azure public cloud. Authentication using username and password via the command line will no longer be supported with MFA. Consider switching to a supported authentication method.
More details
If MFA becomes mandatory, CLI login using the current service account setup may no longer work, potentially disrupting our deployment pipeline.
The issue has been resolved by adding an additional step—logging into Azure CLI using a service account to complete the DefaultAzureCredential authentication flow. Multi-Factor Authentication (MFA) has been disabled for this service account, and currently, the CI/CD deployment is functioning as expected.
Concern:
However, I’m concerned about the upcoming change:
⚠️ Starting July 1, 2025, MFA will be gradually enforced for Azure public cloud. Authentication using username and password via the command line will no longer be supported with MFA. Consider switching to a supported authentication method.
More details
If MFA becomes mandatory, CLI login using the current service account setup may no longer work, potentially disrupting our deployment pipeline.
Hi @Shiva3 ,
Great question—this is a common stumbling block when automating Fabric deployments with Azure DevOps and service principals. Here’s a detailed breakdown and best practices:
Different Contexts in Pipeline:
Authentication might succeed during the initial stages (e.g., in Azure DevOps tasks), but when the deployment script (deploy.py) runs, it could be executed in a different context or environment variable scope. The DefaultAzureCredential flow checks multiple credential sources and may not pick up your service principal as expected during the script run.
Missing Environment Variables:
Ensure that all required environment variables (AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET) are available in the context where deploy.py executes—not just in the pipeline, but for any subprocesses as well.
Token Caching/Expiration:
If there’s a delay or context switch, the acquired token may expire or not be forwarded properly between steps.
User vs. Service Principal Permissions:
Sometimes, the initial authentication uses a user identity, but the deploy script is forced to use a service principal, which may lack certain permissions on the Fabric workspace or resources.
Required Permissions:
Double-check that your service principal has all the necessary permissions on the Fabric workspace (Contributor or higher, Data Admin roles if needed).
Supported SDK/CLI:
Make sure you’re using the latest Azure SDKs compatible with Microsoft Fabric, and that your service principal is granted necessary RBAC roles both in Azure and in Fabric itself.
Service Connection in Azure DevOps:
If using an Azure Resource Manager service connection, verify that it’s set to use the correct service principal and that it’s available to all pipeline tasks and scripts.
Best Practice:
Set the required environment variables explicitly in the pipeline before running your Python deployment script, so DefaultAzureCredential always picks up the correct credentials.
Example YAML snippet:
- task: Bash@3 env: AZURE_CLIENT_ID: $(servicePrincipalId) AZURE_TENANT_ID: $(tenantId) AZURE_CLIENT_SECRET: $(servicePrincipalKey) inputs: targetType: 'inline' script: | python deploy.py
Python (deploy.py) snippet:
from azure.identity import DefaultAzureCredential from azure.mgmt.resource import ResourceManagementClient credential = DefaultAzureCredential() client = ResourceManagementClient(credential, "<subscription_id>") # ... your deployment logic ...
Extra Tips:
Let me know if you need a full working pipeline example or if you hit any other errors—happy to help you troubleshoot further!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Fabric update to learn about new features.
User | Count |
---|---|
69 | |
39 | |
15 | |
14 | |
5 |
User | Count |
---|---|
72 | |
65 | |
25 | |
8 | |
7 |