Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2829,7 +2829,7 @@
}
},
"mappedToolList": [
"storagesync_cloudendpoint_triggerchangedetection"
"storagesync_cloudendpoint_changedetection"
]
}
]
Expand Down
5 changes: 4 additions & 1 deletion servers/Azure.Mcp.Server/docs/azmcp-commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -2092,12 +2092,15 @@ azmcp storagesync cloudendpoint get --subscription <subscription> \
[--name <endpoint-name>]

# Trigger change detection on a Cloud Endpoint
# ❌ Destructive | ❌ Idempotent | ❌ OpenWorld | ❌ ReadOnly | ❌ Secret | ❌ LocalRequired
azmcp storagesync cloudendpoint changedetection --subscription <subscription> \
--resource-group <resource-group> \
--service <service-name> \
--syncgroup <syncgroup-name> \
--name <endpoint-name> \
[--directory-path <path>]
--directory-path <path> \
[--change-detection-mode <mode>] \
[--paths <path1> <path2> ...]
```

#### Registered Server
Expand Down
2 changes: 1 addition & 1 deletion servers/Azure.Mcp.Server/docs/e2eTestPrompts.md
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ This file contains prompts used for end-to-end testing to ensure each tool is in
| storagesync_syncgroup_create | Create a new sync group named <syncgroup-name> in service <service-name> |
| storagesync_syncgroup_delete | Delete the sync group <syncgroup-name> from service <service-name> |
| storagesync_syncgroup_get | Get the details of sync group <syncgroup-name> in service <service-name> |
| storagesync_cloudendpoint_changedetection | Trigger change detection on cloud endpoint <endpoint-name> in sync group <syncgroup-name> in service <service-name> |
| storagesync_cloudendpoint_changedetection | Trigger change detection on cloud endpoint <endpoint-name> in sync group <syncgroup-name> in service <service-name> for directory path <path> |
| storagesync_cloudendpoint_create | Create a new cloud endpoint named <endpoint-name> for Azure file share <share-name> in storage account <storage-account-name> |
| storagesync_cloudendpoint_delete | Delete the cloud endpoint <endpoint-name> from sync group <syncgroup-name> |
| storagesync_cloudendpoint_get | Get the details of cloud endpoint <endpoint-name> in sync group <syncgroup-name> |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public sealed class CloudEndpointTriggerChangeDetectionCommand(ILogger<CloudEndp

public override string Id => "96f096a2-d36f-4361-aa74-4e393e7f48a5";

public override string Name => "triggerchangedetection";
public override string Name => "changedetection";

public override string Description => "Trigger change detection on a cloud endpoint to sync file changes.";

Expand All @@ -45,6 +45,9 @@ protected override void RegisterOptions(Command command)
command.Options.Add(StorageSyncOptionDefinitions.StorageSyncService.Name.AsRequired());
command.Options.Add(StorageSyncOptionDefinitions.SyncGroup.Name.AsRequired());
command.Options.Add(StorageSyncOptionDefinitions.CloudEndpoint.Name.AsRequired());
command.Options.Add(StorageSyncOptionDefinitions.CloudEndpoint.DirectoryPath.AsRequired());
command.Options.Add(StorageSyncOptionDefinitions.CloudEndpoint.ChangeDetectionMode.AsOptional());
command.Options.Add(StorageSyncOptionDefinitions.CloudEndpoint.Paths.AsOptional());
}

protected override CloudEndpointTriggerChangeDetectionOptions BindOptions(ParseResult parseResult)
Expand All @@ -54,6 +57,9 @@ protected override CloudEndpointTriggerChangeDetectionOptions BindOptions(ParseR
options.StorageSyncServiceName = parseResult.GetValueOrDefault<string>(StorageSyncOptionDefinitions.StorageSyncService.Name.Name);
options.SyncGroupName = parseResult.GetValueOrDefault<string>(StorageSyncOptionDefinitions.SyncGroup.Name.Name);
options.CloudEndpointName = parseResult.GetValueOrDefault<string>(StorageSyncOptionDefinitions.CloudEndpoint.Name.Name);
options.DirectoryPath = parseResult.GetValueOrDefault<string>(StorageSyncOptionDefinitions.CloudEndpoint.DirectoryPath.Name);
options.ChangeDetectionMode = parseResult.GetValueOrDefault<string>(StorageSyncOptionDefinitions.CloudEndpoint.ChangeDetectionMode.Name);
options.Paths = parseResult.GetValueOrDefault<string[]>(StorageSyncOptionDefinitions.CloudEndpoint.Paths.Name)?.ToList();
return options;
}

Expand All @@ -68,18 +74,18 @@ public override async Task<CommandResponse> ExecuteAsync(CommandContext context,

try
{
_logger.LogInformation("Triggering change detection. Subscription: {Subscription}, ResourceGroup: {ResourceGroup}, ServiceName: {ServiceName}, GroupName: {GroupName}, EndpointName: {EndpointName}",
options.Subscription, options.ResourceGroup, options.StorageSyncServiceName, options.SyncGroupName, options.CloudEndpointName);
_logger.LogInformation("Triggering change detection. Subscription: {Subscription}, ResourceGroup: {ResourceGroup}, ServiceName: {ServiceName}, GroupName: {GroupName}, EndpointName: {EndpointName}, DirectoryPath: {DirectoryPath}, ChangeDetectionMode: {ChangeDetectionMode}",
options.Subscription, options.ResourceGroup, options.StorageSyncServiceName, options.SyncGroupName, options.CloudEndpointName, options.DirectoryPath, options.ChangeDetectionMode);

await _service.TriggerChangeDetectionAsync(
options.Subscription!,
options.ResourceGroup!,
options.StorageSyncServiceName!,
options.SyncGroupName!,
options.CloudEndpointName!,
null,
null,
false,
options.DirectoryPath!,
options.ChangeDetectionMode,
options.Paths,
options.Tenant,
options.RetryPolicy,
cancellationToken);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,19 @@ public class CloudEndpointTriggerChangeDetectionOptions : BaseStorageSyncOptions
/// Gets or sets the cloud endpoint name.
/// </summary>
public string? CloudEndpointName { get; set; }

/// <summary>
/// Gets or sets the relative path to a directory Azure File share for which change detection is to be performed.
/// </summary>
public string? DirectoryPath { get; set; }

/// <summary>
/// Gets or sets the change detection mode. Applies to a directory specified in directoryPath parameter.
/// </summary>
public string? ChangeDetectionMode { get; set; }

/// <summary>
/// Gets or sets the array of relative paths on the Azure File share to be included in the change detection. Can be files and directories.
/// </summary>
public IList<string>? Paths { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public static class CloudEndpoint
private const string StorageAccountResourceIdName = "storage-account-resource-id";
private const string AzureFileShareNameName = "azure-file-share-name";
private const string DirectoryPathName = "directory-path";
private const string RecursiveName = "recursive";
private const string ChangeDetectionModeName = "change-detection-mode";
private const string PathsName = "paths";

public static readonly Option<string> Name = new($"--{NameName}", "-ce")
{
Expand All @@ -93,12 +94,18 @@ public static class CloudEndpoint

public static readonly Option<string> DirectoryPath = new($"--{DirectoryPathName}")
{
Description = "The directory path for change detection"
Description = "Relative path to a directory on the Azure File share for which change detection is to be performed"
};

public static readonly Option<bool> Recursive = new($"--{RecursiveName}", "-r")
public static readonly Option<string> ChangeDetectionMode = new($"--{ChangeDetectionModeName}")
{
Description = "Recursively include subdirectories for change detection"
Description = "Change detection mode: 'Default' (directory only) or 'Recursive' (directory and subdirectories). Applies to the directory specified in directory-path"
};

public static readonly Option<string[]> Paths = new($"--{PathsName}")
{
Description = "Array of relative paths on the Azure File share to be included in change detection. Can be files and directories",
AllowMultipleArgumentsPerToken = true
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ Task TriggerChangeDetectionAsync(
string storageSyncServiceName,
string syncGroupName,
string cloudEndpointName,
string? directoryPath = null,
string[]? filePaths = null,
bool recursive = false,
string directoryPath,
string? changeDetectionMode = null,
IList<string>? paths = null,
string? tenant = null,
RetryPolicyOptions? retryPolicy = null,
CancellationToken cancellationToken = default);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -626,9 +626,9 @@ public async Task TriggerChangeDetectionAsync(
string storageSyncServiceName,
string syncGroupName,
string cloudEndpointName,
string? directoryPath = null,
string[]? filePaths = null,
bool recursive = false,
string directoryPath,
string? changeDetectionMode = null,
IList<string>? paths = null,
string? tenant = null,
RetryPolicyOptions? retryPolicy = null,
CancellationToken cancellationToken = default)
Expand All @@ -638,7 +638,8 @@ public async Task TriggerChangeDetectionAsync(
(nameof(resourceGroup), resourceGroup),
(nameof(storageSyncServiceName), storageSyncServiceName),
(nameof(syncGroupName), syncGroupName),
(nameof(cloudEndpointName), cloudEndpointName)
(nameof(cloudEndpointName), cloudEndpointName),
(nameof(directoryPath), directoryPath)
);

try
Expand All @@ -653,13 +654,19 @@ public async Task TriggerChangeDetectionAsync(

var content = new Azure.ResourceManager.StorageSync.Models.TriggerChangeDetectionContent
{
DirectoryPath = directoryPath,
ChangeDetectionMode = recursive ? Azure.ResourceManager.StorageSync.Models.ChangeDetectionMode.Recursive : Azure.ResourceManager.StorageSync.Models.ChangeDetectionMode.Default
DirectoryPath = directoryPath
};

if (filePaths != null)
// Set change detection mode if provided
if (!string.IsNullOrEmpty(changeDetectionMode))
{
content.ChangeDetectionMode = new Azure.ResourceManager.StorageSync.Models.ChangeDetectionMode(changeDetectionMode);
}

// Add paths if provided
if (paths != null)
{
foreach (var path in filePaths)
foreach (var path in paths)
{
content.Paths.Add(path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ subscription access.
cloudEndpointGroup.AddCommand("get", serviceProvider.GetRequiredService<CloudEndpointGetCommand>());
cloudEndpointGroup.AddCommand("create", serviceProvider.GetRequiredService<CloudEndpointCreateCommand>());
cloudEndpointGroup.AddCommand("delete", serviceProvider.GetRequiredService<CloudEndpointDeleteCommand>());
cloudEndpointGroup.AddCommand("triggerchangedetection", serviceProvider.GetRequiredService<CloudEndpointTriggerChangeDetectionCommand>());
cloudEndpointGroup.AddCommand("changedetection", serviceProvider.GetRequiredService<CloudEndpointTriggerChangeDetectionCommand>());

// ServerEndpoint subgroup
var serverEndpointGroup = new CommandGroup("serverendpoint",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -485,14 +485,17 @@ public async Task Should_Crud_endpoint()
public async Task Should_trigger_cloud_endpoint_change_detection()
{
var result = await CallToolAsync(
"storagesync_cloudendpoint_triggerchangedetection",
"storagesync_cloudendpoint_changedetection",
new()
{
{ "subscription", Settings.SubscriptionId },
{ "resource-group", Settings.ResourceGroupName },
{ "name", Settings.ResourceBaseName },
{ "sync-group-name", Settings.ResourceBaseName },
{ "cloud-endpoint-name", Settings.ResourceBaseName }
{ "cloud-endpoint-name", Settings.ResourceBaseName },
{ "directory-path", "/" },
{ "change-detection-mode", "Recursive" },
{ "paths", new string[] { } }
});

var message = result.AssertProperty("message");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "",
"TagPrefix": "Azure.Mcp.Tools.StorageSync.LiveTests",
"Tag": "Azure.Mcp.Tools.StorageSync.LiveTests_fd68071820"
"Tag": "Azure.Mcp.Tools.StorageSync.LiveTests_f467c63ce7"
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public void Constructor_InitializesCommandCorrectly()
{
var command = _command.GetCommand();
Assert.NotNull(command);
Assert.Equal("triggerchangedetection", command.Name);
Assert.Equal("changedetection", command.Name);
}

[Fact]
public void Name_ReturnsCorrectValue()
{
Assert.Equal("triggerchangedetection", _command.Name);
Assert.Equal("changedetection", _command.Name);
}
}

Expand Down