From 1f40993063f040cf5da069fe59da7b8eb1382134 Mon Sep 17 00:00:00 2001 From: "Jerry (Zhenyu) Dai" Date: Tue, 11 Nov 2014 15:16:32 +0800 Subject: [PATCH 1/5] Bug1730534 [PowerShell for XSMB] enable accepting objects from pipeline to enable multi-task in File cmdlets --- .../Commands.Storage/File/Cmdlet/NewAzureStorageDirectory.cs | 1 + .../Commands.Storage/File/Cmdlet/NewAzureStorageShare.cs | 1 + .../Commands.Storage/File/Cmdlet/RemoveAzureStorageDirectory.cs | 1 + .../Commands.Storage/File/Cmdlet/RemoveAzureStorageShare.cs | 1 + .../Commands.Storage/File/Cmdlet/SetAzureStorageFileContent.cs | 2 ++ 5 files changed, 6 insertions(+) diff --git a/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageDirectory.cs b/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageDirectory.cs index 5c33be8d398f..2497168bddf5 100644 --- a/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageDirectory.cs +++ b/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageDirectory.cs @@ -50,6 +50,7 @@ public class NewAzureStorageDirectory : AzureStorageFileCmdletBase [Parameter( Position = 1, Mandatory = true, + ValueFromPipeline = true, HelpMessage = "Path of the directory to be created.")] [ValidateNotNullOrEmpty] public string Path { get; set; } diff --git a/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageShare.cs b/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageShare.cs index 43b658ddd229..f932ee115ea5 100644 --- a/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageShare.cs +++ b/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/NewAzureStorageShare.cs @@ -22,6 +22,7 @@ public class NewAzureStorageShare : AzureStorageFileCmdletBase [Parameter( Position = 0, Mandatory = true, + ValueFromPipeline = true, HelpMessage = "Name of the file share to be created.")] [ValidateNotNullOrEmpty] public string Name { get; set; } diff --git a/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/RemoveAzureStorageDirectory.cs b/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/RemoveAzureStorageDirectory.cs index d3905c228c3e..0e56d2600e02 100644 --- a/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/RemoveAzureStorageDirectory.cs +++ b/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/RemoveAzureStorageDirectory.cs @@ -64,6 +64,7 @@ public class RemoveAzureStorageDirectory : AzureStorageFileCmdletBase HelpMessage = "Path to the directory to be removed.")] [Parameter( Position = 1, + ValueFromPipeline = true, ParameterSetName = Constants.DirectoryParameterSetName, HelpMessage = "Path to the directory to be removed.")] [ValidateNotNullOrEmpty] diff --git a/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/RemoveAzureStorageShare.cs b/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/RemoveAzureStorageShare.cs index d9e46a61c4e7..eab3e00f0bb4 100644 --- a/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/RemoveAzureStorageShare.cs +++ b/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/RemoveAzureStorageShare.cs @@ -29,6 +29,7 @@ public class RemoveAzureStorageShare : AzureStorageFileCmdletBase [Parameter( Position = 0, Mandatory = true, + ValueFromPipeline = true, ParameterSetName = Constants.ShareNameParameterSetName, HelpMessage = "Name of the file share to be removed.")] [ValidateNotNullOrEmpty] diff --git a/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/SetAzureStorageFileContent.cs b/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/SetAzureStorageFileContent.cs index 1e992e04a0dc..545d610be675 100644 --- a/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/SetAzureStorageFileContent.cs +++ b/src/ServiceManagement/Storage/Commands.Storage/File/Cmdlet/SetAzureStorageFileContent.cs @@ -52,9 +52,11 @@ public class SetAzureStorageFileContent : StorageFileDataManagementCmdletBase [ValidateNotNull] public CloudFileDirectory Directory { get; set; } + [Alias("FullName")] [Parameter( Position = 1, Mandatory = true, + ValueFromPipelineByPropertyName = true, HelpMessage = "Path to the local file to be uploaded.")] [ValidateNotNullOrEmpty] public string Source { get; set; } From 1ff444e4112ab0467f9a28f71aaa65ad1a574cb9 Mon Sep 17 00:00:00 2001 From: "Jerry (Zhenyu) Dai" Date: Fri, 21 Nov 2014 15:25:20 +0800 Subject: [PATCH 2/5] [PowerShell] 3 P1 bug fix --- .../Common/Cmdlet/NewAzureStorageContext.cs | 10 ++++++- ...WindowsAzure.Commands.Storage.dll-Help.xml | 30 ++++++++++++------- .../Commands.Storage/Resources.Designer.cs | 9 ++++++ .../Storage/Commands.Storage/Resources.resx | 4 +++ 4 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/ServiceManagement/Storage/Commands.Storage/Common/Cmdlet/NewAzureStorageContext.cs b/src/ServiceManagement/Storage/Commands.Storage/Common/Cmdlet/NewAzureStorageContext.cs index afdc47e4df63..7ce3b3226ab9 100644 --- a/src/ServiceManagement/Storage/Commands.Storage/Common/Cmdlet/NewAzureStorageContext.cs +++ b/src/ServiceManagement/Storage/Commands.Storage/Common/Cmdlet/NewAzureStorageContext.cs @@ -13,6 +13,7 @@ // ---------------------------------------------------------------------------------- using System; +using System.Globalization; using System.Management.Automation; using System.Security.Permissions; using Microsoft.WindowsAzure.Commands.Common; @@ -346,7 +347,14 @@ internal CloudStorageAccount GetStorageAccountWithAzureEnvironment(StorageCreden } else { - azureEnvironment = DefaultProfileClient.GetEnvironmentOrDefault(azureEnvironmentName); + try + { + azureEnvironment = DefaultProfileClient.GetEnvironmentOrDefault(azureEnvironmentName); + } + catch (ArgumentException e) + { + throw new ArgumentException(e.Message + String.Format(CultureInfo.CurrentCulture, Resources.ValidEnvironmentName, EnvironmentName.AzureCloud, EnvironmentName.AzureChinaCloud)); + } } Uri blobEndPoint = azureEnvironment.GetStorageBlobEndpoint(storageAccountName, useHttps); diff --git a/src/ServiceManagement/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.dll-Help.xml b/src/ServiceManagement/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.dll-Help.xml index 1d36c9737074..408a13b50e08 100644 --- a/src/ServiceManagement/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.dll-Help.xml +++ b/src/ServiceManagement/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.dll-Help.xml @@ -2643,7 +2643,7 @@ echo "Total $total containers" - PS C:\> Get-AzureStorageFileContent -FileShareName sample -FilePath sampledir/samplefile + PS C:\> Get-AzureStorageFileContent -ShareName sample -FilePath sampledir/samplefile This example downloads the file whose path is sampledir/samplefile in the sample file share. @@ -3039,6 +3039,9 @@ echo "Total $total containers" + + http://msdn.microsoft.com/en-us/library/azure/gg433048.aspx + @@ -3209,6 +3212,9 @@ echo "Total $total containers" + + http://msdn.microsoft.com/en-us/library/azure/hh343258.aspx + @@ -4125,8 +4131,7 @@ New-AzureStorageBlobSASToken -Container cname -Blob bname -Permission rwd -Start - http://msdn.microsoft.com/en-us/library/windowsazure/dn140255.aspx - + http://msdn.microsoft.com/en-us/library/windowsazure/dn140255.aspx @@ -4649,8 +4654,7 @@ New-AzureStorageBlobSASToken -Container cname -Blob bname -Permission rwd -Start - http://msdn.microsoft.com/en-us/library/windowsazure/dn140255.aspx - + http://msdn.microsoft.com/en-us/library/windowsazure/dn140255.aspx @@ -4956,7 +4960,7 @@ New-AzureStorageBlobSASToken -Container cname -Blob bname -Permission rwd -Start String - + AzureCloud | AzureChinaCloud ConnectionString @@ -6041,8 +6045,7 @@ $context | Get-AzureStorageBlob -Container abc - http://msdn.microsoft.com/en-us/library/windowsazure/dn140255.aspx - + http://msdn.microsoft.com/en-us/library/windowsazure/dn140255.aspx @@ -6893,8 +6896,7 @@ $context | Get-AzureStorageBlob -Container abc - http://msdn.microsoft.com/en-us/library/windowsazure/dn140255.aspx - + http://msdn.microsoft.com/en-us/library/windowsazure/dn140255.aspx @@ -9482,7 +9484,7 @@ $context | Get-AzureStorageBlob -Container abc Name - + The name of the table to be removed. String @@ -11368,6 +11370,9 @@ Set-AzureStorageBlobContent -File filename -Container containername -Metadata $m + + http://msdn.microsoft.com/en-us/library/azure/gg433048.aspx + @@ -11614,6 +11619,9 @@ Set-AzureStorageBlobContent -File filename -Container containername -Metadata $m + + http://msdn.microsoft.com/en-us/library/azure/hh343258.aspx + diff --git a/src/ServiceManagement/Storage/Commands.Storage/Resources.Designer.cs b/src/ServiceManagement/Storage/Commands.Storage/Resources.Designer.cs index 6b771c0a10a0..54664d9182dc 100644 --- a/src/ServiceManagement/Storage/Commands.Storage/Resources.Designer.cs +++ b/src/ServiceManagement/Storage/Commands.Storage/Resources.Designer.cs @@ -1459,6 +1459,15 @@ internal static string UseStorageAccountFromContext { } } + /// + /// Looks up a localized string similar to Valid environment names are: '{0}' and '{1}'. + /// + internal static string ValidEnvironmentName { + get { + return ResourceManager.GetString("ValidEnvironmentName", resourceCulture); + } + } + /// /// Looks up a localized string similar to {0} {1}.. /// diff --git a/src/ServiceManagement/Storage/Commands.Storage/Resources.resx b/src/ServiceManagement/Storage/Commands.Storage/Resources.resx index 0e11042c4d4f..d7e24e14b87b 100644 --- a/src/ServiceManagement/Storage/Commands.Storage/Resources.resx +++ b/src/ServiceManagement/Storage/Commands.Storage/Resources.resx @@ -661,4 +661,8 @@ Failed: {2}. Transmit cancelled by user. + + Valid environment names are: '{0}' and '{1}' + 0 and 1 are for the correct Environment names + \ No newline at end of file From dec32f0eb47b98c118aab8b455587ea7522460c8 Mon Sep 17 00:00:00 2001 From: "Jerry (Zhenyu) Dai" Date: Mon, 24 Nov 2014 14:20:22 +0800 Subject: [PATCH 3/5] minor help content fix --- .../Commands.Storage/Common/Cmdlet/NewAzureStorageContext.cs | 2 +- .../Microsoft.WindowsAzure.Commands.Storage.dll-Help.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ServiceManagement/Storage/Commands.Storage/Common/Cmdlet/NewAzureStorageContext.cs b/src/ServiceManagement/Storage/Commands.Storage/Common/Cmdlet/NewAzureStorageContext.cs index 7ce3b3226ab9..6630ab724116 100644 --- a/src/ServiceManagement/Storage/Commands.Storage/Common/Cmdlet/NewAzureStorageContext.cs +++ b/src/ServiceManagement/Storage/Commands.Storage/Common/Cmdlet/NewAzureStorageContext.cs @@ -353,7 +353,7 @@ internal CloudStorageAccount GetStorageAccountWithAzureEnvironment(StorageCreden } catch (ArgumentException e) { - throw new ArgumentException(e.Message + String.Format(CultureInfo.CurrentCulture, Resources.ValidEnvironmentName, EnvironmentName.AzureCloud, EnvironmentName.AzureChinaCloud)); + throw new ArgumentException(e.Message + " " + String.Format(CultureInfo.CurrentCulture, Resources.ValidEnvironmentName, EnvironmentName.AzureCloud, EnvironmentName.AzureChinaCloud)); } } diff --git a/src/ServiceManagement/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.dll-Help.xml b/src/ServiceManagement/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.dll-Help.xml index 408a13b50e08..d9c467ceba4b 100644 --- a/src/ServiceManagement/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.dll-Help.xml +++ b/src/ServiceManagement/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.dll-Help.xml @@ -9529,7 +9529,7 @@ $context | Get-AzureStorageBlob -Container abc Name - + The name of the table to be removed. String From 2ff9ce1121793cbe38201c8c24f57d3f23f527c9 Mon Sep 17 00:00:00 2001 From: "Jerry (Zhenyu) Dai" Date: Mon, 24 Nov 2014 16:48:14 +0800 Subject: [PATCH 4/5] add online links for some Cmdlets --- ...ft.WindowsAzure.Commands.Storage.dll-Help.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/ServiceManagement/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.dll-Help.xml b/src/ServiceManagement/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.dll-Help.xml index d9c467ceba4b..c57a26264ae2 100644 --- a/src/ServiceManagement/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.dll-Help.xml +++ b/src/ServiceManagement/Storage/Commands.Storage/Microsoft.WindowsAzure.Commands.Storage.dll-Help.xml @@ -3040,7 +3040,7 @@ echo "Total $total containers" - http://msdn.microsoft.com/en-us/library/azure/gg433048.aspx + http://msdn.microsoft.com/en-us/library/dn806375.aspx @@ -3213,7 +3213,7 @@ echo "Total $total containers" - http://msdn.microsoft.com/en-us/library/azure/hh343258.aspx + http://msdn.microsoft.com/en-us/library/dn806390.aspx @@ -4131,7 +4131,7 @@ New-AzureStorageBlobSASToken -Container cname -Blob bname -Permission rwd -Start - http://msdn.microsoft.com/en-us/library/windowsazure/dn140255.aspx + http://msdn.microsoft.com/en-us/library/dn806412.aspx @@ -4654,7 +4654,7 @@ New-AzureStorageBlobSASToken -Container cname -Blob bname -Permission rwd -Start - http://msdn.microsoft.com/en-us/library/windowsazure/dn140255.aspx + http://msdn.microsoft.com/en-us/library/dn806416.aspx @@ -6045,7 +6045,7 @@ $context | Get-AzureStorageBlob -Container abc - http://msdn.microsoft.com/en-us/library/windowsazure/dn140255.aspx + http://msdn.microsoft.com/en-us/library/dn806410.aspx @@ -6896,7 +6896,7 @@ $context | Get-AzureStorageBlob -Container abc - http://msdn.microsoft.com/en-us/library/windowsazure/dn140255.aspx + http://msdn.microsoft.com/en-us/library/dn806400.aspx @@ -11371,7 +11371,7 @@ Set-AzureStorageBlobContent -File filename -Container containername -Metadata $m - http://msdn.microsoft.com/en-us/library/azure/gg433048.aspx + http://msdn.microsoft.com/en-us/library/dn806397.aspx @@ -11620,7 +11620,7 @@ Set-AzureStorageBlobContent -File filename -Container containername -Metadata $m - http://msdn.microsoft.com/en-us/library/azure/hh343258.aspx + http://msdn.microsoft.com/en-us/library/dn806391.aspx From 8ed741ea8cff1dc28971a4dd97e22497b1158af8 Mon Sep 17 00:00:00 2001 From: "Jerry (Zhenyu) Dai" Date: Wed, 26 Nov 2014 10:30:22 +0800 Subject: [PATCH 5/5] minor fix for uppercase to lowercase --- .../Commands.Storage/Common/Cmdlet/NewAzureStorageContext.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ServiceManagement/Storage/Commands.Storage/Common/Cmdlet/NewAzureStorageContext.cs b/src/ServiceManagement/Storage/Commands.Storage/Common/Cmdlet/NewAzureStorageContext.cs index 6630ab724116..843b572dbc50 100644 --- a/src/ServiceManagement/Storage/Commands.Storage/Common/Cmdlet/NewAzureStorageContext.cs +++ b/src/ServiceManagement/Storage/Commands.Storage/Common/Cmdlet/NewAzureStorageContext.cs @@ -353,7 +353,7 @@ internal CloudStorageAccount GetStorageAccountWithAzureEnvironment(StorageCreden } catch (ArgumentException e) { - throw new ArgumentException(e.Message + " " + String.Format(CultureInfo.CurrentCulture, Resources.ValidEnvironmentName, EnvironmentName.AzureCloud, EnvironmentName.AzureChinaCloud)); + throw new ArgumentException(e.Message + " " + string.Format(CultureInfo.CurrentCulture, Resources.ValidEnvironmentName, EnvironmentName.AzureCloud, EnvironmentName.AzureChinaCloud)); } }