-
Notifications
You must be signed in to change notification settings - Fork 433
Cleanup Fabric OneLake commands #2120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -376,12 +376,12 @@ This error indicates that the access token doesn't have sufficient permissions t | |
|
|
||
| ### Service Principal Returns 403 for OneLake Operations in VS Code | ||
|
|
||
| When using Azure MCP Server inside VS Code with a Service Principal authenticated via Azure CLI (`az login --service-principal`), OneLake DFS operations (such as `directory_create`, `upload_file`) may return `403 Forbidden`, even though the Service Principal has the correct permissions (e.g., Workspace Admin in Microsoft Fabric). | ||
| When using Azure MCP Server inside VS Code with a Service Principal authenticated via Azure CLI (`az login --service-principal`), OneLake DFS operations (such as `directory_create`, `upload-file`) may return `403 Forbidden`, even though the Service Principal has the correct permissions (e.g., Workspace Admin in Microsoft Fabric). | ||
|
|
||
| #### Symptoms | ||
|
|
||
| - OneLake **blob** operations (e.g., `file_list` without a path) may succeed with `200 OK` | ||
| - OneLake **DFS** operations (e.g., `directory_create`, `upload_file`) fail with `403 Forbidden` | ||
| - OneLake **DFS** operations (e.g., `directory_create`, `upload-file`) fail with `403 Forbidden` | ||
|
||
| - The same Service Principal works correctly when used from Python scripts or other tools outside VS Code | ||
| - Fabric REST API operations (e.g., `item_create`) may also fail with `401 Unauthorized` | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Diagnostics.CodeAnalysis; | ||
| using Azure.Mcp.Core.Commands; | ||
| using Azure.Mcp.Core.Extensions; | ||
| using Fabric.Mcp.Tools.OneLake.Options; | ||
| using Microsoft.Mcp.Core.Extensions; | ||
| using Microsoft.Mcp.Core.Models.Option; | ||
|
|
||
| namespace Fabric.Mcp.Tools.OneLake.Commands; | ||
|
|
||
| public abstract class BaseItemCommand< | ||
| [DynamicallyAccessedMembers(TrimAnnotations.CommandAnnotations)] TOptions> | ||
| : BaseWorkspaceCommand<TOptions> where TOptions : BaseItemOptions, new() | ||
| { | ||
| protected BaseItemCommand() | ||
| { | ||
| } | ||
|
|
||
| protected override void RegisterOptions(Command command) | ||
| { | ||
| base.RegisterOptions(command); | ||
| command.Options.Add(FabricOptionDefinitions.ItemId.AsOptional()); | ||
| command.Options.Add(FabricOptionDefinitions.Item.AsOptional()); | ||
| command.Validators.Add(result => | ||
| { | ||
| var itemId = result.GetValueOrDefault<string>(FabricOptionDefinitions.ItemId.Name); | ||
| var item = result.GetValueOrDefault<string>(FabricOptionDefinitions.Item.Name); | ||
|
|
||
| if (string.IsNullOrWhiteSpace(item) && string.IsNullOrWhiteSpace(itemId)) | ||
| { | ||
| result.AddError("Item identifier is required. Provide --item or --item-id."); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| protected override TOptions BindOptions(ParseResult parseResult) | ||
| { | ||
| var options = base.BindOptions(parseResult); | ||
| var itemId = parseResult.GetValueOrDefault<string>(FabricOptionDefinitions.ItemId.Name); | ||
| var item = parseResult.GetValueOrDefault<string>(FabricOptionDefinitions.Item.Name); | ||
| options.ItemId = !string.IsNullOrWhiteSpace(itemId) | ||
| ? itemId! | ||
| : item ?? string.Empty; | ||
| return options; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| // Copyright (c) Microsoft Corporation. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Diagnostics.CodeAnalysis; | ||
| using Azure.Mcp.Core.Commands; | ||
| using Azure.Mcp.Core.Extensions; | ||
| using Fabric.Mcp.Tools.OneLake.Options; | ||
| using Microsoft.Mcp.Core.Extensions; | ||
| using Microsoft.Mcp.Core.Models.Option; | ||
|
|
||
| namespace Fabric.Mcp.Tools.OneLake.Commands; | ||
|
|
||
| public abstract class BaseWorkspaceCommand< | ||
| [DynamicallyAccessedMembers(TrimAnnotations.CommandAnnotations)] TOptions> | ||
| : GlobalCommand<TOptions> where TOptions : BaseWorkspaceOptions, new() | ||
| { | ||
| protected BaseWorkspaceCommand() | ||
| { | ||
| } | ||
|
|
||
| protected override void RegisterOptions(Command command) | ||
| { | ||
| base.RegisterOptions(command); | ||
| command.Options.Add(FabricOptionDefinitions.WorkspaceId.AsOptional()); | ||
| command.Options.Add(FabricOptionDefinitions.Workspace.AsOptional()); | ||
| command.Validators.Add(result => | ||
| { | ||
| var workspaceId = result.GetValueOrDefault<string>(FabricOptionDefinitions.WorkspaceId.Name); | ||
| var workspace = result.GetValueOrDefault<string>(FabricOptionDefinitions.Workspace.Name); | ||
|
|
||
| if (string.IsNullOrWhiteSpace(workspaceId) && string.IsNullOrWhiteSpace(workspace)) | ||
| { | ||
| result.AddError("Workspace identifier is required. Provide --workspace or --workspace-id."); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| protected override TOptions BindOptions(ParseResult parseResult) | ||
| { | ||
| var options = base.BindOptions(parseResult); | ||
| var workspaceId = parseResult.GetValueOrDefault<string>(FabricOptionDefinitions.WorkspaceId.Name); | ||
| var workspaceName = parseResult.GetValueOrDefault<string>(FabricOptionDefinitions.Workspace.Name); | ||
| options.WorkspaceId = !string.IsNullOrWhiteSpace(workspaceId) | ||
| ? workspaceId! | ||
| : workspaceName ?? string.Empty; | ||
| return options; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The troubleshooting examples mix old underscore-style command names (
directory_create) with the new hyphenated naming (upload-file). Update the remaining OneLake examples to the new tool/command names (and include the correctonelake_prefix if that’s what callers use) so readers can reliably copy/paste working commands.