Skip to content

Commit 7fb0ff3

Browse files
committed
Add HA replica param
1 parent 388e6a3 commit 7fb0ff3

File tree

7 files changed

+1394
-2267
lines changed

7 files changed

+1394
-2267
lines changed

src/Sql/Sql.Test/ScenarioTests/DatabaseReplicationTests.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,10 +196,12 @@ function Test-CreateNamedSecondaryDatabase()
196196

197197
# Create Named Replica
198198
$namedReplica = New-AzSqlDatabaseSecondary -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName $hsDatabase.DatabaseName `
199-
-PartnerResourceGroupName $rg.ResourceGroupName -PartnerServerName $server.ServerName -PartnerDatabaseName "secondary" -SecondaryType "Named"
199+
-PartnerResourceGroupName $rg.ResourceGroupName -PartnerServerName $server.ServerName -PartnerDatabaseName "secondary" -SecondaryType "Named" `
200+
-HighAvailabilityReplicaCount 2
200201

201202
$newDb = Get-AzSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName "secondary"
202203
Assert-AreEqual "Named" $newDb.SecondaryType
204+
Assert-AreEqual 2 $newDb.HighAvailabilityReplicaCount
203205
}
204206
finally
205207
{

src/Sql/Sql.Test/SessionRecords/Microsoft.Azure.Commands.Sql.Test.ScenarioTests.DatabaseReplicationTests/TestCreateNamedSecondaryDatabase.json

Lines changed: 1353 additions & 2259 deletions
Large diffs are not rendered by default.

src/Sql/Sql/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
- Update Backup Storage Redundancy values for LTR backups
2626
* Added CurrentBackupStorageRedundancy, RequestedBackupStorageRedundancy to `Get-AzSqlDatabase`, `New-AzSqlDatabase`, `Set-AzSqlDatabase`, `New-AzSqlDatabaseSecondary`, `Set-AzSqlDatabaseSecondary`, `New-AzSqlDatabaseCopy`
2727
- Changed BackupStorageRedundancy value to CurrentBackupStorageRedundancy, RequestedBackupStorageRedundancy to reflect both the current value and what has been requested if a change was made
28+
* Added HighAvailabilityReplicaCount to `New-AzSqlDatabaseSecondary`
2829

2930
## Version 2.17.1
3031
* Added cmdlet output breaking change warnings to the following:

src/Sql/Sql/Replication/Cmdlet/NewAzureSqlDatabaseSecondary.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using System.Management.Automation;
2525
using System.Globalization;
2626
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
27+
using Microsoft.WindowsAzure.Commands.Utilities.Common;
2728
using System;
2829

2930
namespace Microsoft.Azure.Commands.Sql.Replication.Cmdlet
@@ -163,6 +164,13 @@ public class NewAzureSqlDatabaseSecondary : AzureSqlDatabaseSecondaryCmdletBase
163164
[ValidateSet("Named", "Geo")]
164165
public string SecondaryType { get; set; }
165166

167+
/// <summary>
168+
/// Gets or sets the number of high availability readonly replicas for the Azure Sql database
169+
/// </summary>
170+
[Parameter(Mandatory = false,
171+
HelpMessage = "The number of readonly secondary replicas associated with the database to which readonly application intent connections may be routed. This property is only settable for Hyperscale edition databases.")]
172+
public int HighAvailabilityReplicaCount { get; set; }
173+
166174
protected static readonly string[] ListOfRegionsToShowWarningMessageForGeoBackupStorage = { "eastasia", "southeastasia", "brazilsouth", "east asia", "southeast asia", "brazil south" };
167175

168176
/// <summary>
@@ -242,6 +250,7 @@ protected override IEnumerable<AzureReplicationLinkModel> ApplyUserInputToModel(
242250
LicenseType = LicenseType,
243251
RequestedBackupStorageRedundancy = this.BackupStorageRedundancy,
244252
SecondaryType = SecondaryType,
253+
HighAvailabilityReplicaCount = this.IsParameterBound(p => p.HighAvailabilityReplicaCount) ? HighAvailabilityReplicaCount : (int?)null,
245254
};
246255

247256
if(ParameterSetName == DtuDatabaseParameterSet)

src/Sql/Sql/Replication/Model/AzureReplicationLinkModel.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,13 @@ public class AzureReplicationLinkModel : AzureSqlDatabaseReplicationModelBase
123123
public string RequestedBackupStorageRedundancy { get; set; }
124124

125125
/// <summary>
126-
/// Gets or sets the secondary type for the database if it is a secondary.
126+
/// Gets or sets the secondary type for the database if it is a secondary
127127
/// </summary>
128128
public string SecondaryType { get; set; }
129+
130+
/// <summary>
131+
/// Gets or sets the number of high availability replicas for the database
132+
/// </summary>
133+
public int? HighAvailabilityReplicaCount { get; set; }
129134
}
130135
}

src/Sql/Sql/Replication/Services/AzureSqlDatabaseReplicationAdapter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ internal AzureReplicationLinkModel CreateLinkWithNewSdk(string resourceGroupName
275275
LicenseType = model.LicenseType,
276276
RequestedBackupStorageRedundancy = model.RequestedBackupStorageRedundancy,
277277
SecondaryType = model.SecondaryType,
278+
HighAvailabilityReplicaCount = model.HighAvailabilityReplicaCount,
278279
});
279280

280281
return GetLink(model.ResourceGroupName, model.ServerName, model.DatabaseName, model.PartnerResourceGroupName, model.PartnerServerName);

src/Sql/Sql/help/New-AzSqlDatabaseSecondary.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,19 @@ Creates a secondary database for an existing database and starts data replicatio
1818
New-AzSqlDatabaseSecondary [-DatabaseName] <String> [-SecondaryServiceObjectiveName <String>]
1919
[-SecondaryElasticPoolName <String>] [-Tags <Hashtable>] -PartnerResourceGroupName <String>
2020
-PartnerServerName <String> [-PartnerDatabaseName <String>] [-AllowConnections <AllowConnections>] [-AsJob]
21-
[-LicenseType <String>] [-BackupStorageRedundancy <String>] [-SecondaryType <String>] [-ServerName] <String>
22-
[-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
23-
[<CommonParameters>]
21+
[-LicenseType <String>] [-BackupStorageRedundancy <String>] [-SecondaryType <String>]
22+
[-HighAvailabilityReplicaCount <Int32>] [-ServerName] <String> [-ResourceGroupName] <String>
23+
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
2424
```
2525

2626
### VcoreBasedDatabase
2727
```
2828
New-AzSqlDatabaseSecondary [-DatabaseName] <String> [-Tags <Hashtable>] -PartnerResourceGroupName <String>
2929
-PartnerServerName <String> [-PartnerDatabaseName <String>] [-AllowConnections <AllowConnections>] [-AsJob]
3030
-SecondaryComputeGeneration <String> -SecondaryVCore <Int32> [-LicenseType <String>]
31-
[-BackupStorageRedundancy <String>] [-SecondaryType <String>] [-ServerName] <String>
32-
[-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
33-
[<CommonParameters>]
31+
[-BackupStorageRedundancy <String>] [-SecondaryType <String>] [-HighAvailabilityReplicaCount <Int32>]
32+
[-ServerName] <String> [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
33+
[-Confirm] [<CommonParameters>]
3434
```
3535

3636
## DESCRIPTION
@@ -134,6 +134,21 @@ Accept pipeline input: False
134134
Accept wildcard characters: False
135135
```
136136
137+
### -HighAvailabilityReplicaCount
138+
The number of readonly secondary replicas associated with the database to which readonly application intent connections may be routed. This property is only settable for Hyperscale edition databases.
139+
140+
```yaml
141+
Type: System.Int32
142+
Parameter Sets: (All)
143+
Aliases:
144+
145+
Required: False
146+
Position: Named
147+
Default value: None
148+
Accept pipeline input: False
149+
Accept wildcard characters: False
150+
```
151+
137152
### -LicenseType
138153
The license type for the Azure Sql database.
139154

0 commit comments

Comments
 (0)