Skip to content

Commit fe9757d

Browse files
Added HAReplicaCount parameter to restore-AzSqlDatabase cmdlet (#20580)
* Added HAReplicaCount parameter to restore-AzSqlDatabase cmdlet * updated changelog * Update ChangeLog.md Co-authored-by: Yeming Liu <[email protected]>
1 parent 332c0bd commit fe9757d

File tree

4 files changed

+34
-8
lines changed

4 files changed

+34
-8
lines changed

src/Sql/Sql/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Additional information about change #1
1919
-->
2020
## Upcoming Release
21+
* Added an optional parameter `HAReplicaCount` to `Restore-AzSqlDatabase`
2122

2223
## Version 4.2.0
2324
* Added a parameter named `UseIdentity` for `Set-AzSqlServerAudit`, `Set-AzSqlDatabaseAudit`, `Set-AzSqlServerMSSupportAudit`

src/Sql/Sql/Database Backup/Cmdlet/RestoreAzureRMSqlDatabase.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,14 @@ public class RestoreAzureRmSqlDatabase
280280
"BasePrice")]
281281
public string LicenseType { get; set; }
282282

283+
/// <summary>
284+
/// Gets or sets the HA Replica Count option.
285+
/// </summary>
286+
[Parameter(Mandatory = false,
287+
HelpMessage = "The HA Replica Count used to store backups for the SQL Database. Options are: 0, 1, 2.")]
288+
[ValidateRange(0, 2)]
289+
public int HAReplicaCount { get; set; }
290+
283291
/// <summary>
284292
/// Gets or sets the database backup storage redundancy.
285293
/// </summary>
@@ -382,6 +390,7 @@ protected override AzureSqlDatabaseModel GetEntity()
382390
RequestedBackupStorageRedundancy = BackupStorageRedundancy,
383391
Tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true),
384392
ZoneRedundant = this.IsParameterBound(p => p.ZoneRedundant) ? ZoneRedundant.ToBool() : (bool?)null,
393+
HighAvailabilityReplicaCount = HAReplicaCount,
385394
};
386395

387396
if (ParameterSetName == FromPointInTimeBackupWithVcoreSetName || ParameterSetName == FromDeletedDatabaseBackupWithVcoreSetName ||

src/Sql/Sql/Database Backup/Services/AzureSqlDatabaseBackupAdapter.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ internal AzureSqlDatabaseModel RestoreDatabase(string resourceGroup, DateTime re
592592
Capacity = model.Capacity
593593
},
594594
LicenseType = model.LicenseType,
595+
HighAvailabilityReplicaCount = model.HighAvailabilityReplicaCount,
595596
RequestedBackupStorageRedundancy = model.RequestedBackupStorageRedundancy,
596597
ZoneRedundant = model.ZoneRedundant,
597598
Tags = model.Tags

src/Sql/Sql/help/Restore-AzSqlDatabase.md

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Restores a SQL database.
1717
```
1818
Restore-AzSqlDatabase [-FromPointInTimeBackup] -PointInTime <DateTime> -ResourceId <String>
1919
-ServerName <String> -TargetDatabaseName <String> [-Edition <String>] [-ServiceObjectiveName <String>]
20-
[-ElasticPoolName <String>] [-AsJob] [-LicenseType <String>] [-BackupStorageRedundancy <String>]
20+
[-ElasticPoolName <String>] [-AsJob] [-LicenseType <String>] [-HAReplicaCount <Int>] [-BackupStorageRedundancy <String>]
2121
[-ZoneRedundant] [-Tag <Hashtable>] [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>]
2222
[-WhatIf] [-Confirm] [<CommonParameters>]
2323
```
@@ -26,7 +26,7 @@ Restore-AzSqlDatabase [-FromPointInTimeBackup] -PointInTime <DateTime> -Resource
2626
```
2727
Restore-AzSqlDatabase [-FromPointInTimeBackup] -PointInTime <DateTime> -ResourceId <String>
2828
-ServerName <String> -TargetDatabaseName <String> -Edition <String> [-AsJob] -ComputeGeneration <String>
29-
-VCore <Int32> [-LicenseType <String>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
29+
-VCore <Int32> [-LicenseType <String>] [-HAReplicaCount <Int>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
3030
[-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
3131
[<CommonParameters>]
3232
```
@@ -36,15 +36,15 @@ Restore-AzSqlDatabase [-FromPointInTimeBackup] -PointInTime <DateTime> -Resource
3636
Restore-AzSqlDatabase [-FromDeletedDatabaseBackup] [-PointInTime <DateTime>] -DeletionDate <DateTime>
3737
-ResourceId <String> -ServerName <String> -TargetDatabaseName <String> [-Edition <String>]
3838
[-ServiceObjectiveName <String>] [-ElasticPoolName <String>] [-AsJob] [-LicenseType <String>]
39-
[-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>] [-ResourceGroupName] <String>
39+
[-HAReplicaCount <Int>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>] [-ResourceGroupName] <String>
4040
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
4141
```
4242

4343
### FromDeletedDatabaseBackupWithVcore
4444
```
4545
Restore-AzSqlDatabase [-FromDeletedDatabaseBackup] [-PointInTime <DateTime>] -DeletionDate <DateTime>
4646
-ResourceId <String> -ServerName <String> -TargetDatabaseName <String> -Edition <String> [-AsJob]
47-
-ComputeGeneration <String> -VCore <Int32> [-LicenseType <String>] [-BackupStorageRedundancy <String>]
47+
-ComputeGeneration <String> -VCore <Int32> [-LicenseType <String>] [-HAReplicaCount <Int>] [-BackupStorageRedundancy <String>]
4848
[-ZoneRedundant] [-Tag <Hashtable>] [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>]
4949
[-WhatIf] [-Confirm] [<CommonParameters>]
5050
```
@@ -53,15 +53,15 @@ Restore-AzSqlDatabase [-FromDeletedDatabaseBackup] [-PointInTime <DateTime>] -De
5353
```
5454
Restore-AzSqlDatabase [-FromGeoBackup] -ResourceId <String> -ServerName <String> -TargetDatabaseName <String>
5555
[-Edition <String>] [-ServiceObjectiveName <String>] [-ElasticPoolName <String>] [-AsJob]
56-
[-LicenseType <String>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
56+
[-LicenseType <String>] [-HAReplicaCount <Int>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
5757
[-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
5858
[<CommonParameters>]
5959
```
6060

6161
### FromGeoBackupWithVcore
6262
```
6363
Restore-AzSqlDatabase [-FromGeoBackup] -ResourceId <String> -ServerName <String> -TargetDatabaseName <String>
64-
-Edition <String> [-AsJob] -ComputeGeneration <String> -VCore <Int32> [-LicenseType <String>]
64+
-Edition <String> [-AsJob] -ComputeGeneration <String> -VCore <Int32> [-LicenseType <String>] [-HAReplicaCount <Int>]
6565
[-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>] [-ResourceGroupName] <String>
6666
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
6767
```
@@ -70,7 +70,7 @@ Restore-AzSqlDatabase [-FromGeoBackup] -ResourceId <String> -ServerName <String>
7070
```
7171
Restore-AzSqlDatabase [-FromLongTermRetentionBackup] -ResourceId <String> -ServerName <String>
7272
-TargetDatabaseName <String> [-Edition <String>] [-ServiceObjectiveName <String>] [-ElasticPoolName <String>]
73-
[-AsJob] [-LicenseType <String>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
73+
[-AsJob] [-LicenseType <String>] [-HAReplicaCount <Int>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
7474
[-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
7575
[<CommonParameters>]
7676
```
@@ -79,7 +79,7 @@ Restore-AzSqlDatabase [-FromLongTermRetentionBackup] -ResourceId <String> -Serve
7979
```
8080
Restore-AzSqlDatabase [-FromLongTermRetentionBackup] -ResourceId <String> -ServerName <String>
8181
-TargetDatabaseName <String> -Edition <String> [-AsJob] -ComputeGeneration <String> -VCore <Int32>
82-
[-LicenseType <String>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
82+
[-LicenseType <String>] [-HAReplicaCount <Int>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
8383
[-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
8484
[<CommonParameters>]
8585
```
@@ -329,6 +329,21 @@ Default value: None
329329
Accept pipeline input: False
330330
Accept wildcard characters: False
331331
```
332+
### -HAReplicaCount
333+
The high availability replica count to associate with the Azure Sql Database.
334+
335+
```yaml
336+
Type: System.Management.Automation.SwitchParameter
337+
Parameter Sets: (All)
338+
Aliases:
339+
Accepted values: 0, 1, 2
340+
341+
Required: False
342+
Position: Named
343+
Default value: None
344+
Accept pipeline input: False
345+
Accept wildcard characters: False
346+
```
332347
333348
### -LicenseType
334349
The license type for the Azure Sql database.

0 commit comments

Comments
 (0)