Skip to content

Commit

Permalink
Addressing Jared and Adam's comments
Browse files Browse the repository at this point in the history
  • Loading branch information
NayantaraD committed Aug 28, 2017
1 parent 1481cfc commit e8b91c0
Show file tree
Hide file tree
Showing 15 changed files with 20 additions and 55 deletions.
8 changes: 4 additions & 4 deletions src/ResourceManager/Sql/AzureRM.Sql.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,10 @@ CmdletsToExport = 'Get-AzureRmSqlDatabaseTransparentDataEncryption',
'New-AzureRmSqlSyncAgent', 'Get-AzureRmSqlSyncAgent',
'Remove-AzureRmSqlSyncAgent', 'New-AzureRmSqlSyncAgentKey',
'Get-AzureRmSqlSyncAgentLinkedDatabase',
'New-AzureRmSqlServerVirtualNetworkRule',
'Set-AzureRmSqlServerVirtualNetworkRule',
'Get-AzureRmSqlServerVirtualNetworkRule',
'Remove-AzureRmSqlServerVirtualNetworkRule'
'New-AzureRmSqlServerVirtualNetworkRule',
'Set-AzureRmSqlServerVirtualNetworkRule',
'Get-AzureRmSqlServerVirtualNetworkRule',
'Remove-AzureRmSqlServerVirtualNetworkRule'

# Variables to export from this module
# VariablesToExport = @()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ScenarioTest.SqlTests;
using Microsoft.Azure.Management.Resources;
using Microsoft.Azure.ServiceManagemenet.Common.Models;
using Microsoft.WindowsAzure.Commands.ScenarioTest;
using Xunit;
using Xunit.Abstractions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

<#
.SYNOPSIS
Tests creating and updating a virtual network rule
Tests for checking virtual network rule core functionalities. This includes - create, update, delete, list and get operations
#>
function Test-CreateAndUpdateVirtualNetworkRule
{
Expand All @@ -36,13 +36,15 @@ function Test-CreateAndUpdateVirtualNetworkRule
try
{
# Create rule
$virtualNetworkRule = New-AzureRmSqlServerVirtualNetworkRule -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -VirtualNetworkRuleName $virtualNetworkRuleName -VirtualNetworkSubnetId $virtualNetworkSubnetId1
$virtualNetworkRule = New-AzureRmSqlServerVirtualNetworkRule -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
-VirtualNetworkRuleName $virtualNetworkRuleName -VirtualNetworkSubnetId $virtualNetworkSubnetId1
Assert-AreEqual $virtualNetworkRule.ServerName $server.ServerName
Assert-AreEqual $virtualNetworkRule.VirtualNetworkRuleName $virtualNetworkRuleName
Assert-AreEqual $virtualNetworkRule.VirtualNetworkSubnetId $virtualNetworkSubnetId1

# Update existing rule
$virtualNetworkRule = Set-AzureRmSqlServerVirtualNetworkRule -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -VirtualNetworkRuleName $virtualNetworkRuleName -VirtualNetworkSubnetId $virtualNetworkSubnetId2
$virtualNetworkRule = Set-AzureRmSqlServerVirtualNetworkRule -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
-VirtualNetworkRuleName $virtualNetworkRuleName -VirtualNetworkSubnetId $virtualNetworkSubnetId2
Assert-AreEqual $virtualNetworkRule.ServerName $server.ServerName
Assert-AreEqual $virtualNetworkRule.VirtualNetworkRuleName $virtualNetworkRuleName
Assert-AreEqual $virtualNetworkRule.VirtualNetworkSubnetId $virtualNetworkSubnetId2
Expand Down Expand Up @@ -79,13 +81,15 @@ function Test-GetVirtualNetworkRule
try
{
# Create rule 1
$virtualNetworkRule1 = New-AzureRmSqlServerVirtualNetworkRule -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -VirtualNetworkRuleName $virtualNetworkRuleName1 -VirtualNetworkSubnetId $virtualNetworkSubnetId1
$virtualNetworkRule1 = New-AzureRmSqlServerVirtualNetworkRule -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
-VirtualNetworkRuleName $virtualNetworkRuleName1 -VirtualNetworkSubnetId $virtualNetworkSubnetId1
Assert-AreEqual $virtualNetworkRule1.ServerName $server.ServerName
Assert-AreEqual $virtualNetworkRule1.VirtualNetworkRuleName $virtualNetworkRuleName1
Assert-AreEqual $virtualNetworkRule1.VirtualNetworkSubnetId $virtualNetworkSubnetId1

# Create rule 2
$virtualNetworkRule2 = New-AzureRmSqlServerVirtualNetworkRule -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -VirtualNetworkRuleName $virtualNetworkRuleName2 -VirtualNetworkSubnetId $virtualNetworkSubnetId2
$virtualNetworkRule2 = New-AzureRmSqlServerVirtualNetworkRule -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
-VirtualNetworkRuleName $virtualNetworkRuleName2 -VirtualNetworkSubnetId $virtualNetworkSubnetId2
Assert-AreEqual $virtualNetworkRule2.ServerName $server.ServerName
Assert-AreEqual $virtualNetworkRule2.VirtualNetworkRuleName $virtualNetworkRuleName2
Assert-AreEqual $virtualNetworkRule2.VirtualNetworkSubnetId $virtualNetworkSubnetId2
Expand Down Expand Up @@ -127,16 +131,16 @@ function Test-RemoveVirtualNetworkRule
try
{
# Create rule
$virtualNetworkRule = New-AzureRmSqlServerVirtualNetworkRule -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -VirtualNetworkRuleName $virtualNetworkRuleName -VirtualNetworkSubnetId $virtualNetworkSubnetId
$virtualNetworkRule = New-AzureRmSqlServerVirtualNetworkRule -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
-VirtualNetworkRuleName $virtualNetworkRuleName -VirtualNetworkSubnetId $virtualNetworkSubnetId
Assert-AreEqual $virtualNetworkRule.ServerName $server.ServerName
Assert-AreEqual $virtualNetworkRule.VirtualNetworkRuleName $virtualNetworkRuleName
Assert-AreEqual $virtualNetworkRule.VirtualNetworkSubnetId $virtualNetworkSubnetId

# Remove rule and check if rule is deleted
$resp = Remove-AzureRmSqlServerVirtualNetworkRule -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -VirtualNetworkRuleName $virtualNetworkRuleName -Force
$all = Get-AzureRmSqlServerVirtualNetworkRule -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName
Assert-AreEqual $all.Count 0

}
finally
{
Expand All @@ -161,5 +165,4 @@ function CreateAndGetVirtualNetwork ($resourceGroup, $vnetName, $location = "wes
$getVnet = Get-AzureRmVirtualNetwork -Name $vnetName -ResourceGroupName $resourceGroup.ResourceGroupName

return $getVnet

}
3 changes: 0 additions & 3 deletions src/ResourceManager/Sql/Commands.Sql/Commands.Sql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -449,9 +449,6 @@
</Reference>
<Reference Include="Microsoft.Azure.Management.Storage">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Storage.2.4.0-preview\lib\net40\Microsoft.Azure.Management.Storage.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Azure.Management.Network">
<HintPath>..\..\..\packages\Microsoft.Azure.Management.Network.14.0.0-preview\lib\net452\Microsoft.Azure.Management.Network.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.8.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Microsoft.Data.Edm.5.8.2\lib\net40\Microsoft.Data.Edm.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@
<value>Permanently removing Virtual Network Rule '{0}' for Azure Sql Server '{1}'</value>
</data>
<data name="RemoveAzureSqlServerVirtualNetworkRuleWarning" xml:space="preserve">
<value>Are you sure you want to remove the Virtual Network Rule '{0}' for Azure Sql Server '{1}'?</value>
<value>Are you sure you want to remove the Virtual Network Rule '{0}' for Azure Sql Server '{1}'?</value>
</data>
<data name="ServerVirtualNetworkRuleNameExists" xml:space="preserve">
<value>Virtual Network Rule with name: '{0}' already exists for server '{1}'</value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Azure.Commands.Sql.Common;
using Microsoft.Azure.Commands.Sql.VirtualNetworkRule.Adapter;
using Microsoft.Azure.Commands.Sql.VirtualNetworkRule.Model;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Commands.Sql.VirtualNetworkRule.Model;
using Microsoft.WindowsAzure.Commands.Common;
using System.Collections.Generic;
using System.IO;
using System.Management.Automation;
using System.Reflection;

namespace Microsoft.Azure.Commands.Sql.VirtualNetworkRule.Cmdlet
{
Expand Down Expand Up @@ -76,6 +72,5 @@ protected override IEnumerable<AzureSqlServerVirtualNetworkRuleModel> ApplyUserI
{
return model;
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
using Microsoft.Rest.Azure;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
Expand Down Expand Up @@ -58,7 +56,7 @@ public class NewAzureSqlServerVirtualNetworkRule : AzureSqlServerVirtualNetworkR
{
if (ex.Response.StatusCode == System.Net.HttpStatusCode.NotFound)
{
// This is what we want. We looked and there is no server with this name.
// This is what we want. We looked and there is no virtual network rule with this name.
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Management.Automation;
using System.Security;


namespace Microsoft.Azure.Commands.Sql.VirtualNetworkRule.Cmdlet
{
Expand Down Expand Up @@ -46,7 +42,6 @@ public class SetAzureSqlServerVirtualNetworkRule : AzureSqlServerVirtualNetworkR
[ValidateNotNull]
public string VirtualNetworkSubnetId { get; set; }


/// <summary>
/// Get the Virtual Network Rule to update
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using System;

namespace Microsoft.Azure.Commands.Sql.VirtualNetworkRule.Model
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@
// limitations under the License.
// ----------------------------------------------------------------------------------

using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.Azure.Commands.Sql.VirtualNetworkRule.Model;
using Microsoft.Azure.Commands.Sql.VirtualNetworkRule.Services;
using Microsoft.Azure.Commands.Sql.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using Microsoft.Azure.Commands.ResourceManager.Common.Tags;
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;

namespace Microsoft.Azure.Commands.Sql.VirtualNetworkRule.Adapter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@

using Microsoft.Azure.Commands.Common.Authentication;
using Microsoft.Azure.Commands.Common.Authentication.Abstractions;
using Microsoft.Azure.Commands.Common.Authentication.Models;
using Microsoft.Azure.Commands.Sql.Common;
using Microsoft.Azure.Management.Sql;
using Microsoft.Azure.Management.Sql.Models;
using Microsoft.Rest.Azure;
using System;
using System.Collections.Generic;
using System.Linq;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ schema: 2.0.0
# New-AzureRmSqlServerVirtualNetworkRule

## SYNOPSIS
Creates an Azure SQL Server Virtual Network Rule.
Creates an Azure SQL Server Virtual Network Rule. Virtual Network Rules are used to connect the Azure SQL Server to a specific Virtual Network in order to restrict the access on the Azure SQL Server to only be available within the Virtual Network.

## SYNTAX

Expand Down
1 change: 0 additions & 1 deletion src/ResourceManager/Sql/Commands.Sql/packages.config
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.KeyVault.Core" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.Azure.Management.Network" version="12.0.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Sql" version="1.6.0-preview" targetFramework="net452" />
<package id="Microsoft.Azure.Management.Storage" version="2.4.0-preview" targetFramework="net45" />
<package id="WindowsAzure.Storage" version="8.1.1" targetFramework="net452" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ internal static IList<string> RequiredProvidersForResourceManager<T>()
return new[] { StorageProviderNamespace };
}

if (typeof(T).FullName.Equals("Microsoft.Azure.Management.Network.NetworkManagementClient"))
{
return new[] { NetworkProviderNamespace };
}

return new string[0];
}
}
Expand Down

0 comments on commit e8b91c0

Please sign in to comment.