Skip to content

Sql breaking change part 2 #8085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -121,25 +121,6 @@ function Test-RestorePointInTimeBackup
-ServerName $db.ServerName -ResourceId $db.ResourceId -Edition 'GeneralPurpose' -VCore 2 -ComputeGeneration 'Gen4'
}

# TODO: Deprecate LTRv1
function Test-DatabaseBackupLongTermRetentionPolicy
{
$location = "North Europe"
$serverVersion = "12.0"
$rg = Get-AzureRmResourceGroup -ResourceGroupName hchung
$server = Get-AzureRmSqlServer -ServerName hchung-testsvr -ResourceGroupName $rg.ResourceGroupName
$db = Get-AzureRmSqlDatabase -ServerName $server.ServerName -DatabaseName hchung-testdb -ResourceGroupName $rg.ResourceGroupName
$policyResourceId = "/subscriptions/e5e8af86-2d93-4ebd-8eb5-3b0184daa9de/resourceGroups/hchung/providers/Microsoft.RecoveryServices/vaults/hchung-testvault/backupPolicies/hchung-testpolicy"

# set
Set-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ServerName $server.ServerName -ResourceGroupName $rg.ResourceGroupName `
-DatabaseName $db.DatabaseName -State "Enabled" -ResourceId $policyResourceId
# get
$result = Get-AzureRmSqlDatabaseBackupLongTermRetentionPolicy -ServerName $server.ServerName -ResourceGroupName $rg.ResourceGroupName -DatabaseName $db.DatabaseName
#verify
Assert-True { $result.RecoveryServicesBackupPolicyResourceId -eq $policyResourceId }
}

# LTR-V1 restore tests need to be removed once the service is retired completely
# TODO update for LTRv2 backup
function Test-RestoreLongTermRetentionBackup
Expand Down
1 change: 1 addition & 0 deletions src/ResourceManager/Sql/Commands.Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Additional information about change #1
-->
## Current Release
* Removed -State and -ResourceId parameters from Set-AzSqlDatabaseBackupLongTermRetentionPolicy
* Removed deprecated cmdlets: Get/Set-AzSqlServerBackupLongTermRetentionVault, Get/Start/Stop-AzSqlServerUpgrade, Get/Set-AzSqlDatabaseAuditingPolicy, Get/Set-AzSqlServerAuditingPolicy, Remove-AzSqlDatabaseAuditing, Remove-AzSqlServerAuditing
* Removed deprecated parameter "Current" from Get-AzSqlDatabaseBackupLongTermRetentionPolicy
* Removed deprecated parameter "DatabaseName" from Get-AzSqlServerServiceObjective
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ protected override IEnumerable<AzureSqlDatabaseBackupLongTermRetentionPolicyMode
ModelAdapter.GetDatabaseBackupLongTermRetentionPolicy(
this.ResourceGroupName,
this.ServerName,
this.DatabaseName,
current: true)
this.DatabaseName)
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,36 +52,6 @@ public class SetAzureSqlDatabaseBackupLongTermRetentionPolicy : AzureSqlDatabase
/// </summary>
private const string RemovePolicySet = "RemovePolicy";

/// <summary>
/// Parameter set for setting the legacy long term retention policy.
/// </summary>
private const string LegacySet = "Legacy";

/// <summary>
/// Gets or sets the backup long term retention state
/// </summary>
[CmdletParameterBreakingChange("State", "Parameter is being deprecated without being replaced.")]
[Parameter(Mandatory = true,
ParameterSetName = LegacySet,
HelpMessage = "The state of the long term retention backup policy, 'Enabled' or 'Disabled'")]
[ValidateNotNullOrEmpty]
public string State { get; set; }

/// <summary>
/// Gets or sets the name of the backup long term retention policy
/// </summary>
/// <remarks>
/// The upcoming breaking change will need some logic changes of how the ResourceId is handled. Contact adeal or pixia for assistance.
/// </remarks>
[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.")]
[Parameter(Mandatory = true,
ParameterSetName = LegacySet,
ValueFromPipelineByPropertyName = true,
HelpMessage = "The Resource ID of the backup long term retention policy.")]
[ValidateNotNullOrEmpty]
[Alias("Id")]
public string ResourceId { get; set; }

/// <summary>
/// Gets or sets whether or not to clear the Long Term Retention V2 policy.
/// </summary>
Expand Down Expand Up @@ -153,8 +123,7 @@ protected override IEnumerable<AzureSqlDatabaseBackupLongTermRetentionPolicyMode
ModelAdapter.GetDatabaseBackupLongTermRetentionPolicy(
this.ResourceGroupName,
this.ServerName,
this.DatabaseName,
!ParameterSetName.Equals(LegacySet))
this.DatabaseName)
};
}

Expand Down Expand Up @@ -197,8 +166,6 @@ protected override IEnumerable<AzureSqlDatabaseBackupLongTermRetentionPolicyMode
ResourceGroupName = ResourceGroupName,
ServerName = ServerName,
DatabaseName = DatabaseName,
State = State,
RecoveryServicesBackupPolicyResourceId = ResourceId,
Location = model.FirstOrDefault().Location,
WeeklyRetention = WeeklyRetention,
MonthlyRetention = MonthlyRetention,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,6 @@ public class AzureSqlDatabaseBackupLongTermRetentionPolicyModel
/// </summary>
public int? WeekOfYear { get; set; }

/// <summary>
/// Gets or sets the backup archival state
/// </summary>
public string State { get; set; }

/// <summary>
/// Gets or sets the backup archival policy resource ID
/// </summary>
public string RecoveryServicesBackupPolicyResourceId { get; set; }

/// <summary>
/// Gets or sets the location
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,43 +260,22 @@ internal AzureSqlServerBackupLongTermRetentionVaultModel GetBackupLongTermRetent
internal AzureSqlDatabaseBackupLongTermRetentionPolicyModel GetDatabaseBackupLongTermRetentionPolicy(
string resourceGroup,
string serverName,
string databaseName,
bool current)
string databaseName)
{
if (!current)
{
var baPolicy = Communicator.GetDatabaseBackupLongTermRetentionPolicy(
resourceGroup,
serverName,
databaseName,
"Default");
return new AzureSqlDatabaseBackupLongTermRetentionPolicyModel()
{
Location = baPolicy.Location,
ResourceGroupName = resourceGroup,
ServerName = serverName,
DatabaseName = databaseName,
State = baPolicy.Properties.State,
RecoveryServicesBackupPolicyResourceId = baPolicy.Properties.RecoveryServicesBackupPolicyResourceId,
};
}
else
{
Management.Sql.Models.BackupLongTermRetentionPolicy response = Communicator.GetDatabaseLongTermRetentionPolicy(
Management.Sql.Models.BackupLongTermRetentionPolicy response = Communicator.GetDatabaseLongTermRetentionPolicy(
resourceGroup,
serverName,
databaseName);
return new AzureSqlDatabaseBackupLongTermRetentionPolicyModel()
{
ResourceGroupName = resourceGroup,
ServerName = serverName,
DatabaseName = databaseName,
WeeklyRetention = response.WeeklyRetention,
MonthlyRetention = response.MonthlyRetention,
YearlyRetention = response.YearlyRetention,
WeekOfYear = response.WeekOfYear
};
}
return new AzureSqlDatabaseBackupLongTermRetentionPolicyModel()
{
ResourceGroupName = resourceGroup,
ServerName = serverName,
DatabaseName = databaseName,
WeeklyRetention = response.WeeklyRetention,
MonthlyRetention = response.MonthlyRetention,
YearlyRetention = response.YearlyRetention,
WeekOfYear = response.WeekOfYear
};
}

/// <summary>
Expand Down Expand Up @@ -344,35 +323,7 @@ internal AzureSqlDatabaseBackupLongTermRetentionPolicyModel SetDatabaseBackupLon
string databaseName,
AzureSqlDatabaseBackupLongTermRetentionPolicyModel model)
{
if (!string.IsNullOrWhiteSpace(model.RecoveryServicesBackupPolicyResourceId))
{
var baPolicy = Communicator.SetDatabaseBackupLongTermRetentionPolicy(
resourceGroup,
serverName,
databaseName,
"Default",
new DatabaseBackupLongTermRetentionPolicyCreateOrUpdateParameters()
{
Location = model.Location,
Properties = new DatabaseBackupLongTermRetentionPolicyProperties()
{
State = model.State,
RecoveryServicesBackupPolicyResourceId = model.RecoveryServicesBackupPolicyResourceId,
}
});
return new AzureSqlDatabaseBackupLongTermRetentionPolicyModel()
{
Location = baPolicy.Location,
ResourceGroupName = resourceGroup,
ServerName = serverName,
DatabaseName = databaseName,
State = baPolicy.Properties.State,
RecoveryServicesBackupPolicyResourceId = baPolicy.Properties.RecoveryServicesBackupPolicyResourceId,
};
}
else
{
Management.Sql.Models.BackupLongTermRetentionPolicy response = Communicator.SetDatabaseLongTermRetentionPolicy(
Management.Sql.Models.BackupLongTermRetentionPolicy response = Communicator.SetDatabaseLongTermRetentionPolicy(
resourceGroup,
serverName,
databaseName,
Expand All @@ -383,17 +334,16 @@ internal AzureSqlDatabaseBackupLongTermRetentionPolicyModel SetDatabaseBackupLon
YearlyRetention = model.YearlyRetention,
WeekOfYear = model.WeekOfYear
});
return new AzureSqlDatabaseBackupLongTermRetentionPolicyModel()
{
ResourceGroupName = resourceGroup,
ServerName = serverName,
DatabaseName = databaseName,
WeeklyRetention = response.WeeklyRetention,
MonthlyRetention = response.MonthlyRetention,
YearlyRetention = response.YearlyRetention,
WeekOfYear = response.WeekOfYear
};
}
return new AzureSqlDatabaseBackupLongTermRetentionPolicyModel()
{
ResourceGroupName = resourceGroup,
ServerName = serverName,
DatabaseName = databaseName,
WeeklyRetention = response.WeeklyRetention,
MonthlyRetention = response.MonthlyRetention,
YearlyRetention = response.YearlyRetention,
WeekOfYear = response.WeekOfYear
};
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ Set-AzSqlDatabaseBackupLongTermRetentionPolicy -WeeklyRetention <String> [-Serve
[-Confirm] [<CommonParameters>]
```

### Legacy
```
Set-AzSqlDatabaseBackupLongTermRetentionPolicy -State <String> -ResourceId <String> [-ServerName] <String>
[-DatabaseName] <String> [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

### RemovePolicy
```
Set-AzSqlDatabaseBackupLongTermRetentionPolicy [-RemovePolicy] [-ServerName] <String> [-DatabaseName] <String>
Expand Down Expand Up @@ -66,8 +59,6 @@ WeeklyRetention : P2W
MonthlyRetention : PT0S
YearlyRetention : PT0S
WeekOfYear : 0
State :
RecoveryServicesBackupPolicyResourceId :
Location :
```

Expand All @@ -85,8 +76,6 @@ WeeklyRetention : PT0S
MonthlyRetention : P5Y
YearlyRetention : PT0S
WeekOfYear : 0
State :
RecoveryServicesBackupPolicyResourceId :
Location :
```

Expand All @@ -104,8 +93,6 @@ WeeklyRetention : PT0S
MonthlyRetention : PT0S
YearlyRetention : P10Y
WeekOfYear : 26
State :
RecoveryServicesBackupPolicyResourceId :
Location :
```

Expand All @@ -123,8 +110,6 @@ WeeklyRetention : P14D
MonthlyRetention : P24W
YearlyRetention : P10Y
WeekOfYear : 26
State :
RecoveryServicesBackupPolicyResourceId :
Location :
```

Expand All @@ -142,8 +127,6 @@ WeeklyRetention : PT0S
MonthlyRetention : PT0S
YearlyRetention : PT0S
WeekOfYear : 0
State :
RecoveryServicesBackupPolicyResourceId :
Location :
```

Expand All @@ -162,8 +145,6 @@ WeeklyRetention : PT0S
MonthlyRetention : PT0S
YearlyRetention : PT0S
WeekOfYear : 0
State :
RecoveryServicesBackupPolicyResourceId :
Location :
```

Expand Down Expand Up @@ -261,21 +242,6 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -ResourceId
The Resource ID of the backup long term retention policy.

```yaml
Type: System.String
Parameter Sets: Legacy
Aliases: Id

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -ServerName
The name of the Azure SQL Server the database is in.

Expand All @@ -291,21 +257,6 @@ Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
```

### -State
The state of the long term retention backup policy, 'Enabled' or 'Disabled'

```yaml
Type: System.String
Parameter Sets: Legacy
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -WeeklyRetention
The Weekly Retention.
If just a number is passed instead of an ISO 8601 string, days will be assumed as the units.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
"AssemblyFileName","ClassName","Target","Severity","ProblemId","Description","Remediation"
"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'."
"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'."
"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'."
"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'."
"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."
"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."
"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'."
"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."
"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'."
"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."
Expand Down