Skip to content

Fix bugs in RM storage management cmdlets #1016

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

Merged
merged 16 commits into from
Sep 30, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
93c7cd0
Update xscl in Commands.Common
EmmaZhu Aug 11, 2015
9604d99
Revert "Update xscl in Commands.Common"
EmmaZhu Aug 13, 2015
df5b5fd
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
EmmaZhu Aug 17, 2015
803e02d
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
EmmaZhu Aug 25, 2015
f4d6c30
PSH:[4586026] Add functionality to create a storage account with tags.
EmmaZhu Sep 1, 2015
bbc7418
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
EmmaZhu Sep 6, 2015
5579705
To make CustomDomainName parameter in Set-AzureStorageAccount accept …
EmmaZhu Sep 10, 2015
3c28707
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
EmmaZhu Sep 14, 2015
93dc218
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
EmmaZhu Sep 17, 2015
0c44c8d
[PSH]Change cmdlet names back to remove RM from them.
EmmaZhu Sep 18, 2015
49b5c26
Merge branch 'dev' of https://github.com/Azure/azure-powershell into …
EmmaZhu Sep 21, 2015
f3335ce
Remove types defininations in storage types for they have been define…
EmmaZhu Sep 21, 2015
769fd1a
Merge branch 'sprint54' of https://github.com/wastoresh/azure-powersh…
EmmaZhu Sep 21, 2015
bd0ffbf
Fix issues that the Context is null even when it's indicated in param…
EmmaZhu Sep 22, 2015
a5b14f2
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
EmmaZhu Sep 24, 2015
a288823
Merge branch 'dev' of https://github.com/Azure/azure-powershell into dev
EmmaZhu Sep 30, 2015
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
56 changes: 56 additions & 0 deletions setup/azurecmdfiles.wxi

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public string SrcContainer
[Parameter(HelpMessage = "Source Azure Storage Context Object", ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, ParameterSetName = FileParameterSet)]
[Parameter(HelpMessage = "Source Azure Storage Context Object", ValueFromPipeline = true, ValueFromPipelineByPropertyName = true, ParameterSetName = FileToBlobParameterSet)]
[Parameter(HelpMessage = "Source Azure Storage Context Object", ParameterSetName = UriParameterSet)]
public new AzureStorageContext Context { get; set; }
public override AzureStorageContext Context { get; set; }

[Parameter(HelpMessage = "Destination Storage context object", Mandatory = false)]
public AzureStorageContext DestContext { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public class StorageCloudCmdletBase<T> : CloudBaseCmdlet<T>
{
[Parameter(HelpMessage = "Azure Storage Context Object",
ValueFromPipelineByPropertyName = true)]
public AzureStorageContext Context { get; set; }
public virtual AzureStorageContext Context { get; set; }

[Parameter(HelpMessage = "The server time out for each request in seconds.")]
public virtual int? ServerTimeoutPerRequest { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public abstract class AzureStorageFileCmdletBase : StorageCloudCmdletBase<IStora
ValueFromPipeline = true,
ParameterSetName = Constants.SpecificParameterSetName,
HelpMessage = "Azure Storage Context Object")]
public new AzureStorageContext Context { get; set; }
public override AzureStorageContext Context { get; set; }

protected FileRequestOptions RequestOptions
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public string Policy
ValueFromPipeline = true,
HelpMessage = "Azure Storage Context Object",
ParameterSetName = NameSasPolicyParmeterSet)]
public new AzureStorageContext Context { get; set; }
public override AzureStorageContext Context { get; set; }

/// <summary>
/// Execute command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public string Policy
[Parameter(
ValueFromPipeline = true,
HelpMessage = "Azure Storage Context Object")]
public new AzureStorageContext Context { get; set; }
public override AzureStorageContext Context { get; set; }

// Overwrite the useless parameter
public override int? ServerTimeoutPerRequest { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public class StartAzureStorageFileCopyCommand : StorageFileDataManagementCmdletB
Mandatory = false,
ValueFromPipelineByPropertyName = true,
ParameterSetName = ShareNameParameterSet)]
public new AzureStorageContext Context { get; set; }
public override AzureStorageContext Context { get; set; }

[Parameter(HelpMessage = "Destination Storage context object", ParameterSetName = ContainerNameParameterSet)]
[Parameter(HelpMessage = "Destination Storage context object", ParameterSetName = ContainerParameterSet)]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,3 @@
<?xml version="1.0" encoding="utf-8" ?>
<Types>
<Type>
<Name>Microsoft.WindowsAzure.Storage.File.CloudFile</Name>
<Members>
<ScriptProperty>
<Name>DirectoryTag</Name>
<GetScriptBlock>[string]::Empty</GetScriptBlock>
</ScriptProperty>
<ScriptProperty>
<Name>IsDirectory</Name>
<GetScriptBlock>$false</GetScriptBlock>
</ScriptProperty>
<ScriptProperty>
<Name>Length</Name>
<GetScriptBlock>$_.Properties.Length</GetScriptBlock>
</ScriptProperty>
</Members>
</Type>
<Type>
<Name>Microsoft.WindowsAzure.Storage.File.CloudFileDirectory</Name>
<Members>
<ScriptProperty>
<Name>DirectoryTag</Name>
<GetScriptBlock>"DIR"</GetScriptBlock>
</ScriptProperty>
<ScriptProperty>
<Name>IsDirectory</Name>
<GetScriptBlock>$true</GetScriptBlock>
</ScriptProperty>
<ScriptProperty>
<Name>Length</Name>
<GetScriptBlock>[string]::Empty</GetScriptBlock>
</ScriptProperty>
</Members>
</Type>
</Types>
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
<maml:paragraph>PS C:\&gt;</maml:paragraph>
</maml:introduction>
<dev:code>PS C:\&gt; #Get one storage account
Get-AzureRmStorageAccount -ResourceGroupName &quot;RG1&quot; -AccountName &quot;myStorageAccount&quot;</dev:code>
Get-AzureRmStorageAccount -ResourceGroupName &quot;rg1&quot; -AccountName &quot;mystorageaccount&quot;</dev:code>
<dev:remarks>
<maml:para />
<maml:para />
Expand Down Expand Up @@ -304,7 +304,7 @@
<maml:paragraph>PS C:\&gt;</maml:paragraph>
</maml:introduction>
<dev:code>#Get keys
Get-AzureRmStorageAccountKey -ResourceGroupName &quot;RG1&quot; -AccountName &quot;myStorageAccount&quot;</dev:code>
Get-AzureRmStorageAccountKey -ResourceGroupName &quot;rg1&quot; -AccountName &quot;mystorageaccount&quot;</dev:code>
<dev:remarks>
<maml:para />
<maml:para />
Expand Down Expand Up @@ -375,6 +375,13 @@
</maml:description>
<command:parameterValue required="true" variableLength="false">String</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="4">
<maml:name>Tags</maml:name>
<maml:description>
<maml:para>Tags to set on the storage account.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Hashtable[]</command:parameterValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Profile</maml:name>
<maml:description>
Expand Down Expand Up @@ -437,6 +444,18 @@
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="4">
<maml:name>Tags</maml:name>
<maml:description>
<maml:para>Tags to set on the storage account.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Hashtable[]</command:parameterValue>
<dev:type>
<maml:name>Hashtable[]</maml:name>
<maml:uri/>
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="false" position="named">
<maml:name>Profile</maml:name>
<maml:description>
Expand Down Expand Up @@ -490,7 +509,7 @@
<maml:introduction>
<maml:paragraph>PS C:\&gt;</maml:paragraph>
</maml:introduction>
<dev:code>New-AzureRmStorageAccount -ResourceGroupName &quot;myResourceGroup&quot; -AccountName &quot;myStorageAccount&quot; -Location &quot;US West&quot; -Type &quot;Standard_GRS&quot;</dev:code>
<dev:code>New-AzureRmStorageAccount -ResourceGroupName &quot;myresourcegroup&quot; -AccountName &quot;mystorageaccount&quot; -Location &quot;US West&quot; -Type &quot;Standard_GRS&quot;</dev:code>
<dev:remarks>
<maml:para />
<maml:para />
Expand Down Expand Up @@ -654,7 +673,7 @@
<maml:paragraph>PS C:\&gt;</maml:paragraph>
</maml:introduction>
<dev:code>#Regenerate a key
New-AzureRmStorageKey -ResourceGroupName &quot;myResourceGroup&quot; -AccountName &quot;myStorageAccount&quot; -keyName &quot;key1&quot;</dev:code>
New-AzureRmStorageKey -ResourceGroupName &quot;myresourcegroup&quot; -AccountName &quot;mystorageaccount&quot; -keyName &quot;key1&quot;</dev:code>
<dev:remarks>
<maml:para />
<maml:para />
Expand Down Expand Up @@ -794,7 +813,7 @@ New-AzureRmStorageKey -ResourceGroupName &quot;myResourceGroup&quot; -AccountNam
<maml:introduction>
<maml:paragraph>PS C:\&gt;</maml:paragraph>
</maml:introduction>
<dev:code>PS C:\&gt; Remove-AzureRmStorageAccount -ResourceGroupName &quot;RG1&quot; -AccountName &quot;myStorageAccount&quot;</dev:code>
<dev:code>PS C:\&gt; Remove-AzureRmStorageAccount -ResourceGroupName &quot;rg1&quot; -AccountName &quot;mystorageaccount&quot;</dev:code>
<dev:remarks>
<maml:para />
<maml:para />
Expand Down Expand Up @@ -894,7 +913,7 @@ New-AzureRmStorageKey -ResourceGroupName &quot;myResourceGroup&quot; -AccountNam
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="3">
<maml:name>UseSubDomain</maml:name>
<maml:description>
<maml:para />
<maml:para>Indicates whether indirect CName validation is enabled.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Nullable`1[Boolean]</command:parameterValue>
</command:parameter>
Expand Down Expand Up @@ -925,7 +944,7 @@ New-AzureRmStorageKey -ResourceGroupName &quot;myResourceGroup&quot; -AccountNam
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="2">
<maml:name>Tags</maml:name>
<maml:description>
<maml:para />
<maml:para>Tags to set on the storage account.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Hashtable[]</command:parameterValue>
</command:parameter>
Expand Down Expand Up @@ -1008,7 +1027,7 @@ New-AzureRmStorageKey -ResourceGroupName &quot;myResourceGroup&quot; -AccountNam
<command:parameter required="false" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="3">
<maml:name>UseSubDomain</maml:name>
<maml:description>
<maml:para />
<maml:para>Indicates whether indirect CName validation is enabled.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Nullable`1[Boolean]</command:parameterValue>
<dev:type>
Expand All @@ -1020,7 +1039,7 @@ New-AzureRmStorageKey -ResourceGroupName &quot;myResourceGroup&quot; -AccountNam
<command:parameter required="true" variableLength="true" globbing="false" pipelineInput="true (ByPropertyName)" position="2">
<maml:name>Tags</maml:name>
<maml:description>
<maml:para />
<maml:para>Tags to set on the storage account.</maml:para>
</maml:description>
<command:parameterValue required="true" variableLength="true">Hashtable[]</command:parameterValue>
<dev:type>
Expand All @@ -1029,18 +1048,6 @@ New-AzureRmStorageKey -ResourceGroupName &quot;myResourceGroup&quot; -AccountNam
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
<command:parameter required="false" variableLength="false" globbing="false" pipelineInput="true (ByValue, ByPropertyName)" position="3">
<maml:name>UseSubDomainName</maml:name>
<maml:description>
<maml:para />
</maml:description>
<command:parameterValue required="true" variableLength="false">nullable`1[boolean]</command:parameterValue>
<dev:type>
<maml:name>nullable`1[boolean]</maml:name>
<maml:uri/>
</dev:type>
<dev:defaultValue></dev:defaultValue>
</command:parameter>
</command:parameters>
<command:inputTypes>
<command:inputType>
Expand Down Expand Up @@ -1083,7 +1090,7 @@ New-AzureRmStorageKey -ResourceGroupName &quot;myResourceGroup&quot; -AccountNam
<maml:paragraph>PS C:\&gt;</maml:paragraph>
</maml:introduction>
<dev:code>PS C:\&gt; # Set account type
Set-AzureRmStorageAccount -ResourceGroupName &quot;myResourceGroup&quot; -AccountName &quot;myStorageAccount&quot; -Type &quot;Standard_RAGRS&quot;</dev:code>
Set-AzureRmStorageAccount -ResourceGroupName &quot;myresourcegroup&quot; -AccountName &quot;mystorageaccount&quot; -Type &quot;Standard_RAGRS&quot;</dev:code>
<dev:remarks>
<maml:para />
<maml:para />
Expand All @@ -1104,7 +1111,7 @@ New-AzureRmStorageKey -ResourceGroupName &quot;myResourceGroup&quot; -AccountNam
<maml:paragraph>PS C:\&gt;</maml:paragraph>
</maml:introduction>
<dev:code>PS C:\&gt; #Set custom domain
Set-AzureRmStorageAccount -ResourceGroupName &quot;myResourceGroup&quot; -AccountName &quot;myStorageAccount&quot; -CustomDomainName &quot;domain name&quot; –UseSubDomain true</dev:code>
Set-AzureRmStorageAccount -ResourceGroupName &quot;myresourcegroup&quot; -AccountName &quot;mystorageaccount&quot; -CustomDomainName &quot;www.domainname.com&quot; –UseSubDomain $true</dev:code>
<dev:remarks>
<maml:para />
<maml:para />
Expand All @@ -1123,4 +1130,4 @@ New-AzureRmStorageKey -ResourceGroupName &quot;myResourceGroup&quot; -AccountNam
<maml:relatedLinks>
</maml:relatedLinks>
</command:command>
</helpItems>
</helpItems>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System.Collections;
using System.Management.Automation;
using Microsoft.Azure.Commands.Tags.Model;
using Microsoft.Azure.Management.Storage;
using Microsoft.Azure.Management.Storage.Models;

Expand Down Expand Up @@ -60,14 +62,23 @@ public class NewAzureStorageAccountCommand : StorageAccountBaseCmdlet
[ValidateNotNullOrEmpty]
public string Location { get; set; }

[Parameter(
Position = 4,
Mandatory = false,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Storage Account Tags.")]
[ValidateNotNull]
public Hashtable[] Tags { get; set; }

protected override void ProcessRecord()
{
base.ProcessRecord();

StorageAccountCreateParameters createParameters = new StorageAccountCreateParameters()
{
Location = this.Location,
AccountType = ParseAccountType(this.Type)
AccountType = ParseAccountType(this.Type),
Tags = TagsConversionHelper.CreateTagDictionary(Tags, validate: true)
};

var createAccountResponse = this.StorageClient.StorageAccounts.Create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ public class SetAzureStorageAccountCommand : StorageAccountBaseCmdlet
ParameterSetName = UpdateCustomDomainParamSet,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Storage Account Custom Domain Name.")]
[ValidateNotNullOrEmpty]
[AllowEmptyString]
[ValidateNotNull]
public string CustomDomainName { get; set; }

[Parameter(
Expand All @@ -86,7 +87,8 @@ public class SetAzureStorageAccountCommand : StorageAccountBaseCmdlet
ParameterSetName = UpdateTagsParamSet,
ValueFromPipelineByPropertyName = true,
HelpMessage = "Storage Account Tags.")]
[ValidateNotNullOrEmpty]
[AllowEmptyCollection]
[ValidateNotNull]
public Hashtable[] Tags { get; set; }

protected override void ProcessRecord()
Expand Down Expand Up @@ -120,7 +122,7 @@ protected override void ProcessRecord()

updateParameters = new StorageAccountUpdateParameters
{
Tags = tagDictionary
Tags = tagDictionary ?? new Dictionary<string, string>()
};
}

Expand Down