docs: Add troubleshooting for Service Principal 403 in VS Code context#1716
docs: Add troubleshooting for Service Principal 403 in VS Code context#1716bsgustavo wants to merge 1 commit intomicrosoft:mainfrom
Conversation
When using a Service Principal via Azure CLI inside VS Code, the VSCODE_PID environment variable causes the credential chain to prioritize VisualStudioCodeCredential over AzureCliCredential. This results in 403 Forbidden errors on OneLake DFS operations even when the SP has correct permissions. Added new section documenting the symptoms, root cause (VSCODE_PID credential reordering), and resolution (AZURE_TOKEN_CREDENTIALS=AzureCliCredential with full VS Code restart).
|
Thank you for your contribution @bsgustavo! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Pull request overview
This PR adds troubleshooting documentation for a specific authentication issue that occurs when using Service Principal authentication via Azure CLI inside VS Code. The issue arises because VS Code sets the VSCODE_PID environment variable, which causes the Azure MCP Server's credential chain to prioritize VisualStudioCodeCredential over AzureCliCredential, resulting in 403 Forbidden errors for OneLake DFS operations.
Changes:
- Added a new troubleshooting section documenting the Service Principal 403 issue in VS Code context
- Updated the Table of Contents with a link to the new section
- Provided detailed symptoms, root cause explanation, and resolution steps with platform-specific examples
@microsoft-github-policy-service agree |
Summary
Adds a new troubleshooting section to
TROUBLESHOOTING.mddocumenting a scenario where Service Principal authentication via Azure CLI returns403 Forbiddenon OneLake DFS operations when running inside VS Code.Problem
When using a Service Principal authenticated via
az login --service-principalinside VS Code, OneLake DFS operations (directory_create,upload_file, etc.) fail with403 Forbidden, even though the Service Principal has the correct permissions (e.g., Workspace Admin in Microsoft Fabric).The same Service Principal works correctly when called from Python scripts or other tools outside VS Code.
Root Cause
The
CustomChainedCredentialin the Azure MCP Server detects theVSCODE_PIDenvironment variable (automatically set by VS Code for all child processes) and reorders the credential chain to prioritizeVisualStudioCodeCredentialoverAzureCliCredential. This causes the MCP Server to authenticate using the VS Code user's account instead of the Service Principal, resulting in 403 errors when that account lacks the required data plane permissions.Credential chain when
VSCODE_PIDis detected:Solution
Set
AZURE_TOKEN_CREDENTIALS=AzureCliCredentialas an environment variable and fully restart VS Code (not just reload the window).Changes
VSCODE_PIDcredential reordering)AZURE_TOKEN_CREDENTIALS=AzureCliCredential+ full VS Code restart)