Skip to content

Commit

Permalink
Add HighAvailabilityReplicaCount to New-AzSqlDatabaseSecondary (#15079)
Browse files Browse the repository at this point in the history
* Add HA replica param

* Update ChangeLog.md

Co-authored-by: Jin Lei <54836179+msJinLei@users.noreply.github.com>
  • Loading branch information
bradrich-msft and msJinLei authored May 24, 2021
1 parent 9842f2a commit db10eec
Show file tree
Hide file tree
Showing 7 changed files with 1,394 additions and 2,267 deletions.
4 changes: 3 additions & 1 deletion src/Sql/Sql.Test/ScenarioTests/DatabaseReplicationTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,12 @@ function Test-CreateNamedSecondaryDatabase()

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

$newDb = Get-AzSqlDatabase -ResourceGroupName $rg.ResourceGroupName -ServerName $server.ServerName -DatabaseName "secondary"
Assert-AreEqual "Named" $newDb.SecondaryType
Assert-AreEqual 2 $newDb.HighAvailabilityReplicaCount
}
finally
{
Expand Down

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/Sql/Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Upcoming Release
* Added HighAvailabilityReplicaCount to `New-AzSqlDatabaseSecondary`
* Updated `Set-AzSqlDatabaseVulnerabilityAssessmentRuleBaseline` documentation to include example of define array of array with one inner array.
* Added cmdlet `Copy-AzSqlDatabaseLongTermRetentionBackup`
- Copy LTR backups to different servers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using System.Management.Automation;
using System.Globalization;
using Microsoft.WindowsAzure.Commands.Common.CustomAttributes;
using Microsoft.WindowsAzure.Commands.Utilities.Common;
using System;

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

/// <summary>
/// Gets or sets the number of high availability readonly replicas for the Azure Sql database
/// </summary>
[Parameter(Mandatory = false,
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.")]
public int HighAvailabilityReplicaCount { get; set; }

protected static readonly string[] ListOfRegionsToShowWarningMessageForGeoBackupStorage = { "eastasia", "southeastasia", "brazilsouth", "east asia", "southeast asia", "brazil south" };

/// <summary>
Expand Down Expand Up @@ -242,6 +250,7 @@ protected override IEnumerable<AzureReplicationLinkModel> ApplyUserInputToModel(
LicenseType = LicenseType,
RequestedBackupStorageRedundancy = this.BackupStorageRedundancy,
SecondaryType = SecondaryType,
HighAvailabilityReplicaCount = this.IsParameterBound(p => p.HighAvailabilityReplicaCount) ? HighAvailabilityReplicaCount : (int?)null,
};

if(ParameterSetName == DtuDatabaseParameterSet)
Expand Down
7 changes: 6 additions & 1 deletion src/Sql/Sql/Replication/Model/AzureReplicationLinkModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,13 @@ public class AzureReplicationLinkModel : AzureSqlDatabaseReplicationModelBase
public string RequestedBackupStorageRedundancy { get; set; }

/// <summary>
/// Gets or sets the secondary type for the database if it is a secondary.
/// Gets or sets the secondary type for the database if it is a secondary
/// </summary>
public string SecondaryType { get; set; }

/// <summary>
/// Gets or sets the number of high availability replicas for the database
/// </summary>
public int? HighAvailabilityReplicaCount { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ internal AzureReplicationLinkModel CreateLinkWithNewSdk(string resourceGroupName
LicenseType = model.LicenseType,
RequestedBackupStorageRedundancy = model.RequestedBackupStorageRedundancy,
SecondaryType = model.SecondaryType,
HighAvailabilityReplicaCount = model.HighAvailabilityReplicaCount,
});

return GetLink(model.ResourceGroupName, model.ServerName, model.DatabaseName, model.PartnerResourceGroupName, model.PartnerServerName);
Expand Down
27 changes: 21 additions & 6 deletions src/Sql/Sql/help/New-AzSqlDatabaseSecondary.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ Creates a secondary database for an existing database and starts data replicatio
New-AzSqlDatabaseSecondary [-DatabaseName] <String> [-SecondaryServiceObjectiveName <String>]
[-SecondaryElasticPoolName <String>] [-Tags <Hashtable>] -PartnerResourceGroupName <String>
-PartnerServerName <String> [-PartnerDatabaseName <String>] [-AllowConnections <AllowConnections>] [-AsJob]
[-LicenseType <String>] [-BackupStorageRedundancy <String>] [-SecondaryType <String>] [-ServerName] <String>
[-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-LicenseType <String>] [-BackupStorageRedundancy <String>] [-SecondaryType <String>]
[-HighAvailabilityReplicaCount <Int32>] [-ServerName] <String> [-ResourceGroupName] <String>
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### VcoreBasedDatabase
```
New-AzSqlDatabaseSecondary [-DatabaseName] <String> [-Tags <Hashtable>] -PartnerResourceGroupName <String>
-PartnerServerName <String> [-PartnerDatabaseName <String>] [-AllowConnections <AllowConnections>] [-AsJob]
-SecondaryComputeGeneration <String> -SecondaryVCore <Int32> [-LicenseType <String>]
[-BackupStorageRedundancy <String>] [-SecondaryType <String>] [-ServerName] <String>
[-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-BackupStorageRedundancy <String>] [-SecondaryType <String>] [-HighAvailabilityReplicaCount <Int32>]
[-ServerName] <String> [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

## DESCRIPTION
Expand Down Expand Up @@ -134,6 +134,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```
### -HighAvailabilityReplicaCount
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.
```yaml
Type: System.Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -LicenseType
The license type for the Azure Sql database.
Expand Down

0 comments on commit db10eec

Please sign in to comment.