Skip to content

Add cmdlets to management Network ACL #4324

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 4 commits into from
Jul 31, 2017
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
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.4.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.5.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Test.Framework">
<SpecificVersion>False</SpecificVersion>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ContainerRegistry" version="1.2.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.6.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Storage" version="6.4.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Storage" version="6.5.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.7.0" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.4.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.5.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Rest.ClientRuntime, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Rest.ClientRuntime.2.3.8\lib\net452\Microsoft.Rest.ClientRuntime.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<package id="Microsoft.Azure.Common.Dependencies" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ContainerRegistry" version="1.2.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ResourceManager" version="1.6.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Storage" version="6.4.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Storage" version="6.5.0-preview" targetFramework="net452" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ServiceFabric.1.0.0-preview\lib\net45\Microsoft.Azure.Management.ServiceFabric.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.4.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.5.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Data.Edm">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<package id="Microsoft.Azure.Management.KeyVault" version="2.3.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ServiceFabric" version="1.0.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Storage" version="6.4.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Storage" version="6.5.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Test.Framework" version="1.0.6179.26854-prerelease" targetFramework="net45" />
<package id="Microsoft.Azure.Test.HttpRecorder" version="1.6.7-preview" targetFramework="net45" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ServiceFabric.1.0.0-preview\lib\net45\Microsoft.Azure.Management.ServiceFabric.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.4.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.5.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Resources.2.20.0-preview\lib\net40\Microsoft.Azure.ResourceManager.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<package id="Microsoft.Azure.Management.ResourceManager" version="1.6.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Resources" version="2.20.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.ServiceFabric" version="1.0.0-preview" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Storage" version="6.4.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Storage" version="6.5.0-preview" targetFramework="net452" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net45" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net45" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net45" />
Expand Down
6 changes: 5 additions & 1 deletion src/ResourceManager/Storage/AzureRM.Storage.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ CmdletsToExport = 'Get-AzureRmStorageAccount', 'Get-AzureRmStorageAccountKey',
'Remove-AzureRmStorageAccount', 'Set-AzureRmCurrentStorageAccount',
'Set-AzureRmStorageAccount',
'Get-AzureRmStorageAccountNameAvailability',
'Get-AzureRmStorageUsage'
'Get-AzureRmStorageUsage',
'Update-AzureRmStorageAccountNetworkRuleSet',
'Get-AzureRmStorageAccountNetworkRuleSet',
'Add-AzureRmStorageAccountNetworkRule',
'Remove-AzureRmStorageAccountNetworkRule'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
7 changes: 7 additions & 0 deletions src/ResourceManager/Storage/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
- Additional information about change #1
-->
## Current Release
* Add NeworkRule support to resource mode storage account cmdlets
- New-AzureRmStorageAccount
- Set-AzureRmStorageAccount
- Get-AzureStorageAccountNetworkRuleSet
- Update-AzureStorageAccountNetworkRuleSet
- Add-AzureStorageAccountNetworkRule
- Remove-AzureStorageAccountNetworkRule

## Version 3.2.1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Authorization.2.0.0\lib\net40\Microsoft.Azure.Management.Authorization.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage, Version=6.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.4.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.6.5.0-preview\lib\net452\Microsoft.Azure.Management.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down Expand Up @@ -170,6 +170,9 @@
<None Include="SessionRecords\Microsoft.Azure.Commands.Management.Storage.Test.ScenarioTests.StorageAccountTests\TestGetAzureStorageAccountKey.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Management.Storage.Test.ScenarioTests.StorageAccountTests\TestNetworkRule.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="SessionRecords\Microsoft.Azure.Commands.Management.Storage.Test.ScenarioTests.StorageAccountTests\TestNewAzureStorageAccount.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,13 @@ Gets the default location for a provider
function Get-ProviderLocation($provider)
{
"westus"
}

<#
.SYNOPSIS
Gets the Canary location for a provider
#>
function Get-ProviderLocation_Canary($provider)
{
"eastus2euap"
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,12 @@ public void TestSetAzureRmStorageAccountKeySource()
TestController.NewInstance.RunPsTest("Test-SetAzureRmStorageAccountKeySource");
}

[Fact]
[Trait(Category.AcceptanceType, Category.CheckIn)]
public void TestNetworkRule()
{
TestController.NewInstance.RunPsTest("Test-NetworkRule");
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ function Test-GetAzureStorageAccount
$kind = 'Storage'

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

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

Expand Down Expand Up @@ -501,3 +502,95 @@ function Test-SetAzureRmCurrentStorageAccount
Clean-ResourceGroup $rgname
}
}


<#
.SYNOPSIS
Test NetworkRule
#>
function Test-NetworkRule
{
# Setup
$rgname = Get-StorageManagementTestResourceName;

try
{
# Test
$stoname = 'sto' + $rgname;
$stotype = 'Standard_LRS';
$loc = Get-ProviderLocation_Canary ResourceManagement;
$ip1 = "20.11.0.0/16";
$ip2 = "10.0.0.0/7";
$ip3 = "11.1.1.0/24";
$ip4 = "28.0.2.0/19";

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

New-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -Location $loc -Type $stotype -NetworkRule (@{bypass="Logging,Metrics,AzureServices";
ipRules=(@{IPAddressOrRange="$ip1";Action="allow"},
@{IPAddressOrRange="$ip2";Action="allow"});
defaultAction="Deny"})

$stoacl = (Get-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname).NetworkRule
Assert-AreEqual $stoacl.Bypass 7;
Assert-AreEqual $stoacl.DefaultAction Deny;
Assert-AreEqual $stoacl.IpRules.Count 2
Assert-AreEqual $stoacl.IpRules[0].IPAddressOrRange $ip1;
Assert-AreEqual $stoacl.IpRules[1].IPAddressOrRange $ip2;
Assert-AreEqual $stoacl.VirtualNetworkRules $null

Update-AzureRmStorageAccountNetworkRuleSet -verbose -ResourceGroupName $rgname -Name $stoname -Bypass AzureServices,Metrics -DefaultAction Allow -IpRule (@{IPAddressOrRange="$ip3";Action="allow"},@{IPAddressOrRange="$ip4";Action="allow"})
$stoacl = Get-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname
$stoacliprule = $stoacl.IpRules
Assert-AreEqual $stoacl.Bypass 6;
Assert-AreEqual $stoacl.DefaultAction Allow;
Assert-AreEqual $stoacl.IpRules.Count 2
Assert-AreEqual $stoacl.IpRules[0].IPAddressOrRange $ip3;
Assert-AreEqual $stoacl.IpRules[1].IPAddressOrRange $ip4;
Assert-AreEqual $stoacl.VirtualNetworkRules $null

Remove-AzureRmStorageAccountNetworkRule -ResourceGroupName $rgname -Name $stoname -IPAddressOrRange "$ip3"
$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
$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
$stoacl = Get-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname
Assert-AreEqual $stoacl.Bypass 0;
Assert-AreEqual $stoacl.DefaultAction Deny;
Assert-AreEqual $stoacl.IpRules.Count 2
Assert-AreEqual $stoacl.IpRules[0].IPAddressOrRange $ip3;
Assert-AreEqual $stoacl.IpRules[1].IPAddressOrRange $ip4;
Assert-AreEqual $stoacl.VirtualNetworkRules $null

Set-AzureRmStorageAccount -ResourceGroupName $rgname -Name $stoname -NetworkRule (@{bypass="AzureServices";
ipRules=(@{IPAddressOrRange="$ip1";Action="allow"},
@{IPAddressOrRange="$ip2";Action="allow"});
defaultAction="Allow"})

$stoacl = Get-AzureRmStorageAccountNetworkRuleSet -ResourceGroupName $rgname -Name $stoname
Assert-AreEqual $stoacl.Bypass 4;
Assert-AreEqual $stoacl.DefaultAction Allow;
Assert-AreEqual $stoacl.IpRules.Count 2
Assert-AreEqual $stoacl.IpRules[0].IPAddressOrRange $ip1;
Assert-AreEqual $stoacl.IpRules[1].IPAddressOrRange $ip2;
Assert-AreEqual $stoacl.VirtualNetworkRules $null

Remove-AzureRmStorageAccount -Force -ResourceGroupName $rgname -Name $stoname;
}
finally
{
# Cleanup
Clean-ResourceGroup $rgname
}
}
Loading