Skip to content

Commit ecd535b

Browse files
authored
Merge pull request #8085 from maddieclayton/sqlbc2
Sql breaking change part 2
2 parents 144ecdc + 86ee05f commit ecd535b

File tree

8 files changed

+33
-187
lines changed

8 files changed

+33
-187
lines changed

src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/DatabaseBackupTests.ps1

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,6 @@ function Test-RestorePointInTimeBackup
121121
-ServerName $db.ServerName -ResourceId $db.ResourceId -Edition 'GeneralPurpose' -VCore 2 -ComputeGeneration 'Gen4'
122122
}
123123

124-
# TODO: Deprecate LTRv1
125-
function Test-DatabaseBackupLongTermRetentionPolicy
126-
{
127-
$location = "North Europe"
128-
$serverVersion = "12.0"
129-
$rg = Get-AzureRmResourceGroup -ResourceGroupName hchung
130-
$server = Get-AzureRmSqlServer -ServerName hchung-testsvr -ResourceGroupName $rg.ResourceGroupName
131-
$db = Get-AzureRmSqlDatabase -ServerName $server.ServerName -DatabaseName hchung-testdb -ResourceGroupName $rg.ResourceGroupName
132-
$policyResourceId = "/subscriptions/e5e8af86-2d93-4ebd-8eb5-3b0184daa9de/resourceGroups/hchung/providers/Microsoft.RecoveryServices/vaults/hchung-testvault/backupPolicies/hchung-testpolicy"
133-
134-
# set
135-
Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ServerName $server.ServerName -ResourceGroupName $rg.ResourceGroupName `
136-
-DatabaseName $db.DatabaseName -State "Enabled" -ResourceId $policyResourceId
137-
# get
138-
$result = Get-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ServerName $server.ServerName -ResourceGroupName $rg.ResourceGroupName -DatabaseName $db.DatabaseName
139-
#verify
140-
Assert-True { $result.RecoveryServicesBackupPolicyResourceId -eq $policyResourceId }
141-
}
142-
143124
# LTR-V1 restore tests need to be removed once the service is retired completely
144125
# TODO update for LTRv2 backup
145126
function Test-RestoreLongTermRetentionBackup

src/ResourceManager/Sql/Commands.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
## Current Release
21+
* Removed -State and -ResourceId parameters from Set-AzSqlDatabaseBackupLongTermRetentionPolicy
2122
* Removed deprecated cmdlets: Get/Set-AzSqlServerBackupLongTermRetentionVault, Get/Start/Stop-AzSqlServerUpgrade, Get/Set-AzSqlDatabaseAuditingPolicy, Get/Set-AzSqlServerAuditingPolicy, Remove-AzSqlDatabaseAuditing, Remove-AzSqlServerAuditing
2223
* Removed deprecated parameter "Current" from Get-AzSqlDatabaseBackupLongTermRetentionPolicy
2324
* Removed deprecated parameter "DatabaseName" from Get-AzSqlServerServiceObjective

src/ResourceManager/Sql/Commands.Sql/Database Backup/Cmdlet/GetAzureSqlDatabaseBackupLongTermRetentionPolicy.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ protected override IEnumerable<AzureSqlDatabaseBackupLongTermRetentionPolicyMode
3838
ModelAdapter.GetDatabaseBackupLongTermRetentionPolicy(
3939
this.ResourceGroupName,
4040
this.ServerName,
41-
this.DatabaseName,
42-
current: true)
41+
this.DatabaseName)
4342
};
4443
}
4544

src/ResourceManager/Sql/Commands.Sql/Database Backup/Cmdlet/SetAzureSqlDatabaseBackupLongTermRetentionPolicy.cs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -52,36 +52,6 @@ public class SetAzureSqlDatabaseBackupLongTermRetentionPolicy : AzureSqlDatabase
5252
/// </summary>
5353
private const string RemovePolicySet = "RemovePolicy";
5454

55-
/// <summary>
56-
/// Parameter set for setting the legacy long term retention policy.
57-
/// </summary>
58-
private const string LegacySet = "Legacy";
59-
60-
/// <summary>
61-
/// Gets or sets the backup long term retention state
62-
/// </summary>
63-
[CmdletParameterBreakingChange("State", "Parameter is being deprecated without being replaced.")]
64-
[Parameter(Mandatory = true,
65-
ParameterSetName = LegacySet,
66-
HelpMessage = "The state of the long term retention backup policy, 'Enabled' or 'Disabled'")]
67-
[ValidateNotNullOrEmpty]
68-
public string State { get; set; }
69-
70-
/// <summary>
71-
/// Gets or sets the name of the backup long term retention policy
72-
/// </summary>
73-
/// <remarks>
74-
/// The upcoming breaking change will need some logic changes of how the ResourceId is handled. Contact adeal or pixia for assistance.
75-
/// </remarks>
76-
[CmdletParameterBreakingChange("ResourceId", "ResourceId will no longer refer to RecoveryServicesBackupPolicyResourceId as it is no longer needed. Instead, it will refer to the ResourceId of the long term retention policy being set.")]
77-
[Parameter(Mandatory = true,
78-
ParameterSetName = LegacySet,
79-
ValueFromPipelineByPropertyName = true,
80-
HelpMessage = "The Resource ID of the backup long term retention policy.")]
81-
[ValidateNotNullOrEmpty]
82-
[Alias("Id")]
83-
public string ResourceId { get; set; }
84-
8555
/// <summary>
8656
/// Gets or sets whether or not to clear the Long Term Retention V2 policy.
8757
/// </summary>
@@ -153,8 +123,7 @@ protected override IEnumerable<AzureSqlDatabaseBackupLongTermRetentionPolicyMode
153123
ModelAdapter.GetDatabaseBackupLongTermRetentionPolicy(
154124
this.ResourceGroupName,
155125
this.ServerName,
156-
this.DatabaseName,
157-
!ParameterSetName.Equals(LegacySet))
126+
this.DatabaseName)
158127
};
159128
}
160129

@@ -197,8 +166,6 @@ protected override IEnumerable<AzureSqlDatabaseBackupLongTermRetentionPolicyMode
197166
ResourceGroupName = ResourceGroupName,
198167
ServerName = ServerName,
199168
DatabaseName = DatabaseName,
200-
State = State,
201-
RecoveryServicesBackupPolicyResourceId = ResourceId,
202169
Location = model.FirstOrDefault().Location,
203170
WeeklyRetention = WeeklyRetention,
204171
MonthlyRetention = MonthlyRetention,

src/ResourceManager/Sql/Commands.Sql/Database Backup/Model/AzureSqlDatabaseBackupLongTermRetentionPolicyModel.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,6 @@ public class AzureSqlDatabaseBackupLongTermRetentionPolicyModel
4141
/// </summary>
4242
public int? WeekOfYear { get; set; }
4343

44-
/// <summary>
45-
/// Gets or sets the backup archival state
46-
/// </summary>
47-
public string State { get; set; }
48-
49-
/// <summary>
50-
/// Gets or sets the backup archival policy resource ID
51-
/// </summary>
52-
public string RecoveryServicesBackupPolicyResourceId { get; set; }
53-
5444
/// <summary>
5545
/// Gets or sets the location
5646
/// </summary>

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

Lines changed: 23 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -260,43 +260,22 @@ internal AzureSqlServerBackupLongTermRetentionVaultModel GetBackupLongTermRetent
260260
internal AzureSqlDatabaseBackupLongTermRetentionPolicyModel GetDatabaseBackupLongTermRetentionPolicy(
261261
string resourceGroup,
262262
string serverName,
263-
string databaseName,
264-
bool current)
263+
string databaseName)
265264
{
266-
if (!current)
267-
{
268-
var baPolicy = Communicator.GetDatabaseBackupLongTermRetentionPolicy(
269-
resourceGroup,
270-
serverName,
271-
databaseName,
272-
"Default");
273-
return new AzureSqlDatabaseBackupLongTermRetentionPolicyModel()
274-
{
275-
Location = baPolicy.Location,
276-
ResourceGroupName = resourceGroup,
277-
ServerName = serverName,
278-
DatabaseName = databaseName,
279-
State = baPolicy.Properties.State,
280-
RecoveryServicesBackupPolicyResourceId = baPolicy.Properties.RecoveryServicesBackupPolicyResourceId,
281-
};
282-
}
283-
else
284-
{
285-
Management.Sql.Models.BackupLongTermRetentionPolicy response = Communicator.GetDatabaseLongTermRetentionPolicy(
265+
Management.Sql.Models.BackupLongTermRetentionPolicy response = Communicator.GetDatabaseLongTermRetentionPolicy(
286266
resourceGroup,
287267
serverName,
288268
databaseName);
289-
return new AzureSqlDatabaseBackupLongTermRetentionPolicyModel()
290-
{
291-
ResourceGroupName = resourceGroup,
292-
ServerName = serverName,
293-
DatabaseName = databaseName,
294-
WeeklyRetention = response.WeeklyRetention,
295-
MonthlyRetention = response.MonthlyRetention,
296-
YearlyRetention = response.YearlyRetention,
297-
WeekOfYear = response.WeekOfYear
298-
};
299-
}
269+
return new AzureSqlDatabaseBackupLongTermRetentionPolicyModel()
270+
{
271+
ResourceGroupName = resourceGroup,
272+
ServerName = serverName,
273+
DatabaseName = databaseName,
274+
WeeklyRetention = response.WeeklyRetention,
275+
MonthlyRetention = response.MonthlyRetention,
276+
YearlyRetention = response.YearlyRetention,
277+
WeekOfYear = response.WeekOfYear
278+
};
300279
}
301280

302281
/// <summary>
@@ -344,35 +323,7 @@ internal AzureSqlDatabaseBackupLongTermRetentionPolicyModel SetDatabaseBackupLon
344323
string databaseName,
345324
AzureSqlDatabaseBackupLongTermRetentionPolicyModel model)
346325
{
347-
if (!string.IsNullOrWhiteSpace(model.RecoveryServicesBackupPolicyResourceId))
348-
{
349-
var baPolicy = Communicator.SetDatabaseBackupLongTermRetentionPolicy(
350-
resourceGroup,
351-
serverName,
352-
databaseName,
353-
"Default",
354-
new DatabaseBackupLongTermRetentionPolicyCreateOrUpdateParameters()
355-
{
356-
Location = model.Location,
357-
Properties = new DatabaseBackupLongTermRetentionPolicyProperties()
358-
{
359-
State = model.State,
360-
RecoveryServicesBackupPolicyResourceId = model.RecoveryServicesBackupPolicyResourceId,
361-
}
362-
});
363-
return new AzureSqlDatabaseBackupLongTermRetentionPolicyModel()
364-
{
365-
Location = baPolicy.Location,
366-
ResourceGroupName = resourceGroup,
367-
ServerName = serverName,
368-
DatabaseName = databaseName,
369-
State = baPolicy.Properties.State,
370-
RecoveryServicesBackupPolicyResourceId = baPolicy.Properties.RecoveryServicesBackupPolicyResourceId,
371-
};
372-
}
373-
else
374-
{
375-
Management.Sql.Models.BackupLongTermRetentionPolicy response = Communicator.SetDatabaseLongTermRetentionPolicy(
326+
Management.Sql.Models.BackupLongTermRetentionPolicy response = Communicator.SetDatabaseLongTermRetentionPolicy(
376327
resourceGroup,
377328
serverName,
378329
databaseName,
@@ -383,17 +334,16 @@ internal AzureSqlDatabaseBackupLongTermRetentionPolicyModel SetDatabaseBackupLon
383334
YearlyRetention = model.YearlyRetention,
384335
WeekOfYear = model.WeekOfYear
385336
});
386-
return new AzureSqlDatabaseBackupLongTermRetentionPolicyModel()
387-
{
388-
ResourceGroupName = resourceGroup,
389-
ServerName = serverName,
390-
DatabaseName = databaseName,
391-
WeeklyRetention = response.WeeklyRetention,
392-
MonthlyRetention = response.MonthlyRetention,
393-
YearlyRetention = response.YearlyRetention,
394-
WeekOfYear = response.WeekOfYear
395-
};
396-
}
337+
return new AzureSqlDatabaseBackupLongTermRetentionPolicyModel()
338+
{
339+
ResourceGroupName = resourceGroup,
340+
ServerName = serverName,
341+
DatabaseName = databaseName,
342+
WeeklyRetention = response.WeeklyRetention,
343+
MonthlyRetention = response.MonthlyRetention,
344+
YearlyRetention = response.YearlyRetention,
345+
WeekOfYear = response.WeekOfYear
346+
};
397347
}
398348

399349
/// <summary>

src/ResourceManager/Sql/Commands.Sql/help/Set-AzSqlDatabaseBackupLongTermRetentionPolicy.md

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,6 @@ Set-AzSqlDatabaseBackupLongTermRetentionPolicy -WeeklyRetention <String> [-Serve
1919
[-Confirm] [<CommonParameters>]
2020
```
2121

22-
### Legacy
23-
```
24-
Set-AzSqlDatabaseBackupLongTermRetentionPolicy -State <String> -ResourceId <String> [-ServerName] <String>
25-
[-DatabaseName] <String> [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
26-
[-Confirm] [<CommonParameters>]
27-
```
28-
2922
### RemovePolicy
3023
```
3124
Set-AzSqlDatabaseBackupLongTermRetentionPolicy [-RemovePolicy] [-ServerName] <String> [-DatabaseName] <String>
@@ -66,8 +59,6 @@ WeeklyRetention : P2W
6659
MonthlyRetention : PT0S
6760
YearlyRetention : PT0S
6861
WeekOfYear : 0
69-
State :
70-
RecoveryServicesBackupPolicyResourceId :
7162
Location :
7263
```
7364

@@ -85,8 +76,6 @@ WeeklyRetention : PT0S
8576
MonthlyRetention : P5Y
8677
YearlyRetention : PT0S
8778
WeekOfYear : 0
88-
State :
89-
RecoveryServicesBackupPolicyResourceId :
9079
Location :
9180
```
9281

@@ -104,8 +93,6 @@ WeeklyRetention : PT0S
10493
MonthlyRetention : PT0S
10594
YearlyRetention : P10Y
10695
WeekOfYear : 26
107-
State :
108-
RecoveryServicesBackupPolicyResourceId :
10996
Location :
11097
```
11198

@@ -123,8 +110,6 @@ WeeklyRetention : P14D
123110
MonthlyRetention : P24W
124111
YearlyRetention : P10Y
125112
WeekOfYear : 26
126-
State :
127-
RecoveryServicesBackupPolicyResourceId :
128113
Location :
129114
```
130115

@@ -142,8 +127,6 @@ WeeklyRetention : PT0S
142127
MonthlyRetention : PT0S
143128
YearlyRetention : PT0S
144129
WeekOfYear : 0
145-
State :
146-
RecoveryServicesBackupPolicyResourceId :
147130
Location :
148131
```
149132

@@ -162,8 +145,6 @@ WeeklyRetention : PT0S
162145
MonthlyRetention : PT0S
163146
YearlyRetention : PT0S
164147
WeekOfYear : 0
165-
State :
166-
RecoveryServicesBackupPolicyResourceId :
167148
Location :
168149
```
169150

@@ -261,21 +242,6 @@ Accept pipeline input: True (ByPropertyName)
261242
Accept wildcard characters: False
262243
```
263244
264-
### -ResourceId
265-
The Resource ID of the backup long term retention policy.
266-
267-
```yaml
268-
Type: System.String
269-
Parameter Sets: Legacy
270-
Aliases: Id
271-
272-
Required: True
273-
Position: Named
274-
Default value: None
275-
Accept pipeline input: True (ByPropertyName)
276-
Accept wildcard characters: False
277-
```
278-
279245
### -ServerName
280246
The name of the Azure SQL Server the database is in.
281247
@@ -291,21 +257,6 @@ Accept pipeline input: True (ByPropertyName)
291257
Accept wildcard characters: False
292258
```
293259
294-
### -State
295-
The state of the long term retention backup policy, 'Enabled' or 'Disabled'
296-
297-
```yaml
298-
Type: System.String
299-
Parameter Sets: Legacy
300-
Aliases:
301-
302-
Required: True
303-
Position: Named
304-
Default value: None
305-
Accept pipeline input: False
306-
Accept wildcard characters: False
307-
```
308-
309260
### -WeeklyRetention
310261
The Weekly Retention.
311262
If just a number is passed instead of an ISO 8601 string, days will be assumed as the units.

tools/StaticAnalysis/Exceptions/Az.Sql/BreakingChangeIssues.csv

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation"
2+
"Microsoft.Azure.Commands.Sql.dll","Microsoft.Azure.Commands.Sql.Backup.Cmdlet.GetAzureSqlDatabaseBackupLongTermRetentionPolicy","Get-AzSqlDatabaseBackupLongTermRetentionPolicy","0","3010","The property 'State' of type 'Microsoft.Azure.Commands.Sql.Backup.Model.AzureSqlDatabaseBackupLongTermRetentionPolicyModel' has been removed.","Add the property 'State' back to type 'Microsoft.Azure.Commands.Sql.Backup.Model.AzureSqlDatabaseBackupLongTermRetentionPolicyModel'."
3+
"Microsoft.Azure.Commands.Sql.dll","Microsoft.Azure.Commands.Sql.Backup.Cmdlet.GetAzureSqlDatabaseBackupLongTermRetentionPolicy","Get-AzSqlDatabaseBackupLongTermRetentionPolicy","0","3010","The property 'RecoveryServicesBackupPolicyResourceId' of type 'Microsoft.Azure.Commands.Sql.Backup.Model.AzureSqlDatabaseBackupLongTermRetentionPolicyModel' has been removed.","Add the property 'RecoveryServicesBackupPolicyResourceId' back to type 'Microsoft.Azure.Commands.Sql.Backup.Model.AzureSqlDatabaseBackupLongTermRetentionPolicyModel'."
4+
"Microsoft.Azure.Commands.Sql.dll","Microsoft.Azure.Commands.Sql.Backup.Cmdlet.SetAzureSqlDatabaseBackupLongTermRetentionPolicy","Set-AzSqlDatabaseBackupLongTermRetentionPolicy","0","3010","The property 'State' of type 'Microsoft.Azure.Commands.Sql.Backup.Model.AzureSqlDatabaseBackupLongTermRetentionPolicyModel' has been removed.","Add the property 'State' back to type 'Microsoft.Azure.Commands.Sql.Backup.Model.AzureSqlDatabaseBackupLongTermRetentionPolicyModel'."
5+
"Microsoft.Azure.Commands.Sql.dll","Microsoft.Azure.Commands.Sql.Backup.Cmdlet.SetAzureSqlDatabaseBackupLongTermRetentionPolicy","Set-AzSqlDatabaseBackupLongTermRetentionPolicy","0","3010","The property 'RecoveryServicesBackupPolicyResourceId' of type 'Microsoft.Azure.Commands.Sql.Backup.Model.AzureSqlDatabaseBackupLongTermRetentionPolicyModel' has been removed.","Add the property 'RecoveryServicesBackupPolicyResourceId' back to type 'Microsoft.Azure.Commands.Sql.Backup.Model.AzureSqlDatabaseBackupLongTermRetentionPolicyModel'."
6+
"Microsoft.Azure.Commands.Sql.dll","Microsoft.Azure.Commands.Sql.Backup.Cmdlet.SetAzureSqlDatabaseBackupLongTermRetentionPolicy","Set-AzSqlDatabaseBackupLongTermRetentionPolicy","0","2000","The cmdlet 'Set-AzSqlDatabaseBackupLongTermRetentionPolicy' no longer supports the parameter 'State' and no alias was found for the original parameter name.","Add the parameter 'State' back to the cmdlet 'Set-AzSqlDatabaseBackupLongTermRetentionPolicy', or add an alias to the original parameter name."
7+
"Microsoft.Azure.Commands.Sql.dll","Microsoft.Azure.Commands.Sql.Backup.Cmdlet.SetAzureSqlDatabaseBackupLongTermRetentionPolicy","Set-AzSqlDatabaseBackupLongTermRetentionPolicy","0","2000","The cmdlet 'Set-AzSqlDatabaseBackupLongTermRetentionPolicy' no longer supports the parameter 'ResourceId' and no alias was found for the original parameter name.","Add the parameter 'ResourceId' back to the cmdlet 'Set-AzSqlDatabaseBackupLongTermRetentionPolicy', or add an alias to the original parameter name."
8+
"Microsoft.Azure.Commands.Sql.dll","Microsoft.Azure.Commands.Sql.Backup.Cmdlet.SetAzureSqlDatabaseBackupLongTermRetentionPolicy","Set-AzSqlDatabaseBackupLongTermRetentionPolicy","0","1050","The parameter set 'Legacy' for cmdlet 'Set-AzSqlDatabaseBackupLongTermRetentionPolicy' has been removed.","Add parameter set 'Legacy' back to cmdlet 'Set-AzSqlDatabaseBackupLongTermRetentionPolicy'."
29
"Microsoft.Azure.Commands.Sql.dll","Microsoft.Azure.Commands.Sql.ServiceObjective.Cmdlet.GetAzureSqlServerServiceObjective","Get-AzSqlServerServiceObjective","0","2000","The cmdlet 'Get-AzSqlServerServiceObjective' no longer supports the parameter 'DatabaseName' and no alias was found for the original parameter name.","Add the parameter 'DatabaseName' back to the cmdlet 'Get-AzSqlServerServiceObjective', or add an alias to the original parameter name."
310
"Microsoft.Azure.Commands.Sql.dll","Microsoft.Azure.Commands.Sql.ServiceObjective.Cmdlet.GetAzureSqlServerServiceObjective","Get-AzSqlServerServiceObjective","0","1050","The parameter set '__AllParameterSets' for cmdlet 'Get-AzSqlServerServiceObjective' has been removed.","Add parameter set '__AllParameterSets' back to cmdlet 'Get-AzSqlServerServiceObjective'."
411
"Microsoft.Azure.Commands.Sql.dll","Microsoft.Azure.Commands.Sql.ServerUpgrade.Cmdlet.GetAzureSqlServerUpgrade","Get-AzSqlServerUpgrade","0","1000","The cmdlet 'Get-AzSqlServerUpgrade' has been removed and no alias was found for the original cmdlet name.","Add the cmdlet 'Get-AzSqlServerUpgrade' back to the module, or add an alias to the original cmdlet name."

0 commit comments

Comments
 (0)