Skip to content

Commit

Permalink
Added HAReplicaCount parameter to restore-AzSqlDatabase cmdlet (#20580)
Browse files Browse the repository at this point in the history
* Added HAReplicaCount parameter to restore-AzSqlDatabase cmdlet

* updated changelog

* Update ChangeLog.md

Co-authored-by: Yeming Liu <11371776+isra-fel@users.noreply.github.com>
  • Loading branch information
rebeccaxu-ms and isra-fel authored Jan 17, 2023
1 parent 332c0bd commit fe9757d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 8 deletions.
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 an optional parameter `HAReplicaCount` to `Restore-AzSqlDatabase`

## Version 4.2.0
* Added a parameter named `UseIdentity` for `Set-AzSqlServerAudit`, `Set-AzSqlDatabaseAudit`, `Set-AzSqlServerMSSupportAudit`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ public class RestoreAzureRmSqlDatabase
"BasePrice")]
public string LicenseType { get; set; }

/// <summary>
/// Gets or sets the HA Replica Count option.
/// </summary>
[Parameter(Mandatory = false,
HelpMessage = "The HA Replica Count used to store backups for the SQL Database. Options are: 0, 1, 2.")]
[ValidateRange(0, 2)]
public int HAReplicaCount { get; set; }

/// <summary>
/// Gets or sets the database backup storage redundancy.
/// </summary>
Expand Down Expand Up @@ -382,6 +390,7 @@ protected override AzureSqlDatabaseModel GetEntity()
RequestedBackupStorageRedundancy = BackupStorageRedundancy,
Tags = TagsConversionHelper.CreateTagDictionary(Tag, validate: true),
ZoneRedundant = this.IsParameterBound(p => p.ZoneRedundant) ? ZoneRedundant.ToBool() : (bool?)null,
HighAvailabilityReplicaCount = HAReplicaCount,
};

if (ParameterSetName == FromPointInTimeBackupWithVcoreSetName || ParameterSetName == FromDeletedDatabaseBackupWithVcoreSetName ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,7 @@ internal AzureSqlDatabaseModel RestoreDatabase(string resourceGroup, DateTime re
Capacity = model.Capacity
},
LicenseType = model.LicenseType,
HighAvailabilityReplicaCount = model.HighAvailabilityReplicaCount,
RequestedBackupStorageRedundancy = model.RequestedBackupStorageRedundancy,
ZoneRedundant = model.ZoneRedundant,
Tags = model.Tags
Expand Down
31 changes: 23 additions & 8 deletions src/Sql/Sql/help/Restore-AzSqlDatabase.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Restores a SQL database.
```
Restore-AzSqlDatabase [-FromPointInTimeBackup] -PointInTime <DateTime> -ResourceId <String>
-ServerName <String> -TargetDatabaseName <String> [-Edition <String>] [-ServiceObjectiveName <String>]
[-ElasticPoolName <String>] [-AsJob] [-LicenseType <String>] [-BackupStorageRedundancy <String>]
[-ElasticPoolName <String>] [-AsJob] [-LicenseType <String>] [-HAReplicaCount <Int>] [-BackupStorageRedundancy <String>]
[-ZoneRedundant] [-Tag <Hashtable>] [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [<CommonParameters>]
```
Expand All @@ -26,7 +26,7 @@ Restore-AzSqlDatabase [-FromPointInTimeBackup] -PointInTime <DateTime> -Resource
```
Restore-AzSqlDatabase [-FromPointInTimeBackup] -PointInTime <DateTime> -ResourceId <String>
-ServerName <String> -TargetDatabaseName <String> -Edition <String> [-AsJob] -ComputeGeneration <String>
-VCore <Int32> [-LicenseType <String>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
-VCore <Int32> [-LicenseType <String>] [-HAReplicaCount <Int>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
[-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```
Expand All @@ -36,15 +36,15 @@ Restore-AzSqlDatabase [-FromPointInTimeBackup] -PointInTime <DateTime> -Resource
Restore-AzSqlDatabase [-FromDeletedDatabaseBackup] [-PointInTime <DateTime>] -DeletionDate <DateTime>
-ResourceId <String> -ServerName <String> -TargetDatabaseName <String> [-Edition <String>]
[-ServiceObjectiveName <String>] [-ElasticPoolName <String>] [-AsJob] [-LicenseType <String>]
[-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>] [-ResourceGroupName] <String>
[-HAReplicaCount <Int>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>] [-ResourceGroupName] <String>
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

### FromDeletedDatabaseBackupWithVcore
```
Restore-AzSqlDatabase [-FromDeletedDatabaseBackup] [-PointInTime <DateTime>] -DeletionDate <DateTime>
-ResourceId <String> -ServerName <String> -TargetDatabaseName <String> -Edition <String> [-AsJob]
-ComputeGeneration <String> -VCore <Int32> [-LicenseType <String>] [-BackupStorageRedundancy <String>]
-ComputeGeneration <String> -VCore <Int32> [-LicenseType <String>] [-HAReplicaCount <Int>] [-BackupStorageRedundancy <String>]
[-ZoneRedundant] [-Tag <Hashtable>] [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>]
[-WhatIf] [-Confirm] [<CommonParameters>]
```
Expand All @@ -53,15 +53,15 @@ Restore-AzSqlDatabase [-FromDeletedDatabaseBackup] [-PointInTime <DateTime>] -De
```
Restore-AzSqlDatabase [-FromGeoBackup] -ResourceId <String> -ServerName <String> -TargetDatabaseName <String>
[-Edition <String>] [-ServiceObjectiveName <String>] [-ElasticPoolName <String>] [-AsJob]
[-LicenseType <String>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
[-LicenseType <String>] [-HAReplicaCount <Int>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
[-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```

### FromGeoBackupWithVcore
```
Restore-AzSqlDatabase [-FromGeoBackup] -ResourceId <String> -ServerName <String> -TargetDatabaseName <String>
-Edition <String> [-AsJob] -ComputeGeneration <String> -VCore <Int32> [-LicenseType <String>]
-Edition <String> [-AsJob] -ComputeGeneration <String> -VCore <Int32> [-LicenseType <String>] [-HAReplicaCount <Int>]
[-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>] [-ResourceGroupName] <String>
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```
Expand All @@ -70,7 +70,7 @@ Restore-AzSqlDatabase [-FromGeoBackup] -ResourceId <String> -ServerName <String>
```
Restore-AzSqlDatabase [-FromLongTermRetentionBackup] -ResourceId <String> -ServerName <String>
-TargetDatabaseName <String> [-Edition <String>] [-ServiceObjectiveName <String>] [-ElasticPoolName <String>]
[-AsJob] [-LicenseType <String>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
[-AsJob] [-LicenseType <String>] [-HAReplicaCount <Int>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
[-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```
Expand All @@ -79,7 +79,7 @@ Restore-AzSqlDatabase [-FromLongTermRetentionBackup] -ResourceId <String> -Serve
```
Restore-AzSqlDatabase [-FromLongTermRetentionBackup] -ResourceId <String> -ServerName <String>
-TargetDatabaseName <String> -Edition <String> [-AsJob] -ComputeGeneration <String> -VCore <Int32>
[-LicenseType <String>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
[-LicenseType <String>] [-HAReplicaCount <Int>] [-BackupStorageRedundancy <String>] [-ZoneRedundant] [-Tag <Hashtable>]
[-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
```
Expand Down Expand Up @@ -329,6 +329,21 @@ Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -HAReplicaCount
The high availability replica count to associate with the Azure Sql Database.
```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:
Accepted values: 0, 1, 2

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 fe9757d

Please sign in to comment.