Skip to content

Add -AsJob parameter to Storage cmdlets #5223

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 2 commits into from
Jan 5, 2018
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
4 changes: 3 additions & 1 deletion src/ResourceManager/Storage/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
- Set-AzureRmStorageAccount
* Added Location Completer to -Location parameters allowing tab completion through valid Locations
* Added ResourceGroup Completer to -ResourceGroup parameters allowing tab completion through resource groups in current subscription
* Added -AsJob support for long-running Storage cmdlets. Allows selected cmdlets to run in the background and return a job to track and control progress.
- Affected cmdlets are New-, Remove-, Add-, and Update- for Storage Account and Storage Account Network Rule.
## Version 4.0.1
* Fixed assembly loading issue that caused some cmdlets to fail when executing

Expand Down Expand Up @@ -80,4 +82,4 @@

## Version 2.4.0

## Version 2.3.0
## Version 2.3.0
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ function Test-StorageAccount

New-AzureRmResourceGroup -Name $rgname -Location $loc;

New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype -Kind $kind -AccessTier $accessTier -EnableEncryptionService $encryptionServiceBF;
$job = New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype -Kind $kind -AccessTier $accessTier -EnableEncryptionService $encryptionServiceBF -AsJob
$job | Wait-Job
$stos = Get-AzureRmStorageAccount -ResourceGroupName $rgname;

$stotype = 'StandardGRS';
Expand Down Expand Up @@ -565,22 +566,25 @@ function Test-NetworkRule
Assert-AreEqual $stoacl.IpRules[1].IPAddressOrRange $ip4;
Assert-AreEqual $stoacl.VirtualNetworkRules $null

Remove-AzureRmStorageAccountNetworkRule -ResourceGroupName $rgname -Name $stoname -IPAddressOrRange "$ip3"
$job = Remove-AzureRmStorageAccountNetworkRule -ResourceGroupName $rgname -Name $stoname -IPAddressOrRange "$ip3" -AsJob
$job | Wait-Job
$stoacl = Get-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname
Assert-AreEqual $stoacl.Bypass 6;
Assert-AreEqual $stoacl.DefaultAction Allow;
Assert-AreEqual $stoacl.IpRules.Count 1
Assert-AreEqual $stoacl.IpRules[0].IPAddressOrRange $ip4;
Assert-AreEqual $stoacl.VirtualNetworkRules $null

Update-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname -IpRule @() -DefaultAction Deny -Bypass None
$job = Update-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname -IpRule @() -DefaultAction Deny -Bypass None -AsJob
$job | Wait-Job
$stoacl = Get-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname
Assert-AreEqual $stoacl.Bypass 0;
Assert-AreEqual $stoacl.DefaultAction Deny;
Assert-AreEqual $stoacl.IpRules $null
Assert-AreEqual $stoacl.VirtualNetworkRules $null

$stoacliprule | Add-AzureRmStorageAccountNetworkRule -ResourceGroupName $rgname -Name $stoname
$job = $stoacliprule | Add-AzureRmStorageAccountNetworkRule -ResourceGroupName $rgname -Name $stoname -AsJob
$job | Wait-Job
$stoacl = Get-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname
Assert-AreEqual $stoacl.Bypass 0;
Assert-AreEqual $stoacl.DefaultAction Deny;
Expand All @@ -589,10 +593,11 @@ function Test-NetworkRule
Assert-AreEqual $stoacl.IpRules[1].IPAddressOrRange $ip4;
Assert-AreEqual $stoacl.VirtualNetworkRules $null

Set-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -NetworkRuleSet (@{bypass="AzureServices";
$job = Set-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -AsJob -NetworkRuleSet (@{bypass="AzureServices";
ipRules=(@{IPAddressOrRange="$ip1";Action="allow"},
@{IPAddressOrRange="$ip2";Action="allow"});
defaultAction="Allow"})
$job | Wait-Job

$stoacl = Get-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname
Assert-AreEqual $stoacl.Bypass 4;
Expand All @@ -602,7 +607,8 @@ function Test-NetworkRule
Assert-AreEqual $stoacl.IpRules[1].IPAddressOrRange $ip2;
Assert-AreEqual $stoacl.VirtualNetworkRules $null

Remove-AzureRmStorageAccount -Force -ResourceGroupName $rgname -Name $stoname;
$job = Remove-AzureRmStorageAccount -Force -ResourceGroupName $rgname -Name $stoname -AsJob
$job | Wait-Job
}
finally
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ public class AddAzureStorageAccountNetworkRuleCommand : StorageAccountBaseCmdlet
[Alias("SubnetId", "VirtualNetworkId")]
public string[] VirtualNetworkResourceId { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }


public override void ExecuteCmdlet()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ public PSNetworkRuleSet NetworkRuleSet
get; set;
}

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,18 @@ public class RemoveAzureStorageAccountCommand : StorageAccountBaseCmdlet
public string Name { get; set; }

[Parameter(HelpMessage = "Force to Delete the Storage Account")]
public SwitchParameter Force
{
get { return force; }
set { force = value; }
}
private bool force = false;
public SwitchParameter Force { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();

if (ShouldProcess(this.Name, "Remove Storage Account"))
{
if (this.force || ShouldContinue(string.Format("Remove Storage Account '{0}' and all content in it", this.Name), ""))
if (this.Force || ShouldContinue(string.Format("Remove Storage Account '{0}' and all content in it", this.Name), ""))
{
this.StorageClient.StorageAccounts.Delete(
this.ResourceGroupName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ public class RemoveAzureStorageAccountNetworkRuleCommand : StorageAccountBaseCmd
[Alias("SubnetId", "VirtualNetworkId")]
public string[] VirtualNetworkResourceId { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ public PSNetworkRuleSet NetworkRuleSet
HelpMessage = "Upgrade Storage Account Kind to StorageV2.")]
public SwitchParameter UpgradeToStorageV2 { get; set; }

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

public override void ExecuteCmdlet()
{
base.ExecuteCmdlet();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public PSVirtualNetworkRule[] VirtualNetworkRule
private bool isIpRuleSet = false;
private bool isNetworkRuleSet = false;

[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }


public override void ExecuteCmdlet()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,27 @@ schema: 2.0.0
### NetWorkRuleString (Default)
```
Add-AzureRmStorageAccountNetworkRule [-ResourceGroupName] <String> [-Name] <String>
-VirtualNetworkResourceId <String[]> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
-VirtualNetworkResourceId <String[]> [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

### IpRuleObject
```
Add-AzureRmStorageAccountNetworkRule [-ResourceGroupName] <String> [-Name] <String> -IPRule <PSIpRule[]>
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### NetworkRuleObject
```
Add-AzureRmStorageAccountNetworkRule [-ResourceGroupName] <String> [-Name] <String>
-VirtualNetworkRule <PSVirtualNetworkRule[]> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
-VirtualNetworkRule <PSVirtualNetworkRule[]> [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### IpRuleString
```
Add-AzureRmStorageAccountNetworkRule [-ResourceGroupName] <String> [-Name] <String>
-IPAddressOrRange <String[]> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
-IPAddressOrRange <String[]> [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

Expand Down Expand Up @@ -76,6 +76,21 @@ This command add several IpRule with IpRule objects, input with JSON.

## PARAMETERS

### -AsJob
Run cmdlet in the background

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -DefaultProfile
The credentials, account, tenant, and subscription used for communication with Azure.

Expand All @@ -97,7 +112,7 @@ The Array of IpAddressOrRange, add IpRules with the input IpAddressOrRange and d
```yaml
Type: String[]
Parameter Sets: IpRuleString
Aliases:
Aliases:

Required: True
Position: Named
Expand All @@ -112,7 +127,7 @@ The Array of IpRule objects to add to the NetworkRule Property.
```yaml
Type: PSIpRule[]
Parameter Sets: IpRuleObject
Aliases:
Aliases:

Required: True
Position: Named
Expand Down Expand Up @@ -142,7 +157,7 @@ Specifies the name of the resource group contains the Storage account.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Aliases:

Required: True
Position: 0
Expand Down Expand Up @@ -172,7 +187,7 @@ The Array of VirtualNetworkRule objects to add to the NetworkRule Property.
```yaml
Type: PSVirtualNetworkRule[]
Parameter Sets: NetworkRuleObject
Aliases:
Aliases:

Required: True
Position: Named
Expand Down Expand Up @@ -229,3 +244,4 @@ Microsoft.Azure.Commands.Management.Storage.Models.PSIpRule
## NOTES

## RELATED LINKS

Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Specifies the name of the resource group that contains the Storage account to ge
```yaml
Type: String
Parameter Sets: ResourceGroupParameterSet
Aliases:
Aliases:

Required: False
Position: 0
Expand All @@ -101,7 +101,7 @@ Accept wildcard characters: False
```yaml
Type: String
Parameter Sets: AccountNameParameterSet
Aliases:
Aliases:

Required: True
Position: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ Specifies the name of the resource group that contains the Storage account.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Aliases:

Required: True
Position: 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Specifies the name of the resource group contains the Storage account.
```yaml
Type: String
Parameter Sets: (All)
Aliases:
Aliases:

Required: True
Position: 0
Expand All @@ -90,3 +90,4 @@ This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable
## NOTES

## RELATED LINKS

Loading