diff --git a/src/Storage/ChangeLog.md b/src/Storage/ChangeLog.md index f8c1d70defbe..ed473f797ff5 100644 --- a/src/Storage/ChangeLog.md +++ b/src/Storage/ChangeLog.md @@ -18,7 +18,11 @@ - Additional information about change #1 --> ## Current Release - +* Upgrade to Azure Storage Client Library 8.5.0 and Azure Storage DataMovement Library 0.6.3 +* Add File Share Snapshot Support Feature + - Add 'SnapshotTime' parameter to Get-AzureStorageShare + - Add 'IncludeAllSnapshot' parameter to Remove-AzureStorageShare + ## Version 3.4.1 ## Version 3.4.0 diff --git a/src/Storage/Commands.Storage.Test/Commands.Storage.Test.csproj b/src/Storage/Commands.Storage.Test/Commands.Storage.Test.csproj index baa1cbf082da..b1ef27a54dc9 100644 --- a/src/Storage/Commands.Storage.Test/Commands.Storage.Test.csproj +++ b/src/Storage/Commands.Storage.Test/Commands.Storage.Test.csproj @@ -122,11 +122,11 @@ ..\..\packages\Microsoft.WindowsAzure.Management.4.1.1\lib\net40\Microsoft.WindowsAzure.Management.dll - - ..\..\packages\WindowsAzure.Storage.8.4.0\lib\net45\Microsoft.WindowsAzure.Storage.dll + + ..\..\packages\WindowsAzure.Storage.8.5.0\lib\net45\Microsoft.WindowsAzure.Storage.dll - - ..\..\packages\Microsoft.Azure.Storage.DataMovement.0.6.1\lib\net45\Microsoft.WindowsAzure.Storage.DataMovement.dll + + ..\..\packages\Microsoft.Azure.Storage.DataMovement.0.6.3\lib\net45\Microsoft.WindowsAzure.Storage.DataMovement.dll ..\..\packages\Newtonsoft.Json.6.0.8\lib\net45\Newtonsoft.Json.dll diff --git a/src/Storage/Commands.Storage.Test/Service/MockStorageFileManagement.cs b/src/Storage/Commands.Storage.Test/Service/MockStorageFileManagement.cs index 1958783372a5..1598a574f9a8 100644 --- a/src/Storage/Commands.Storage.Test/Service/MockStorageFileManagement.cs +++ b/src/Storage/Commands.Storage.Test/Service/MockStorageFileManagement.cs @@ -53,9 +53,9 @@ public void SetsAvailableDirectories(params string[] directoryNames) this.availableDirectoryNames.AddRange(directoryNames); } - public CloudFileShare GetShareReference(string shareName) + public CloudFileShare GetShareReference(string shareName, DateTimeOffset? snapshotTime = null) { - return client.GetShareReference(shareName); + return client.GetShareReference(shareName, snapshotTime); } public void FetchShareAttributes(CloudFileShare share, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) @@ -136,7 +136,7 @@ public Task DeleteDirectoryAsync(CloudFileDirectory directory, AccessCondition a return TaskEx.FromResult(true); } - public Task DeleteShareAsync(CloudFileShare share, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public Task DeleteShareAsync(CloudFileShare share, DeleteShareSnapshotsOption deleteShareSnapshotsOption, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { return TaskEx.FromResult(true); } diff --git a/src/Storage/Commands.Storage.Test/packages.config b/src/Storage/Commands.Storage.Test/packages.config index 77381e33aaaa..79f5f44ef296 100644 --- a/src/Storage/Commands.Storage.Test/packages.config +++ b/src/Storage/Commands.Storage.Test/packages.config @@ -5,7 +5,7 @@ - + @@ -25,7 +25,7 @@ - + diff --git a/src/Storage/Commands.Storage/Commands.Storage.csproj b/src/Storage/Commands.Storage/Commands.Storage.csproj index 3f36eace91cc..6ec2e2f02c2e 100644 --- a/src/Storage/Commands.Storage/Commands.Storage.csproj +++ b/src/Storage/Commands.Storage/Commands.Storage.csproj @@ -59,13 +59,12 @@ ..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.1.8.0.0\lib\net35-full\Microsoft.WindowsAzure.Configuration.dll - True - - ..\..\packages\WindowsAzure.Storage.8.4.0\lib\net45\Microsoft.WindowsAzure.Storage.dll + + ..\..\packages\WindowsAzure.Storage.8.5.0\lib\net45\Microsoft.WindowsAzure.Storage.dll - - ..\..\packages\Microsoft.Azure.Storage.DataMovement.0.6.1\lib\net45\Microsoft.WindowsAzure.Storage.DataMovement.dll + + ..\..\packages\Microsoft.Azure.Storage.DataMovement.0.6.3\lib\net45\Microsoft.WindowsAzure.Storage.DataMovement.dll False @@ -242,7 +241,9 @@ PreserveNewest - + + Designer + diff --git a/src/Storage/Commands.Storage/Common/StorageExtensions.cs b/src/Storage/Commands.Storage/Common/StorageExtensions.cs index 202a82501366..8abb7a0e6a61 100644 --- a/src/Storage/Commands.Storage/Common/StorageExtensions.cs +++ b/src/Storage/Commands.Storage/Common/StorageExtensions.cs @@ -34,11 +34,11 @@ internal static Uri GenerateUriWithCredentials( if (string.IsNullOrEmpty(sasToken)) { - return file.Uri; + return file.SnapshotQualifiedUri; } else { - return new Uri(string.Format(CultureInfo.InvariantCulture, "{0}{1}", file.Uri.AbsoluteUri, sasToken)); + return new Uri(string.Format(CultureInfo.InvariantCulture, "{0}{1}", file.SnapshotQualifiedUri.AbsoluteUri, sasToken)); } } @@ -57,7 +57,7 @@ internal static CloudFile GenerateCopySourceFile( return file; } - return new CloudFile(file.Uri, new StorageCredentials(sasToken)); + return new CloudFile(file.SnapshotQualifiedUri, new StorageCredentials(sasToken)); } private static string GetFileSASToken(CloudFile file) diff --git a/src/Storage/Commands.Storage/Common/Util.cs b/src/Storage/Commands.Storage/Common/Util.cs index 4c1c84e80586..dba7b539d080 100644 --- a/src/Storage/Commands.Storage/Common/Util.cs +++ b/src/Storage/Commands.Storage/Common/Util.cs @@ -199,7 +199,7 @@ public static string ConvertToString(this object instance) if (null != file) { - return file.Uri.AbsoluteUri; + return file.SnapshotQualifiedUri.AbsoluteUri; } return instance.ToString(); diff --git a/src/Storage/Commands.Storage/File/Cmdlet/GetAzureStorageFileCopyState.cs b/src/Storage/Commands.Storage/File/Cmdlet/GetAzureStorageFileCopyState.cs index 19d51868e3db..697bf4f87b60 100644 --- a/src/Storage/Commands.Storage/File/Cmdlet/GetAzureStorageFileCopyState.cs +++ b/src/Storage/Commands.Storage/File/Cmdlet/GetAzureStorageFileCopyState.cs @@ -204,7 +204,7 @@ protected async Task MonitorFileCopyStatusAsync(long taskId) if (file.CopyState == null) { - ArgumentException e = new ArgumentException(String.Format(Resources.FileCopyTaskNotFound, file.Uri.ToString())); + ArgumentException e = new ArgumentException(String.Format(Resources.FileCopyTaskNotFound, file.SnapshotQualifiedUri.ToString())); OutputStream.WriteError(internalTaskId, e); Interlocked.Increment(ref InternalFailedCount); taskDone = true; diff --git a/src/Storage/Commands.Storage/File/Cmdlet/GetAzureStorageShare.cs b/src/Storage/Commands.Storage/File/Cmdlet/GetAzureStorageShare.cs index 87804510e6f8..e5dc1f58f430 100644 --- a/src/Storage/Commands.Storage/File/Cmdlet/GetAzureStorageShare.cs +++ b/src/Storage/Commands.Storage/File/Cmdlet/GetAzureStorageShare.cs @@ -18,6 +18,7 @@ namespace Microsoft.WindowsAzure.Commands.Storage.File.Cmdlet using Azure.Commands.Common.Authentication.Abstractions; using Microsoft.WindowsAzure.Commands.Common.Storage; using Microsoft.WindowsAzure.Storage.File; + using System; using System.Globalization; using System.Management.Automation; @@ -28,7 +29,7 @@ public class GetAzureStorageShare : AzureStorageFileCmdletBase Position = 0, Mandatory = true, ParameterSetName = Constants.SpecificParameterSetName, - HelpMessage = "Name of the file share to be listed.")] + HelpMessage = "Name of the file share to be received.")] [ValidateNotNullOrEmpty] public string Name { get; set; } @@ -38,6 +39,14 @@ public class GetAzureStorageShare : AzureStorageFileCmdletBase HelpMessage = "A prefix of the file shares to be listed.")] public string Prefix { get; set; } + [Parameter( + Position = 1, + Mandatory = false, + ParameterSetName = Constants.SpecificParameterSetName, + HelpMessage = "SnapshotTime of the file share snapshot to be received.")] + [ValidateNotNullOrEmpty] + public DateTimeOffset? SnapshotTime { get; set; } + [Parameter( ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, @@ -58,7 +67,7 @@ public override void ExecuteCmdlet() { case Constants.SpecificParameterSetName: NamingUtil.ValidateShareName(this.Name, false); - var share = this.Channel.GetShareReference(this.Name); + var share = this.Channel.GetShareReference(this.Name, this.SnapshotTime); await this.Channel.FetchShareAttributesAsync(share, null, this.RequestOptions, this.OperationContext, this.CmdletCancellationToken).ConfigureAwait(false); this.OutputStream.WriteObject(taskId, share); diff --git a/src/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageFileSasToken.cs b/src/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageFileSasToken.cs index e7d99c761a99..183feba6624c 100644 --- a/src/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageFileSasToken.cs +++ b/src/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageFileSasToken.cs @@ -183,7 +183,7 @@ public override void ExecuteCmdlet() if (FullUri) { - string fullUri = SasTokenHelper.GetFullUriWithSASToken(file.Uri.AbsoluteUri.ToString(), sasToken); + string fullUri = SasTokenHelper.GetFullUriWithSASToken(file.SnapshotQualifiedUri.AbsoluteUri.ToString(), sasToken); WriteObject(fullUri); } diff --git a/src/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageShareSasToken.cs b/src/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageShareSasToken.cs index 71900e1a7c92..a01f13eb3547 100644 --- a/src/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageShareSasToken.cs +++ b/src/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageShareSasToken.cs @@ -114,7 +114,7 @@ public override void ExecuteCmdlet() if (FullUri) { - string fullUri = SasTokenHelper.GetFullUriWithSASToken(fileShare.Uri.AbsoluteUri.ToString(), sasToken); + string fullUri = SasTokenHelper.GetFullUriWithSASToken(fileShare.SnapshotQualifiedUri.AbsoluteUri.ToString(), sasToken); WriteObject(fullUri); } diff --git a/src/Storage/Commands.Storage/File/Cmdlet/RemoveAzureStorageShare.cs b/src/Storage/Commands.Storage/File/Cmdlet/RemoveAzureStorageShare.cs index 3ad713f5d51c..fbc301627331 100644 --- a/src/Storage/Commands.Storage/File/Cmdlet/RemoveAzureStorageShare.cs +++ b/src/Storage/Commands.Storage/File/Cmdlet/RemoveAzureStorageShare.cs @@ -14,6 +14,8 @@ namespace Microsoft.WindowsAzure.Commands.Storage.File.Cmdlet { + using Microsoft.WindowsAzure.Commands.Storage.Common; + using Microsoft.WindowsAzure.Storage; using Microsoft.WindowsAzure.Storage.File; using System.Globalization; using System.Management.Automation; @@ -44,7 +46,10 @@ public class RemoveAzureStorageShare : AzureStorageFileCmdletBase [ValidateNotNull] public CloudFileShare Share { get; set; } - [Parameter(HelpMessage = "Force to remove the share and all content in it")] + [Parameter(HelpMessage = "Remove File Share with all of its snapshots")] + public SwitchParameter IncludeAllSnapshot { get; set; } + + [Parameter(HelpMessage = "Force to remove the share with all its snapshots, and all content in them.")] public SwitchParameter Force { get { return force; } @@ -56,6 +61,15 @@ public SwitchParameter Force private bool force; + /// + /// Cmdlet begin processing + /// + protected override void BeginProcessing() + { + base.BeginProcessing(); + OutputStream.ConfirmWriter = (s1, s2, s3) => ShouldContinue(s2, s3); + } + public override void ExecuteCmdlet() { CloudFileShare share; @@ -77,9 +91,54 @@ public override void ExecuteCmdlet() { this.RunTask(async taskId => { + if (share.IsSnapshot && IncludeAllSnapshot.IsPresent) + { + throw new PSArgumentException(string.Format(CultureInfo.InvariantCulture, "'IncludeAllSnapshot' should only be specified to delete a base share, and should not be specified to delete a Share snapshot: {0}", share.SnapshotQualifiedUri)); + } + if (force || ShareIsEmpty(share) || ShouldContinue(string.Format("Remove share and all content in it: {0}", share.Name), "")) { - await this.Channel.DeleteShareAsync(share, null, this.RequestOptions, this.OperationContext, this.CmdletCancellationToken).ConfigureAwait(false); + DeleteShareSnapshotsOption deleteShareSnapshotsOption = DeleteShareSnapshotsOption.None; + bool retryDeleteSnapshot = false; + + //Force means will delete the share anyway, so use 'IncludeSnapshots' to delete the share even has snapshot, or delete will fail when share has snapshot + // To delete a Share shapshot, must use 'None' + if (IncludeAllSnapshot.IsPresent) + { + deleteShareSnapshotsOption = DeleteShareSnapshotsOption.IncludeSnapshots; + } + else + { + retryDeleteSnapshot = true; + } + + try + { + await this.Channel.DeleteShareAsync(share, deleteShareSnapshotsOption, null, this.RequestOptions, this.OperationContext, this.CmdletCancellationToken).ConfigureAwait(false); + retryDeleteSnapshot = false; + } + catch (StorageException e) + { + //If x-ms-delete-snapshots is not specified on the request and the share has associated snapshots, the File service returns status code 409 (Conflict). + if (!(e.IsConflictException() && retryDeleteSnapshot)) + { + throw; + } + } + + if (retryDeleteSnapshot) + { + if (force || await OutputStream.ConfirmAsync(string.Format("This share might have snapshots, remove the share and all snapshots?: {0}", share.Name)).ConfigureAwait(false)) + { + deleteShareSnapshotsOption = DeleteShareSnapshotsOption.IncludeSnapshots; + await this.Channel.DeleteShareAsync(share, deleteShareSnapshotsOption, null, this.RequestOptions, this.OperationContext, this.CmdletCancellationToken).ConfigureAwait(false); + } + else + { + string result = string.Format("The remove operation of share '{0}' has been cancelled.", share.Name); + OutputStream.WriteVerbose(taskId, result); + } + } } if (this.PassThru) diff --git a/src/Storage/Commands.Storage/File/Cmdlet/StartAzureStorageFileCopy.cs b/src/Storage/Commands.Storage/File/Cmdlet/StartAzureStorageFileCopy.cs index 5b507e9254ee..730c7ce50174 100644 --- a/src/Storage/Commands.Storage/File/Cmdlet/StartAzureStorageFileCopy.cs +++ b/src/Storage/Commands.Storage/File/Cmdlet/StartAzureStorageFileCopy.cs @@ -281,7 +281,7 @@ private void StartCopyFromBlob() Func taskGenerator = (taskId) => StartAsyncCopy( taskId, destFile, - () => this.ConfirmOverwrite(blob.SnapshotQualifiedUri.ToString(), destFile.Uri.ToString()), + () => this.ConfirmOverwrite(blob.SnapshotQualifiedUri.ToString(), destFile.SnapshotQualifiedUri.ToString()), () => destFile.StartCopyAsync(blob.GenerateCopySourceBlob(), null, null, this.RequestOptions, this.OperationContext, CmdletCancellationToken)); this.RunTask(taskGenerator); @@ -321,7 +321,7 @@ private void StartCopyFromFile() Func taskGenerator = (taskId) => StartAsyncCopy( taskId, destFile, - () => this.ConfirmOverwrite(sourceFile.Uri.ToString(), destFile.Uri.ToString()), + () => this.ConfirmOverwrite(sourceFile.SnapshotQualifiedUri.ToString(), destFile.SnapshotQualifiedUri.ToString()), () => destFile.StartCopyAsync(sourceFile.GenerateCopySourceFile(), null, null, this.RequestOptions, this.OperationContext, this.CmdletCancellationToken)); this.RunTask(taskGenerator); @@ -334,7 +334,7 @@ private void StartCopyFromUri() Func taskGenerator = (taskId) => StartAsyncCopy( taskId, destFile, - () => this.ConfirmOverwrite(this.AbsoluteUri, destFile.Uri.ToString()), + () => this.ConfirmOverwrite(this.AbsoluteUri, destFile.SnapshotQualifiedUri.ToString()), () => destFile.StartCopyAsync(new Uri(this.AbsoluteUri), null, null, this.RequestOptions, this.OperationContext)); this.RunTask(taskGenerator); diff --git a/src/Storage/Commands.Storage/File/Cmdlet/StopAzureStorageFileCopy.cs b/src/Storage/Commands.Storage/File/Cmdlet/StopAzureStorageFileCopy.cs index 21c8607ec80b..9675594c6257 100644 --- a/src/Storage/Commands.Storage/File/Cmdlet/StopAzureStorageFileCopy.cs +++ b/src/Storage/Commands.Storage/File/Cmdlet/StopAzureStorageFileCopy.cs @@ -99,7 +99,7 @@ private async Task StopCopyFile(long taskId, IStorageFileManagement localChannel if (file.CopyState == null || string.IsNullOrEmpty(file.CopyState.CopyId)) { - ArgumentException e = new ArgumentException(String.Format(Resources.FileCopyTaskNotFound, file.Uri.ToString())); + ArgumentException e = new ArgumentException(String.Format(Resources.FileCopyTaskNotFound, file.SnapshotQualifiedUri.ToString())); OutputStream.WriteError(taskId, e); } else @@ -109,10 +109,10 @@ private async Task StopCopyFile(long taskId, IStorageFileManagement localChannel if (!Force) { - string confirmation = String.Format(Resources.ConfirmAbortFileCopyOperation, file.Uri.ToString(), abortCopyId); + string confirmation = String.Format(Resources.ConfirmAbortFileCopyOperation, file.SnapshotQualifiedUri.ToString(), abortCopyId); if (!await OutputStream.ConfirmAsync(confirmation).ConfigureAwait(false)) { - string cancelMessage = String.Format(Resources.StopCopyOperationCancelled, file.Uri.ToString()); + string cancelMessage = String.Format(Resources.StopCopyOperationCancelled, file.SnapshotQualifiedUri.ToString()); OutputStream.WriteVerbose(taskId, cancelMessage); } } @@ -123,7 +123,7 @@ private async Task StopCopyFile(long taskId, IStorageFileManagement localChannel } await localChannel.AbortCopyAsync(file, abortCopyId, null, requestOptions, OperationContext, CmdletCancellationToken).ConfigureAwait(false); - string message = String.Format(Resources.StopCopyFileSuccessfully, file.Uri.ToString()); + string message = String.Format(Resources.StopCopyFileSuccessfully, file.SnapshotQualifiedUri.ToString()); OutputStream.WriteObject(taskId, message); } } diff --git a/src/Storage/Commands.Storage/File/StorageClientExtensions.cs b/src/Storage/Commands.Storage/File/StorageClientExtensions.cs index f6ebf62213e3..9631d7279760 100644 --- a/src/Storage/Commands.Storage/File/StorageClientExtensions.cs +++ b/src/Storage/Commands.Storage/File/StorageClientExtensions.cs @@ -48,7 +48,7 @@ public static CloudFileDirectory GetDirectoryReferenceByPath(this CloudFileDirec currentDirectory = currentDirectory.GetDirectoryReference(subFolder); } - return new CloudFileDirectory(currentDirectory.Uri, currentDirectory.Share.ServiceClient.Credentials); + return new CloudFileDirectory(currentDirectory.SnapshotQualifiedUri, currentDirectory.Share.ServiceClient.Credentials); } /// @@ -73,7 +73,7 @@ public static CloudFile GetFileReferenceByPath(this CloudFileDirectory currentDi CloudFile file = currentDirectory.GetFileReference(path.Last()); - return new CloudFile(file.Uri, file.Share.ServiceClient.Credentials); + return new CloudFile(file.SnapshotQualifiedUri, file.Share.ServiceClient.Credentials); } /// @@ -85,12 +85,24 @@ public static string GetFullPath(this IListFileItem item) { // We need to make sure the share uri ends with "/" in order to // let MakeRelativeUri work properly. - UriBuilder shareUri = new UriBuilder(item.Share.Uri); + UriBuilder shareUri = new UriBuilder(item.Share.SnapshotQualifiedUri); if (!shareUri.Path.EndsWith(UriPathSeparator, StringComparison.Ordinal)) { shareUri.Path = string.Concat(shareUri.Path, UriPathSeparator); } + CloudFile file = item as CloudFile; + if(file != null) + { + return shareUri.Uri.MakeRelativeUri(file.SnapshotQualifiedUri).ToString(); + } + + CloudFileDirectory dir = item as CloudFileDirectory; + if (dir != null) + { + return shareUri.Uri.MakeRelativeUri(dir.SnapshotQualifiedUri).ToString(); + } + return shareUri.Uri.MakeRelativeUri(item.Uri).ToString(); } diff --git a/src/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.format.ps1xml b/src/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.format.ps1xml index d36cfe7a9a82..30ef63b4ec3a 100644 --- a/src/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.format.ps1xml +++ b/src/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.format.ps1xml @@ -21,6 +21,14 @@ Left + + + Left + + + + Left + @@ -31,6 +39,12 @@ $_.Properties.LastModified + + $_.IsSnapshot + + + $_.SnapshotTime + @@ -43,7 +57,7 @@ Microsoft.WindowsAzure.Storage.File.CloudFileDirectory - $_.Parent.Uri + $_.Parent.SnapshotQualifiedUri diff --git a/src/Storage/Commands.Storage/Model/Contract/IStorageFileManagement.cs b/src/Storage/Commands.Storage/Model/Contract/IStorageFileManagement.cs index 3c0b9026c6dd..22d81f85b4ae 100644 --- a/src/Storage/Commands.Storage/Model/Contract/IStorageFileManagement.cs +++ b/src/Storage/Commands.Storage/Model/Contract/IStorageFileManagement.cs @@ -31,7 +31,7 @@ public interface IStorageFileManagement : IStorageManagement /// /// A string containing the name of the share. /// A reference to a share. - CloudFileShare GetShareReference(string shareName); + CloudFileShare GetShareReference(string shareName, DateTimeOffset? snapshotTime = null); /// /// Get share permissions. @@ -329,7 +329,7 @@ public interface IStorageFileManagement : IStorageManagement /// /// A System.Threading.Tasks.Task object that represents the current operation. /// - Task DeleteShareAsync(CloudFileShare share, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken); + Task DeleteShareAsync(CloudFileShare share, DeleteShareSnapshotsOption deleteShareSnapshotsOption, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken); /// /// Returns a task that performs an asynchronous operation to delete a file. diff --git a/src/Storage/Commands.Storage/Model/Contract/StorageFileManagement.cs b/src/Storage/Commands.Storage/Model/Contract/StorageFileManagement.cs index 6b986caebcbb..e590e5954429 100644 --- a/src/Storage/Commands.Storage/Model/Contract/StorageFileManagement.cs +++ b/src/Storage/Commands.Storage/Model/Contract/StorageFileManagement.cs @@ -59,9 +59,9 @@ private CloudFileClient Client } } - public CloudFileShare GetShareReference(string shareName) + public CloudFileShare GetShareReference(string shareName, DateTimeOffset? snapshotTime = null) { - return this.Client.GetShareReference(shareName); + return this.Client.GetShareReference(shareName, snapshotTime); } public void FetchShareAttributes(CloudFileShare share, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) @@ -136,9 +136,9 @@ public Task DeleteDirectoryAsync(CloudFileDirectory directory, AccessCondition a return directory.DeleteAsync(accessCondition, options, operationContext, cancellationToken); } - public Task DeleteShareAsync(CloudFileShare share, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) + public Task DeleteShareAsync(CloudFileShare share, DeleteShareSnapshotsOption deleteShareSnapshotsOption, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) { - return share.DeleteAsync(accessCondition, options, operationContext, cancellationToken); + return share.DeleteAsync(deleteShareSnapshotsOption, accessCondition, options, operationContext, cancellationToken); } public Task DeleteFileAsync(CloudFile file, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext, CancellationToken cancellationToken) diff --git a/src/Storage/Commands.Storage/help/Get-AzureStorageShare.md b/src/Storage/Commands.Storage/help/Get-AzureStorageShare.md index 7ea8882b09e6..66961bd3cab1 100644 --- a/src/Storage/Commands.Storage/help/Get-AzureStorageShare.md +++ b/src/Storage/Commands.Storage/help/Get-AzureStorageShare.md @@ -20,8 +20,9 @@ Get-AzureStorageShare [[-Prefix] ] [-Context ] [-Server ### Specific ``` -Get-AzureStorageShare [-Name] [-Context ] [-ServerTimeoutPerRequest ] - [-ClientTimeoutPerRequest ] [-ConcurrentTaskCount ] [] +Get-AzureStorageShare [-Name] [-SnapshotTime ] [-Context ] + [-ServerTimeoutPerRequest ] [-ClientTimeoutPerRequest ] [-ConcurrentTaskCount ] + [] ``` ## DESCRIPTION @@ -53,6 +54,13 @@ The first command uses the **New-AzureStorageContext** cmdlet to create a contex The second command gets the file shares for the context object stored in $Context. +### Example 4: Get a file share snapshot with specific share name and SnapshotTime +``` +PS C:\>Get-AzureStorageShare -Name "ContosoShare06" -SnapshotTime "6/16/2017 9:48:41 AM +00:00" +``` + +This command gets a file share snapshot with specific share name and SnapshotTime. + ## PARAMETERS ### -ClientTimeoutPerRequest @@ -154,6 +162,21 @@ Accept pipeline input: False Accept wildcard characters: False ``` +### -SnapshotTime +SnapshotTime of the file share snapshot to be received. + +```yaml +Type: DateTimeOffset +Parameter Sets: Specific +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + ### CommonParameters This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216). diff --git a/src/Storage/Commands.Storage/help/Remove-AzureStorageShare.md b/src/Storage/Commands.Storage/help/Remove-AzureStorageShare.md index f1275d1a1204..e8b14992c0b6 100644 --- a/src/Storage/Commands.Storage/help/Remove-AzureStorageShare.md +++ b/src/Storage/Commands.Storage/help/Remove-AzureStorageShare.md @@ -14,15 +14,16 @@ Deletes a file share. ### ShareName (Default) ``` -Remove-AzureStorageShare [-Name] [-Force] [-PassThru] [-Context ] - [-ServerTimeoutPerRequest ] [-ClientTimeoutPerRequest ] [-ConcurrentTaskCount ] [-WhatIf] - [-Confirm] [] +Remove-AzureStorageShare [-Name] [-IncludeAllSnapshot] [-Force] [-PassThru] + [-Context ] [-ServerTimeoutPerRequest ] [-ClientTimeoutPerRequest ] + [-ConcurrentTaskCount ] [-WhatIf] [-Confirm] [] ``` ### Share ``` -Remove-AzureStorageShare [-Share] [-Force] [-PassThru] [-ServerTimeoutPerRequest ] - [-ClientTimeoutPerRequest ] [-ConcurrentTaskCount ] [-WhatIf] [-Confirm] [] +Remove-AzureStorageShare [-Share] [-IncludeAllSnapshot] [-Force] [-PassThru] + [-ServerTimeoutPerRequest ] [-ClientTimeoutPerRequest ] [-ConcurrentTaskCount ] [-WhatIf] + [-Confirm] [] ``` ## DESCRIPTION @@ -37,6 +38,13 @@ PS C:\>Remove-AzureStorageShare -Name "ContosoShare06" This command removes the file share named ContosoShare06. +### Example 2: Remove a file share and all its snapshots +``` +PS C:\>Remove-AzureStorageShare -Name "ContosoShare06" -IncludeAllSnapshot +``` + +This command removes the file share named ContosoShare06 and all its snapshots. + ## PARAMETERS ### -ClientTimeoutPerRequest @@ -92,7 +100,22 @@ Accept wildcard characters: False ``` ### -Force -Force to remove the share and all content in it +Force to remove the share with all of its snapshots, and all content. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -IncludeAllSnapshot +Remove File Share with all of its snapshots ```yaml Type: SwitchParameter diff --git a/src/Storage/Commands.Storage/packages.config b/src/Storage/Commands.Storage/packages.config index dd6f6d5926f3..5bff455af48b 100644 --- a/src/Storage/Commands.Storage/packages.config +++ b/src/Storage/Commands.Storage/packages.config @@ -1,10 +1,15 @@  - + + + + + + - + \ No newline at end of file