Skip to content

Commit 1f1c88a

Browse files
authored
Added zone redundant parameter to powershell commands. (Azure#4877)
Added zone redundant parameter to powershell commands.
2 parents f2a2278 + 66e3761 commit 1f1c88a

File tree

35 files changed

+585351
-22905
lines changed

35 files changed

+585351
-22905
lines changed

src/ResourceManager/Sql/ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
* Adding support for list and cancel the asynchronous updateslo operation on the database
2222
- update existing cmdlet Get-AzureRmSqlDatabaseActivity to return DB updateslo operation status.
2323
- add new cmdlet Stop-AzureRmSqlDatabaseActivity for cancel the asynchronous updateslo operation on the database.
24+
* Adding support for Zone Redundancy for databases and elastic pools
25+
- Adding ZoneRedundant switch parameter to New-AzureRmSqlDatabase
26+
- Adding ZoneRedundant switch parameter to Set-AzureRmSqlDatabase
27+
- Adding ZoneRedundant switch parameter to New-AzureRmSqlElasticPool
28+
- Adding ZoneRedundant switch parameter to Set-AzureRmSqlElasticPool
2429
* Adding support for Server DNS Aliases
2530
- Adding Get-AzureRmSqlServerDnsAlias cmdlet which gets server dns aliases by server and alias name or a list of server dns aliases for an azure Sql Server.
2631
- Adding New-AzureRmSqlServerDnsAlias cmdlet which creates new server dns alias for a given Azure Sql server

src/ResourceManager/Sql/Commands.Sql.Test/Commands.Sql.Test.csproj

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,15 +656,27 @@
656656
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseCreateWithSampleName.json">
657657
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
658658
</None>
659+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseCreateWithZoneRedundancy.json">
660+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
661+
</None>
659662
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseGet.json">
660663
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
661664
</None>
665+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseGetWithZoneRedundancy.json">
666+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
667+
</None>
662668
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseRemove.json">
663669
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
664670
</None>
665671
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseUpdate.json">
666672
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
667673
</None>
674+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseUpdateWithZoneRedundancy.json">
675+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
676+
</None>
677+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseCrudTests\TestDatabaseUpdateWithZoneRedundancyNotSpecified.json">
678+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
679+
</None>
668680
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseReplicationTests\TestCreateDatabaseCopy.json">
669681
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
670682
</None>
@@ -746,15 +758,24 @@
746758
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolCreate.json">
747759
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
748760
</None>
761+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolCreateWithZoneRedundancy.json">
762+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
763+
</None>
749764
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolGet.json">
750765
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
751766
</None>
767+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolGetWithZoneRedundancy.json">
768+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
769+
</None>
752770
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolRemove.json">
753771
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
754772
</None>
755773
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolUpdate.json">
756774
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
757775
</None>
776+
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.ElasticPoolCrudTests\TestElasticPoolUpdateWithZoneRedundancy.json">
777+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
778+
</None>
758779
<None Include="SessionRecords\Microsoft.Azure.Commands.Sql.Test.ScenarioTests.FailoverGroupTests\TestCreateFailoverGroup_AutomaticPolicy.json">
759780
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
760781
</None>

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/DatabaseCrudTests.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,20 +52,48 @@ public void TestDatabaseCreateWithSampleName()
5252
RunPowerShellTest("Test-CreateDatabaseWithSampleName");
5353
}
5454

55+
[Fact]
56+
[Trait(Category.AcceptanceType, Category.CheckIn)]
57+
public void TestDatabaseCreateWithZoneRedundancy()
58+
{
59+
RunPowerShellTest("Test-CreateDatabaseWithZoneRedundancy");
60+
}
61+
5562
[Fact]
5663
[Trait(Category.AcceptanceType, Category.CheckIn)]
5764
public void TestDatabaseUpdate()
5865
{
5966
RunPowerShellTest("Test-UpdateDatabase");
6067
}
6168

69+
[Fact]
70+
[Trait(Category.AcceptanceType, Category.CheckIn)]
71+
public void TestDatabaseUpdateWithZoneRedundancy()
72+
{
73+
RunPowerShellTest("Test-UpdateDatabaseWithZoneRedundant");
74+
}
75+
76+
[Fact]
77+
[Trait(Category.AcceptanceType, Category.CheckIn)]
78+
public void TestDatabaseUpdateWithZoneRedundancyNotSpecified()
79+
{
80+
RunPowerShellTest("Test-UpdateDatabaseWithZoneRedundantNotSpecified");
81+
}
82+
6283
[Fact]
6384
[Trait(Category.AcceptanceType, Category.CheckIn)]
6485
public void TestDatabaseGet()
6586
{
6687
RunPowerShellTest("Test-GetDatabase");
6788
}
6889

90+
[Fact]
91+
[Trait(Category.AcceptanceType, Category.CheckIn)]
92+
public void TestDatabaseGetWithZoneRedundancy()
93+
{
94+
RunPowerShellTest("Test-GetDatabaseWithZoneRedundancy");
95+
}
96+
6997
[Fact]
7098
[Trait(Category.AcceptanceType, Category.CheckIn)]
7199
public void TestDatabaseRemove()

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/DatabaseCrudTests.ps1

Lines changed: 168 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ function Test-CreateDatabaseInternal ($location = "westcentralus")
102102
function Test-CreateDatabaseWithSampleName
103103
{
104104
# Setup
105+
$location = "westcentralus"
105106
$rg = Create-ResourceGroupForTest
106107
try
107108
{
108-
$server = Create-ServerForTest $rg
109+
$server = Create-ServerForTest $rg $location
109110

110111
# Create with samplename
111112
$databaseName = Get-DatabaseName
@@ -128,6 +129,52 @@ function Test-CreateDatabaseWithSampleName
128129
}
129130
}
130131

132+
<#
133+
.SYNOPSIS
134+
Tests creating a database with zone redundancy.
135+
#>
136+
function Test-CreateDatabaseWithZoneRedundancy
137+
{
138+
# Setup
139+
$location = "eastus2"
140+
$rg = Create-ResourceGroupForTest $location
141+
try
142+
{
143+
$server = Create-ServerForTest $rg $location
144+
145+
# Create database with no zone redundancy set
146+
$databaseName = Get-DatabaseName
147+
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
148+
-DatabaseName $databaseName -Edition Premium
149+
Assert-AreEqual $db.DatabaseName $databaseName
150+
Assert-NotNull $db.Edition
151+
Assert-NotNull $db.ZoneRedundant
152+
Assert-AreEqual "false" $db.ZoneRedundant
153+
154+
# Create database with zone redundancy true
155+
$databaseName = Get-DatabaseName
156+
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
157+
-DatabaseName $databaseName -Edition Premium -ZoneRedundant
158+
Assert-AreEqual $db.DatabaseName $databaseName
159+
Assert-NotNull $db.Edition
160+
Assert-NotNull $db.ZoneRedundant
161+
Assert-AreEqual "true" $db.ZoneRedundant
162+
163+
# Create database with zone redundancy false
164+
$databaseName = Get-DatabaseName
165+
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
166+
-DatabaseName $databaseName -Edition Premium -ZoneRedundant:$false
167+
Assert-AreEqual $db.DatabaseName $databaseName
168+
Assert-NotNull $db.Edition
169+
Assert-NotNull $db.ZoneRedundant
170+
Assert-AreEqual "false" $db.ZoneRedundant
171+
}
172+
finally
173+
{
174+
Remove-ResourceGroupForTest $rg
175+
}
176+
}
177+
131178
<#
132179
.SYNOPSIS
133180
Tests updating a database
@@ -200,6 +247,88 @@ function Test-UpdateDatabaseInternal ($location = "westcentralus")
200247
}
201248
}
202249

250+
<#
251+
.SYNOPSIS
252+
Tests updating a database with zone redundancy
253+
#>
254+
function Test-UpdateDatabaseWithZoneRedundant ()
255+
{
256+
# Setup
257+
$location = "eastus2"
258+
$rg = Create-ResourceGroupForTest $location
259+
$server = Create-ServerForTest $rg $location
260+
261+
$databaseName = Get-DatabaseName
262+
$db1 = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
263+
-Edition Premium
264+
Assert-AreEqual $db1.DatabaseName $databaseName
265+
Assert-NotNull $db1.ZoneRedundant
266+
Assert-AreEqual "false" $db1.ZoneRedundant
267+
268+
$databaseName = Get-DatabaseName
269+
$db2 = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
270+
-Edition Premium -ZoneRedundant
271+
Assert-AreEqual $db2.DatabaseName $databaseName
272+
Assert-NotNull $db2.ZoneRedundant
273+
Assert-AreEqual "true" $db2.ZoneRedundant
274+
275+
try
276+
{
277+
# Alter database with zone redundancy to true
278+
$sdb1 = Set-AzureRmSqlDatabase -ResourceGroupName $db1.ResourceGroupName -ServerName $db1.ServerName -DatabaseName $db1.DatabaseName `
279+
-ZoneRedundant
280+
Assert-AreEqual $sdb1.DatabaseName $db1.DatabaseName
281+
Assert-NotNull $sdb1.ZoneRedundant
282+
Assert-AreEqual "true" $sdb1.ZoneRedundant
283+
284+
# Alter database with zone redundancy to false
285+
$sdb2 = Set-AzureRmSqlDatabase -ResourceGroupName $db2.ResourceGroupName -ServerName $db2.ServerName -DatabaseName $db2.DatabaseName `
286+
-ZoneRedundant:$false
287+
Assert-AreEqual $sdb2.DatabaseName $db2.DatabaseName
288+
Assert-NotNull $sdb2.ZoneRedundant
289+
Assert-AreEqual "false" $sdb2.ZoneRedundant
290+
}
291+
finally
292+
{
293+
Remove-ResourceGroupForTest $rg
294+
}
295+
}
296+
297+
<#
298+
.SYNOPSIS
299+
Tests updating a database with zone redundancy not specified
300+
#>
301+
function Test-UpdateDatabaseWithZoneRedundantNotSpecified ()
302+
{
303+
# Setup
304+
$location = "eastus2"
305+
$rg = Create-ResourceGroupForTest $location
306+
$server = Create-ServerForTest $rg $location
307+
308+
$databaseName = Get-DatabaseName
309+
$db = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $databaseName `
310+
-Edition Premium -ZoneRedundant
311+
Assert-AreEqual $db.DatabaseName $databaseName
312+
Assert-NotNull $db.ZoneRedundant
313+
Assert-AreEqual "true" $db.ZoneRedundant
314+
315+
try
316+
{
317+
# Alter database with no zone redundancy set
318+
$db1 = Set-AzureRmSqlDatabase -ResourceGroupName $db.ResourceGroupName -ServerName $db.ServerName -DatabaseName $db.DatabaseName `
319+
-Tags @{"tag_key"="tag_new_value2"}
320+
Assert-AreEqual $db1.DatabaseName $db.DatabaseName
321+
Assert-AreEqual True $db1.Tags.ContainsKey("tag_key")
322+
Assert-AreEqual "tag_new_value2" $db1.Tags["tag_key"]
323+
Assert-NotNull $db1.ZoneRedundant
324+
Assert-AreEqual "true" $db1.ZoneRedundant
325+
}
326+
finally
327+
{
328+
Remove-ResourceGroupForTest $rg
329+
}
330+
}
331+
203332

204333
<#
205334
.SYNOPSIS
@@ -269,6 +398,43 @@ function Test-GetDatabaseInternal ($location = "westcentralus")
269398
}
270399
}
271400

401+
<#
402+
.SYNOPSIS
403+
Tests getting a database with zone redundancy.
404+
#>
405+
function Test-GetDatabaseWithZoneRedundancy
406+
{
407+
# Setup
408+
$location = "eastus2"
409+
$rg = Create-ResourceGroupForTest $location
410+
try
411+
{
412+
$server = Create-ServerForTest $rg $location
413+
414+
# Create database with no zone redundancy set
415+
$databaseName = Get-DatabaseName
416+
$db1 = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
417+
-DatabaseName $databaseName -Edition Premium -ZoneRedundant
418+
419+
$gdb1 = Get-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupname -ServerName $server.ServerName -DatabaseName $db1.DatabaseName
420+
Assert-AreEqual $gdb1.DatabaseName $db1.DatabaseName
421+
Assert-AreEqual "true" $gdb1.ZoneRedundant
422+
423+
# Create database with zone redundancy true
424+
$databaseName = Get-DatabaseName
425+
$db2 = New-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName `
426+
-DatabaseName $databaseName -Edition Premium
427+
428+
$gdb2 = Get-AzureRmSqlDatabase -ResourceGroupName $rg.ResourceGroupname -ServerName $server.ServerName -DatabaseName $db2.DatabaseName
429+
Assert-AreEqual $gdb2.DatabaseName $db2.DatabaseName
430+
Assert-AreEqual "false" $gdb2.ZoneRedundant
431+
}
432+
finally
433+
{
434+
Remove-ResourceGroupForTest $rg
435+
}
436+
}
437+
272438

273439
<#
274440
.SYNOPSIS
@@ -333,7 +499,7 @@ function Test-RemoveDatabaseInternal ($location = "westcentralus")
333499
#>
334500
function Test-CancelDatabaseOperation
335501
{
336-
Test-CancelDatabaseOperationInternal "North Europe"
502+
Test-CancelDatabaseOperationInternal
337503
}
338504

339505
<#

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/ElasticPoolCrudTests.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,40 @@ public void TestElasticPoolCreate()
3333
RunPowerShellTest("Test-CreateElasticPool");
3434
}
3535

36+
[Fact]
37+
public void TestElasticPoolCreateWithZoneRedundancy()
38+
{
39+
RunPowerShellTest("Test-CreateElasticPoolWithZoneRedundancy");
40+
}
41+
3642
[Fact]
3743
[Trait(Category.AcceptanceType, Category.CheckIn)]
3844
public void TestElasticPoolUpdate()
3945
{
4046
RunPowerShellTest("Test-UpdateElasticPool");
4147
}
4248

49+
[Fact]
50+
[Trait(Category.AcceptanceType, Category.CheckIn)]
51+
public void TestElasticPoolUpdateWithZoneRedundancy()
52+
{
53+
RunPowerShellTest("Test-UpdateElasticPoolWithZoneRedundancy");
54+
}
55+
4356
[Fact]
4457
[Trait(Category.AcceptanceType, Category.CheckIn)]
4558
public void TestElasticPoolGet()
4659
{
4760
RunPowerShellTest("Test-GetElasticPool");
4861
}
4962

63+
[Fact]
64+
[Trait(Category.AcceptanceType, Category.CheckIn)]
65+
public void TestElasticPoolGetWithZoneRedundancy()
66+
{
67+
RunPowerShellTest("Test-GetElasticPoolWithZoneRedundancy");
68+
}
69+
5070
[Fact]
5171
[Trait(Category.AcceptanceType, Category.CheckIn)]
5272
public void TestElasticPoolRemove()

0 commit comments

Comments
 (0)