Skip to content
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

add warning for BackupStorageRedundancy #12934

Merged
merged 15 commits into from
Sep 15, 2020
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions src/Sql/Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
* Updated cmdlets `New-AzSqlDatabaseImport` and `New-AzSqlDatabaseExport` to support network isolation functionality
* Added cmdlet `New-AzSqlDatabaseImportExisting`
* Update to Databases cmdlets to support backup storage type specification
* Added Force parameter to `New-AzSqlDatabase`
* Added warning for BackupStorageRedundancy configuration in select regions in `New-AzSqlDatabase`

## Version 2.9.1
* Fixed potential server name case insensitive error in `New-AzSqlServer` and `Set-AzSqlServer`
Expand Down
33 changes: 32 additions & 1 deletion src/Sql/Sql/Database/Cmdlet/NewAzureSqlDatabase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.Linq;
using System.Management.Automation;
using System.Collections;
using System.Globalization;

namespace Microsoft.Azure.Commands.Sql.Database.Cmdlet
{
Expand Down Expand Up @@ -134,6 +135,12 @@ public class NewAzureSqlDatabase : AzureSqlDatabaseCmdletBase<AzureSqlDatabaseCr
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
public SwitchParameter AsJob { get; set; }

/// <summary>
/// Defines whether it is ok to skip the requesting of confirmation
/// </summary>
[Parameter(HelpMessage = "Skip confirmation message for performing the action")]
public SwitchParameter Force { get; set; }

/// <summary>
/// Gets or sets the Vcore number for the Azure Sql database
/// </summary>
Expand Down Expand Up @@ -198,14 +205,38 @@ public class NewAzureSqlDatabase : AzureSqlDatabaseCmdletBase<AzureSqlDatabaseCr
/// </summary>
[Parameter(Mandatory = false,
HelpMessage = "The Backup storage redundancy used to store backups for the SQL Database. Options are: Local, Zone and Geo.")]
[ValidateSet("Local", "Zone", "Geo")]
[ValidateSet("Local", "Zone", "Geo", IgnoreCase = false)]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change validate set IgnoreCase from true to false is a breaking change. Is it a bug fix? Will it report error from server when case mismatched?

Copy link
Contributor Author

@xaliciayang xaliciayang Sep 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a newly introduced paramater (as part of PR 12899); @dingmeng-xue and I discussed this. We introduced IgnoreCase = false to match the MI user experience (PR 12849).

public string BackupStorageRedundancy { get; set; }

protected static readonly string[] ListOfRegionsToShowWarningMessageForGeoBackupStorage = { "eastasia", "southeastasia", "brazilsouth", "east asia", "southeast asia", "brazil south" };

/// <summary>
/// Overriding to add warning message
/// </summary>
public override void ExecuteCmdlet()
{
string location = ModelAdapter.GetServerLocation(ResourceGroupName, ServerName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • ModuleAdapter needs to be initialized before use( InitModelAdapter() is called in base.ExecuteCmdlet())
  • ModelAdapter.GetServerLocation(ResourceGroupName, ServerName) will generate an additional call which requires re-recording of the related test cases.

if (ListOfRegionsToShowWarningMessageForGeoBackupStorage.Contains(location.ToLower()))
{
if (this.BackupStorageRedundancy == null)
{
if (!Force.IsPresent && !ShouldContinue(
string.Format(CultureInfo.InvariantCulture, Properties.Resources.DoYouWantToProceed, this.DatabaseName),
string.Format(CultureInfo.InvariantCulture, Properties.Resources.GeoBackupRedundancyNotChosenWarning, this.DatabaseName)))
{
return;
}
}
else if (string.Equals(this.BackupStorageRedundancy, "Geo", System.StringComparison.OrdinalIgnoreCase))
xaliciayang marked this conversation as resolved.
Show resolved Hide resolved
{
if (!Force.IsPresent && !ShouldContinue(
string.Format(CultureInfo.InvariantCulture, Properties.Resources.DoYouWantToProceed, this.DatabaseName),
string.Format(CultureInfo.InvariantCulture, Properties.Resources.GeoBackupRedundancyChosenWarning, this.DatabaseName)))
{
return;
}
}
}
base.ExecuteCmdlet();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public override void ExecuteCmdlet()
{
if (!Force.IsPresent && !ShouldContinue(
string.Format(CultureInfo.InvariantCulture, Properties.Resources.DoYouWantToProceed, this.Name),
string.Format(CultureInfo.InvariantCulture, Properties.Resources.GeoBackupRedundancyNotChoosenWarning, this.Name)))
string.Format(CultureInfo.InvariantCulture, Properties.Resources.GeoBackupRedundancyNotChosenWarning, this.Name)))
{
return;
}
Expand All @@ -390,7 +390,7 @@ public override void ExecuteCmdlet()
{
if (!Force.IsPresent && !ShouldContinue(
string.Format(CultureInfo.InvariantCulture, Properties.Resources.DoYouWantToProceed, this.Name),
string.Format(CultureInfo.InvariantCulture, Properties.Resources.GeoBackupRedundancyChoosenWarning, this.Name)))
string.Format(CultureInfo.InvariantCulture, Properties.Resources.GeoBackupRedundancyChosenWarning, this.Name)))
{
return;
}
Expand Down
48 changes: 24 additions & 24 deletions src/Sql/Sql/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/Sql/Sql/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -634,11 +634,11 @@
<data name="ServerNameInvalid" xml:space="preserve">
<value>The server name '{0}' cannot be empty or null. The server name can only be made up of lowercase letters a-z, the numbers 0-9 and the hyphen. The hyphen may not lead or trail in the server name. Please fix the server name and retry. Please contact Microsoft support if the issue persists.</value>
</data>
<data name="GeoBackupRedundancyChoosenWarning" xml:space="preserve">
<value>Selected value for backup storage redundancy is geo-redundant storage. Note that database backups will be geo-replicated to the paired region. To learn more about Azure Paired Regions visit https://aka.ms/micreate-ragrs-regions.</value>
<data name="GeoBackupRedundancyChosenWarning" xml:space="preserve">
<value>Selected value for backup storage redundancy is geo-redundant storage. Note that database backups will be geo-replicated to the paired region. To learn more about Azure Paired Regions visit https://docs.microsoft.com/en-us/azure/best-practices-availability-paired-regions.</value>
</data>
<data name="GeoBackupRedundancyNotChoosenWarning" xml:space="preserve">
<value>You have not specified the value for backup storage redundancy which will default to geo-redundant storage. Note that database backups will be geo-replicated to the paired region. To learn more about Azure Paired Regions visit https://aka.ms/micreate-ragrs-regions.</value>
<data name="GeoBackupRedundancyNotChosenWarning" xml:space="preserve">
<value>You have not specified the value for backup storage redundancy which will default to geo-redundant storage. Note that database backups will be geo-replicated to the paired region. To learn more about Azure Paired Regions visit https://docs.microsoft.com/en-us/azure/best-practices-availability-paired-regions.</value>
</data>
<data name="StopAzureSqlInstanceDatabaseLogReplayDescription" xml:space="preserve">
<value>Stopping Azure Sql Managed Database Log Replay by removing '{0}' database.</value>
Expand Down
19 changes: 17 additions & 2 deletions src/Sql/Sql/help/New-AzSqlDatabase.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Creates a database or an elastic database.
New-AzSqlDatabase -DatabaseName <String> [-CollationName <String>] [-CatalogCollation <String>]
[-MaxSizeBytes <Int64>] [-Edition <String>] [-RequestedServiceObjectiveName <String>]
[-ElasticPoolName <String>] [-ReadScale <DatabaseReadScale>] [-Tags <Hashtable>] [-SampleName <String>]
[-ZoneRedundant] [-AsJob] [-LicenseType <String>] [-AutoPauseDelayInMinutes <Int32>]
[-ZoneRedundant] [-AsJob] [-Force] [-LicenseType <String>] [-AutoPauseDelayInMinutes <Int32>]
[-MinimumCapacity <Double>] [-ReadReplicaCount <Int32>] [-BackupStorageRedundancy <String>]
[-ServerName] <String> [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
Expand All @@ -28,7 +28,7 @@ New-AzSqlDatabase -DatabaseName <String> [-CollationName <String>] [-CatalogColl
```
New-AzSqlDatabase -DatabaseName <String> [-CollationName <String>] [-CatalogCollation <String>]
[-MaxSizeBytes <Int64>] -Edition <String> [-ReadScale <DatabaseReadScale>] [-Tags <Hashtable>]
[-SampleName <String>] [-ZoneRedundant] [-AsJob] -VCore <Int32> -ComputeGeneration <String>
[-SampleName <String>] [-ZoneRedundant] [-AsJob] [-Force] -VCore <Int32> -ComputeGeneration <String>
[-LicenseType <String>] [-ComputeModel <String>] [-AutoPauseDelayInMinutes <Int32>]
[-MinimumCapacity <Double>] [-ReadReplicaCount <Int32>] [-BackupStorageRedundancy <String>]
[-ServerName] <String> [-ResourceGroupName] <String> [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
Expand Down Expand Up @@ -338,6 +338,21 @@ Accept pipeline input: False
Accept wildcard characters: False
```

### -Force
Skip confirmation message for performing the action

```yaml
Type: System.Management.Automation.SwitchParameter
Parameter Sets: (All)
Aliases:

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

### -LicenseType
The license type for the Azure Sql database. Possible values are:
- BasePrice - Azure Hybrid Benefit (AHB) discounted pricing for existing SQL Server license owners is applied. Database price will be discounted for existing SQL Server license owners.
Expand Down