Skip to content

Commit 6698c3f

Browse files
authored
Merge pull request #4324 from wastoresh/networkaclnew
Add cmdlets to management Network ACL
2 parents 20c7a55 + f8c6214 commit 6698c3f

36 files changed

+7126
-19
lines changed

src/ResourceManager/ContainerRegistry/Commands.ContainerRegistry.Test/Commands.ContainerRegistry.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
<Private>True</Private>
6262
</Reference>
6363
<Reference Include="Microsoft.Azure.Management.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
64-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.4.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
64+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.5.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
6565
</Reference>
6666
<Reference Include="Microsoft.Azure.Test.Framework">
6767
<SpecificVersion>False</SpecificVersion>

src/ResourceManager/ContainerRegistry/Commands.ContainerRegistry.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
66
<package id="Microsoft.Azure.Management.ContainerRegistry" version="1.2.0-preview" targetFramework="net45" />
77
<package id="Microsoft.Azure.Management.ResourceManager" version="1.6.0-preview" targetFramework="net452" />
8-
<package id="Microsoft.Azure.Management.Storage" version="6.4.0-preview" targetFramework="net452" />
8+
<package id="Microsoft.Azure.Management.Storage" version="6.5.0-preview" targetFramework="net452" />
99
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net45" />
1010
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.7.0" targetFramework="net45" />
1111
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />

src/ResourceManager/ContainerRegistry/Commands.ContainerRegistry/Commands.ContainerRegistry.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<Private>True</Private>
7070
</Reference>
7171
<Reference Include="Microsoft.Azure.Management.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
72-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.4.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
72+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.5.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
7373
</Reference>
7474
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7575
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.8\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>

src/ResourceManager/ContainerRegistry/Commands.ContainerRegistry/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
66
<package id="Microsoft.Azure.Management.ContainerRegistry" version="1.2.0-preview" targetFramework="net45" />
77
<package id="Microsoft.Azure.Management.ResourceManager" version="1.6.0-preview" targetFramework="net452" />
8-
<package id="Microsoft.Azure.Management.Storage" version="6.4.0-preview" targetFramework="net452" />
8+
<package id="Microsoft.Azure.Management.Storage" version="6.5.0-preview" targetFramework="net452" />
99
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
1010
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
1111
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />

src/ResourceManager/ServiceFabric/Commands.ServiceFabric.Test/Commands.ServiceFabric.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ServiceFabric.1.0.0-preview\lib\net45\Microsoft.Azure.Management.ServiceFabric.dll</HintPath>
9595
</Reference>
9696
<Reference Include="Microsoft.Azure.Management.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
97-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.4.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
97+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.5.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
9898
</Reference>
9999
<Reference Include="Microsoft.CSharp" />
100100
<Reference Include="Microsoft.Data.Edm">

src/ResourceManager/ServiceFabric/Commands.ServiceFabric.Test/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<package id="Microsoft.Azure.Management.KeyVault" version="2.3.0-preview" targetFramework="net452" />
1111
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
1212
<package id="Microsoft.Azure.Management.ServiceFabric" version="1.0.0-preview" targetFramework="net45" />
13-
<package id="Microsoft.Azure.Management.Storage" version="6.4.0-preview" targetFramework="net452" />
13+
<package id="Microsoft.Azure.Management.Storage" version="6.5.0-preview" targetFramework="net452" />
1414
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net45" />
1515
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.6.7-preview" targetFramework="net45" />
1616
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />

src/ResourceManager/ServiceFabric/Commands.ServiceFabric/Commands.ServiceFabric.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ServiceFabric.1.0.0-preview\lib\net45\Microsoft.Azure.Management.ServiceFabric.dll</HintPath>
184184
</Reference>
185185
<Reference Include="Microsoft.Azure.Management.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
186-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.4.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
186+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.5.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
187187
</Reference>
188188
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0">
189189
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.20.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>

src/ResourceManager/ServiceFabric/Commands.ServiceFabric/packages.config

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<package id="Microsoft.Azure.Management.ResourceManager" version="1.6.0-preview" targetFramework="net452" />
1515
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
1616
<package id="Microsoft.Azure.Management.ServiceFabric" version="1.0.0-preview" targetFramework="net45" />
17-
<package id="Microsoft.Azure.Management.Storage" version="6.4.0-preview" targetFramework="net452" />
17+
<package id="Microsoft.Azure.Management.Storage" version="6.5.0-preview" targetFramework="net452" />
1818
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
1919
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
2020
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />

src/ResourceManager/Storage/AzureRM.Storage.psd1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ CmdletsToExport = 'Get-AzureRmStorageAccount', 'Get-AzureRmStorageAccountKey',
7878
'Remove-AzureRmStorageAccount', 'Set-AzureRmCurrentStorageAccount',
7979
'Set-AzureRmStorageAccount',
8080
'Get-AzureRmStorageAccountNameAvailability',
81-
'Get-AzureRmStorageUsage'
81+
'Get-AzureRmStorageUsage',
82+
'Update-AzureRmStorageAccountNetworkRuleSet',
83+
'Get-AzureRmStorageAccountNetworkRuleSet',
84+
'Add-AzureRmStorageAccountNetworkRule',
85+
'Remove-AzureRmStorageAccountNetworkRule'
8286

8387
# Variables to export from this module
8488
# VariablesToExport = @()

src/ResourceManager/Storage/ChangeLog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@
1818
- Additional information about change #1
1919
-->
2020
## Current Release
21+
* Add NeworkRule support to resource mode storage account cmdlets
22+
- New-AzureRmStorageAccount
23+
- Set-AzureRmStorageAccount
24+
- Get-AzureStorageAccountNetworkRuleSet
25+
- Update-AzureStorageAccountNetworkRuleSet
26+
- Add-AzureStorageAccountNetworkRule
27+
- Remove-AzureStorageAccountNetworkRule
2128

2229
## Version 3.2.1
2330

src/ResourceManager/Storage/Commands.Management.Storage.Test/Commands.Management.Storage.Test.csproj

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
5353
</Reference>
5454
<Reference Include="Microsoft.Azure.Management.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
55-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.4.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
55+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.5.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
5656
</Reference>
5757
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
5858
<SpecificVersion>False</SpecificVersion>
@@ -170,6 +170,9 @@
170170
<None Include="SessionRecords\Microsoft.Azure.Commands.Management.Storage.Test.ScenarioTests.StorageAccountTests\TestGetAzureStorageAccountKey.json">
171171
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
172172
</None>
173+
<None Include="SessionRecords\Microsoft.Azure.Commands.Management.Storage.Test.ScenarioTests.StorageAccountTests\TestNetworkRule.json">
174+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
175+
</None>
173176
<None Include="SessionRecords\Microsoft.Azure.Commands.Management.Storage.Test.ScenarioTests.StorageAccountTests\TestNewAzureStorageAccount.json">
174177
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
175178
</None>

src/ResourceManager/Storage/Commands.Management.Storage.Test/ScenarioTests/Common.ps1

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,4 +147,13 @@ Gets the default location for a provider
147147
function Get-ProviderLocation($provider)
148148
{
149149
"westus"
150+
}
151+
152+
<#
153+
.SYNOPSIS
154+
Gets the Canary location for a provider
155+
#>
156+
function Get-ProviderLocation_Canary($provider)
157+
{
158+
"eastus2euap"
150159
}

src/ResourceManager/Storage/Commands.Management.Storage.Test/ScenarioTests/StorageAccountTests.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,12 @@ public void TestSetAzureRmStorageAccountKeySource()
105105
TestController.NewInstance.RunPsTest("Test-SetAzureRmStorageAccountKeySource");
106106
}
107107

108+
[Fact]
109+
[Trait(Category.AcceptanceType, Category.CheckIn)]
110+
public void TestNetworkRule()
111+
{
112+
TestController.NewInstance.RunPsTest("Test-NetworkRule");
113+
}
114+
108115
}
109116
}

src/ResourceManager/Storage/Commands.Management.Storage.Test/ScenarioTests/StorageAccountTests.ps1

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ function Test-GetAzureStorageAccount
159159
$kind = 'Storage'
160160

161161
New-AzureRmResourceGroup -Name $rgname -Location $loc;
162+
Write-Output ("Resource Group created")
162163

163164
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype ;
164165

@@ -501,3 +502,95 @@ function Test-SetAzureRmCurrentStorageAccount
501502
Clean-ResourceGroup $rgname
502503
}
503504
}
505+
506+
507+
<#
508+
.SYNOPSIS
509+
Test NetworkRule
510+
#>
511+
function Test-NetworkRule
512+
{
513+
# Setup
514+
$rgname = Get-StorageManagementTestResourceName;
515+
516+
try
517+
{
518+
# Test
519+
$stoname = 'sto' + $rgname;
520+
$stotype = 'Standard_LRS';
521+
$loc = Get-ProviderLocation_Canary ResourceManagement;
522+
$ip1 = "20.11.0.0/16";
523+
$ip2 = "10.0.0.0/7";
524+
$ip3 = "11.1.1.0/24";
525+
$ip4 = "28.0.2.0/19";
526+
527+
New-AzureRmResourceGroup -Name $rgname -Location $loc;
528+
529+
New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype -NetworkRule (@{bypass="Logging,Metrics,AzureServices";
530+
ipRules=(@{IPAddressOrRange="$ip1";Action="allow"},
531+
@{IPAddressOrRange="$ip2";Action="allow"});
532+
defaultAction="Deny"})
533+
534+
$stoacl = (Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname).NetworkRule
535+
Assert-AreEqual $stoacl.Bypass 7;
536+
Assert-AreEqual $stoacl.DefaultAction Deny;
537+
Assert-AreEqual $stoacl.IpRules.Count 2
538+
Assert-AreEqual $stoacl.IpRules[0].IPAddressOrRange $ip1;
539+
Assert-AreEqual $stoacl.IpRules[1].IPAddressOrRange $ip2;
540+
Assert-AreEqual $stoacl.VirtualNetworkRules $null
541+
542+
Update-AzureRmStorageAccountNetworkRuleSet -verbose -ResourceGroupName $rgname -Name $stoname -Bypass AzureServices,Metrics -DefaultAction Allow -IpRule (@{IPAddressOrRange="$ip3";Action="allow"},@{IPAddressOrRange="$ip4";Action="allow"})
543+
$stoacl = Get-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname
544+
$stoacliprule = $stoacl.IpRules
545+
Assert-AreEqual $stoacl.Bypass 6;
546+
Assert-AreEqual $stoacl.DefaultAction Allow;
547+
Assert-AreEqual $stoacl.IpRules.Count 2
548+
Assert-AreEqual $stoacl.IpRules[0].IPAddressOrRange $ip3;
549+
Assert-AreEqual $stoacl.IpRules[1].IPAddressOrRange $ip4;
550+
Assert-AreEqual $stoacl.VirtualNetworkRules $null
551+
552+
Remove-AzureRmStorageAccountNetworkRule -ResourceGroupName $rgname -Name $stoname -IPAddressOrRange "$ip3"
553+
$stoacl = Get-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname
554+
Assert-AreEqual $stoacl.Bypass 6;
555+
Assert-AreEqual $stoacl.DefaultAction Allow;
556+
Assert-AreEqual $stoacl.IpRules.Count 1
557+
Assert-AreEqual $stoacl.IpRules[0].IPAddressOrRange $ip4;
558+
Assert-AreEqual $stoacl.VirtualNetworkRules $null
559+
560+
Update-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname -IpRule @() -DefaultAction Deny -Bypass None
561+
$stoacl = Get-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname
562+
Assert-AreEqual $stoacl.Bypass 0;
563+
Assert-AreEqual $stoacl.DefaultAction Deny;
564+
Assert-AreEqual $stoacl.IpRules $null
565+
Assert-AreEqual $stoacl.VirtualNetworkRules $null
566+
567+
$stoacliprule | Add-AzureRmStorageAccountNetworkRule -ResourceGroupName $rgname -Name $stoname
568+
$stoacl = Get-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname
569+
Assert-AreEqual $stoacl.Bypass 0;
570+
Assert-AreEqual $stoacl.DefaultAction Deny;
571+
Assert-AreEqual $stoacl.IpRules.Count 2
572+
Assert-AreEqual $stoacl.IpRules[0].IPAddressOrRange $ip3;
573+
Assert-AreEqual $stoacl.IpRules[1].IPAddressOrRange $ip4;
574+
Assert-AreEqual $stoacl.VirtualNetworkRules $null
575+
576+
Set-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -NetworkRule (@{bypass="AzureServices";
577+
ipRules=(@{IPAddressOrRange="$ip1";Action="allow"},
578+
@{IPAddressOrRange="$ip2";Action="allow"});
579+
defaultAction="Allow"})
580+
581+
$stoacl = Get-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname
582+
Assert-AreEqual $stoacl.Bypass 4;
583+
Assert-AreEqual $stoacl.DefaultAction Allow;
584+
Assert-AreEqual $stoacl.IpRules.Count 2
585+
Assert-AreEqual $stoacl.IpRules[0].IPAddressOrRange $ip1;
586+
Assert-AreEqual $stoacl.IpRules[1].IPAddressOrRange $ip2;
587+
Assert-AreEqual $stoacl.VirtualNetworkRules $null
588+
589+
Remove-AzureRmStorageAccount -Force -ResourceGroupName $rgname -Name $stoname;
590+
}
591+
finally
592+
{
593+
# Cleanup
594+
Clean-ResourceGroup $rgname
595+
}
596+
}

0 commit comments

Comments
 (0)