Skip to content

Commit beeed80

Browse files
Yashu1818Yash Udasi
andauthored
Add serverless support in new az sql database secondary (#23319)
* Adding serverless params within NewAzureSqlDatabaseSecondary * Updating the New-AzSqlDatabaseSecondary.md file * Adding parameters to test file * Revert "Adding parameters to test file" This reverts commit 7cd8bd3. * Update Changelog.md --------- Co-authored-by: Yash Udasi <[email protected]>
1 parent 34937fa commit beeed80

File tree

6 files changed

+102
-3
lines changed

6 files changed

+102
-3
lines changed

src/Sql/Sql/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
-->
2020
## Upcoming Release
2121
* Fixed `Set-AzSqlDatabaseFailoverGroup` when going from multi-secondary to single secondary
22+
* Added `SecondaryComputeModel`, `AutoPauseDelayInMinutes` and `MinimumCapacity` parameters within `New-AzSqlDatabaseSecondary`
2223

2324
## Version 4.12.0
2425
* Added new parameters `MaintenanceConfigurationId`, `DnsZone` to `AzSqlInstancePool` cmdlets

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

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,16 @@ public class NewAzureSqlDatabaseSecondary : AzureSqlDatabaseSecondaryCmdletBase
124124
[ValidateNotNullOrEmpty]
125125
public string SecondaryComputeGeneration { get; set; }
126126

127+
/// <summary>
128+
/// Gets or sets the compute model for Azure Sql database
129+
/// </summary>
130+
[Parameter(ParameterSetName = VcoreDatabaseParameterSet, Mandatory = false,
131+
HelpMessage="The compute model for secondary database. Serverless or Provisioned")]
132+
[PSArgumentCompleter(
133+
SecondaryDatabaseComputeModel.Provisioned,
134+
SecondaryDatabaseComputeModel.Serverless)]
135+
public string SecondaryComputeModel { get; set; }
136+
127137
/// <summary>
128138
/// Gets or sets the Vcore numbers of the database copy
129139
/// </summary>
@@ -143,6 +153,21 @@ public class NewAzureSqlDatabaseSecondary : AzureSqlDatabaseSecondaryCmdletBase
143153
"BasePrice")]
144154
public string LicenseType { get; set; }
145155

156+
/// <summary>
157+
/// Gets or sets the Auto Pause delay for Azure Sql Database
158+
/// </summary>
159+
[Parameter(Mandatory = false,
160+
HelpMessage = "The auto pause delay in minutes for secondary database(serverless only), -1 to opt out from pausing")]
161+
public int AutoPauseDelayInMinutes { get; set; }
162+
163+
/// <summary>
164+
/// Gets or sets the Minimal capacity that database will always have allocated, if not paused
165+
/// </summary>
166+
[Parameter(Mandatory = false,
167+
HelpMessage = "The Minimal capacity that the secondary database will always have allocated, if not paused. For serverless database only.")]
168+
[Alias("MinVCore", "MinCapacity")]
169+
public double MinimumCapacity { get; set; }
170+
146171
/// <summary>
147172
/// Gets or sets the database backup storage redundancy.
148173
/// </summary>
@@ -278,6 +303,8 @@ protected override IEnumerable<AzureReplicationLinkModel> ApplyUserInputToModel(
278303
AllowConnections = this.AllowConnections,
279304
Tags = TagsConversionHelper.CreateTagDictionary(Tags, validate: true),
280305
LicenseType = LicenseType,
306+
AutoPauseDelayInMinutes = this.IsParameterBound(p => p.AutoPauseDelayInMinutes) ? AutoPauseDelayInMinutes : (int?)null,
307+
MinimumCapacity = this.IsParameterBound(p => p.MinimumCapacity) ? MinimumCapacity : (double?)null,
281308
RequestedBackupStorageRedundancy = this.BackupStorageRedundancy,
282309
SecondaryType = SecondaryType,
283310
HighAvailabilityReplicaCount = this.IsParameterBound(p => p.HighAvailabilityReplicaCount) ? HighAvailabilityReplicaCount : (int?)null,
@@ -305,7 +332,7 @@ protected override IEnumerable<AzureReplicationLinkModel> ApplyUserInputToModel(
305332
}
306333
else
307334
{
308-
linkModel.SkuName = AzureSqlDatabaseAdapter.GetDatabaseSkuName(primaryDb.Edition);
335+
linkModel.SkuName = AzureSqlDatabaseAdapter.GetDatabaseSkuName(primaryDb.Edition, SecondaryComputeModel == SecondaryDatabaseComputeModel.Serverless);
309336
linkModel.Edition = primaryDb.Edition;
310337
linkModel.Capacity = SecondaryVCore;
311338
linkModel.Family = SecondaryComputeGeneration;

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ public class AzureReplicationLinkModel : AzureSqlDatabaseReplicationModelBase
112112
/// </summary>
113113
public string LicenseType { get; set; }
114114

115+
/// <summary>
116+
/// Gets or sets the Auto pause delay of the database
117+
/// </summary>
118+
public int? AutoPauseDelayInMinutes { get; set; }
119+
120+
/// <summary>
121+
/// Minimal capacity that database will always have allocated, if not paused
122+
/// </summary>
123+
public double? MinimumCapacity { get; set; }
124+
115125
/// <summary>
116126
/// Gets or sets the current backup storage redundancy for the database
117127
/// </summary>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace Microsoft.Azure.Commands.Sql.Replication.Model
6+
{
7+
public class SecondaryDatabaseComputeModel
8+
{
9+
public const string Provisioned = "Provisioned";
10+
11+
public const string Serverless = "Serverless";
12+
}
13+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,8 @@ internal AzureReplicationLinkModel CreateLinkWithNewSdk(string resourceGroupName
282282
Capacity = model.Capacity
283283
},
284284
LicenseType = model.LicenseType,
285+
AutoPauseDelay = model.AutoPauseDelayInMinutes,
286+
MinCapacity = model.MinimumCapacity,
285287
RequestedBackupStorageRedundancy = model.RequestedBackupStorageRedundancy,
286288
SecondaryType = model.SecondaryType,
287289
HighAvailabilityReplicaCount = model.HighAvailabilityReplicaCount,

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

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ New-AzSqlDatabaseSecondary [-DatabaseName] <String> [-SecondaryServiceObjectiveN
2929
```
3030
New-AzSqlDatabaseSecondary [-DatabaseName] <String> [-Tags <Hashtable>] -PartnerResourceGroupName <String>
3131
-PartnerServerName <String> [-PartnerDatabaseName <String>] [-AllowConnections <AllowConnections>] [-AsJob]
32-
-SecondaryComputeGeneration <String> -SecondaryVCore <Int32> [-LicenseType <String>]
33-
[-BackupStorageRedundancy <String>] [-SecondaryType <String>] [-HighAvailabilityReplicaCount <Int32>]
32+
-SecondaryComputeGeneration <String> -SecondaryVCore <Int32> [-SecondaryComputeModel <String>] [-LicenseType <String>]
33+
[-AutoPauseDelayInMinutes <Int32>] [-MinimumCapacity <Double>] [-BackupStorageRedundancy <String>] [-SecondaryType <String>] [-HighAvailabilityReplicaCount <Int32>]
3434
[-ZoneRedundant] [-AssignIdentity] [-EncryptionProtector <String>] [-UserAssignedIdentityId <String[]>]
3535
[-KeyList <String[]>] [-FederatedClientId <Guid>] [-EncryptionProtectorAutoRotation] [-ServerName] <String>
3636
[-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
@@ -107,6 +107,21 @@ Accept pipeline input: False
107107
Accept wildcard characters: False
108108
```
109109
110+
### -AutoPauseDelayInMinutes
111+
The auto pause delay in minutes for database(serverless only), -1 to opt out
112+
113+
```yaml
114+
Type: System.Int32
115+
Parameter Sets: (All)
116+
Aliases:
117+
118+
Required: False
119+
Position: Named
120+
Default value: None
121+
Accept pipeline input: False
122+
Accept wildcard characters: False
123+
```
124+
110125
### -BackupStorageRedundancy
111126
The Backup storage redundancy used to store backups for the SQL Database. Options are: Local, Zone and Geo.
112127
@@ -243,6 +258,22 @@ Accept pipeline input: False
243258
Accept wildcard characters: False
244259
```
245260
261+
### -MinimumCapacity
262+
The Minimal capacity that the secondary database will always have allocated, if not paused.
263+
For serverless Azure Sql databases only.
264+
265+
```yaml
266+
Type: System.Double
267+
Parameter Sets: (All)
268+
Aliases: MinVCore, MinCapacity
269+
270+
Required: False
271+
Position: Named
272+
Default value: None
273+
Accept pipeline input: False
274+
Accept wildcard characters: False
275+
```
276+
246277
### -PartnerDatabaseName
247278
The name of the secondary database to create.
248279
@@ -318,6 +349,21 @@ Accept pipeline input: False
318349
Accept wildcard characters: False
319350
```
320351
352+
### -SecondaryComputeModel
353+
The compute model for Azure Sql database secondary. Serverless or Provisioned
354+
355+
```yaml
356+
Type: System.String
357+
Parameter Sets: VcoreBasedDatabase
358+
Aliases:
359+
360+
Required: False
361+
Position: Named
362+
Default value: None
363+
Accept pipeline input: False
364+
Accept wildcard characters: False
365+
```
366+
321367
### -SecondaryElasticPoolName
322368
Specifies the name of the elastic pool in which to put the secondary database.
323369

0 commit comments

Comments
 (0)