From 591b584cadb09a1882adc407cf467b9741642e9c Mon Sep 17 00:00:00 2001 From: Perica Trajkov Date: Thu, 3 Sep 2020 20:22:15 +0200 Subject: [PATCH 1/5] Adding Warning message for 3 regions when Geo backup storage redundancy is choosen --- .../Cmdlet/NewAzureSqlManagedInstance.cs | 31 +++++++++++++++++++ .../AzureSqlManagedInstanceAdapter.cs | 8 ++--- src/Sql/Sql/Properties/Resources.Designer.cs | 18 +++++++++++ src/Sql/Sql/Properties/Resources.resx | 6 ++++ 4 files changed, 59 insertions(+), 4 deletions(-) diff --git a/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs b/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs index bcbb949f45d9..9cfe96727a17 100644 --- a/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs +++ b/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs @@ -19,6 +19,7 @@ using Microsoft.Rest.Azure; using System.Collections; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Management.Automation; using Microsoft.Azure.Management.Sql.Models; @@ -51,6 +52,8 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase protected const string NewByInstancePoolResourceIdParameterSet = "NewByInstancePoolResourceIdParameterSet"; + protected static readonly string[] ListOfRegionsToShowWarningMessageForGeoBackupStorage = { "eastasia", "southeastasia", "brazilsouth" }; + /// /// Gets or sets the instance pool parent object /// @@ -319,6 +322,12 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase [Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] public SwitchParameter AsJob { get; set; } + /// + /// Defines whether it is ok to skip the requesting of confirmation + /// + [Parameter(HelpMessage = "Skip confirmation message for performing the action")] + public SwitchParameter Force { get; set; } + /// /// Overriding to add warning message /// @@ -366,6 +375,28 @@ public override void ExecuteCmdlet() } } + if (ListOfRegionsToShowWarningMessageForGeoBackupStorage.Contains(this.Location.ToLower())) + { + if (this.BackupStorageRedundancy == null) + { + if (!Force.IsPresent && !ShouldContinue( + string.Format(CultureInfo.InvariantCulture, Properties.Resources.DoYouWantToProceed, this.Name), + string.Format(CultureInfo.InvariantCulture, Properties.Resources.GeoBackupRedundancyNotChoosenWarning, this.Name))) + { + return; + } + } + else if (string.Equals(this.BackupStorageRedundancy, "Geo", System.StringComparison.OrdinalIgnoreCase)) + { + if (!Force.IsPresent && !ShouldContinue( + string.Format(CultureInfo.InvariantCulture, Properties.Resources.DoYouWantToProceed, this.Name), + string.Format(CultureInfo.InvariantCulture, Properties.Resources.GeoBackupRedundancyChoosenWarning, this.Name))) + { + return; + } + } + } + base.ExecuteCmdlet(); } diff --git a/src/Sql/Sql/ManagedInstance/Services/AzureSqlManagedInstanceAdapter.cs b/src/Sql/Sql/ManagedInstance/Services/AzureSqlManagedInstanceAdapter.cs index c47afdf8354c..e132b8edd785 100644 --- a/src/Sql/Sql/ManagedInstance/Services/AzureSqlManagedInstanceAdapter.cs +++ b/src/Sql/Sql/ManagedInstance/Services/AzureSqlManagedInstanceAdapter.cs @@ -252,13 +252,13 @@ public static string GetInstanceSkuPrefix(string tier) /// internal backupStorageRedundancy public static string MapExternalBackupStorageRedundancyToInternal(string backupStorageRedundancy) { - switch (backupStorageRedundancy) + switch (backupStorageRedundancy.ToLower()) { - case "Geo": + case "geo": return "GRS"; - case "Local": + case "local": return "LRS"; - case "Zone": + case "zone": return "ZRS"; default: return "GRS"; diff --git a/src/Sql/Sql/Properties/Resources.Designer.cs b/src/Sql/Sql/Properties/Resources.Designer.cs index 4505924f7970..22717cf557f5 100644 --- a/src/Sql/Sql/Properties/Resources.Designer.cs +++ b/src/Sql/Sql/Properties/Resources.Designer.cs @@ -555,6 +555,24 @@ internal static string FailoverGroupRemoveDatabaseNotExists { } } + /// + /// Looks up a localized string similar to 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.. + /// + internal static string GeoBackupRedundancyChoosenWarning { + get { + return ResourceManager.GetString("GeoBackupRedundancyChoosenWarning", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 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.. + /// + internal static string GeoBackupRedundancyNotChoosenWarning { + get { + return ResourceManager.GetString("GeoBackupRedundancyNotChoosenWarning", resourceCulture); + } + } + /// /// Looks up a localized string similar to The Active Directory Group '{0}' is not security enabled. Only Azure Active Directory Security Enabled Groups are supported.. /// diff --git a/src/Sql/Sql/Properties/Resources.resx b/src/Sql/Sql/Properties/Resources.resx index 4043a94423e7..dafc70645556 100644 --- a/src/Sql/Sql/Properties/Resources.resx +++ b/src/Sql/Sql/Properties/Resources.resx @@ -634,4 +634,10 @@ 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. + + 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. + + + 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. + \ No newline at end of file From 4a1ae1fbef9c229ed2b3150417d5028c42e06e6a Mon Sep 17 00:00:00 2001 From: Perica Trajkov Date: Fri, 4 Sep 2020 11:12:45 +0200 Subject: [PATCH 2/5] Adding IgnoreCase=false to parameter BackupStorageRedundancy --- .../ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs | 2 +- .../Services/AzureSqlManagedInstanceAdapter.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs b/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs index 9cfe96727a17..493aae2b0f41 100644 --- a/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs +++ b/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs @@ -313,7 +313,7 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase /// [Parameter(Mandatory = false, HelpMessage = "The Backup storage redundancy used to store backups for the Sql Azure Managed Instance. Options are: Local, Zone and Geo ")] - [ValidateSet("Local", "Zone", "Geo")] + [ValidateSet("Local", "Zone", "Geo", IgnoreCase = false)] public string BackupStorageRedundancy { get; set; } /// diff --git a/src/Sql/Sql/ManagedInstance/Services/AzureSqlManagedInstanceAdapter.cs b/src/Sql/Sql/ManagedInstance/Services/AzureSqlManagedInstanceAdapter.cs index e132b8edd785..c47afdf8354c 100644 --- a/src/Sql/Sql/ManagedInstance/Services/AzureSqlManagedInstanceAdapter.cs +++ b/src/Sql/Sql/ManagedInstance/Services/AzureSqlManagedInstanceAdapter.cs @@ -252,13 +252,13 @@ public static string GetInstanceSkuPrefix(string tier) /// internal backupStorageRedundancy public static string MapExternalBackupStorageRedundancyToInternal(string backupStorageRedundancy) { - switch (backupStorageRedundancy.ToLower()) + switch (backupStorageRedundancy) { - case "geo": + case "Geo": return "GRS"; - case "local": + case "Local": return "LRS"; - case "zone": + case "Zone": return "ZRS"; default: return "GRS"; From 8ab7ccb701de70378583fb763ad32090096f3149 Mon Sep 17 00:00:00 2001 From: Perica Trajkov Date: Fri, 4 Sep 2020 11:33:29 +0200 Subject: [PATCH 3/5] Small string fix --- src/Sql/Sql/Properties/Resources.Designer.cs | 4 ++-- src/Sql/Sql/Properties/Resources.resx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Sql/Sql/Properties/Resources.Designer.cs b/src/Sql/Sql/Properties/Resources.Designer.cs index 22717cf557f5..01faa0f02f9a 100644 --- a/src/Sql/Sql/Properties/Resources.Designer.cs +++ b/src/Sql/Sql/Properties/Resources.Designer.cs @@ -556,7 +556,7 @@ internal static string FailoverGroupRemoveDatabaseNotExists { } /// - /// Looks up a localized string similar to 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.. + /// Looks up a localized string similar to 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.. /// internal static string GeoBackupRedundancyChoosenWarning { get { @@ -565,7 +565,7 @@ internal static string GeoBackupRedundancyChoosenWarning { } /// - /// Looks up a localized string similar to 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.. + /// Looks up a localized string similar to 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.. /// internal static string GeoBackupRedundancyNotChoosenWarning { get { diff --git a/src/Sql/Sql/Properties/Resources.resx b/src/Sql/Sql/Properties/Resources.resx index dafc70645556..59a6b050f793 100644 --- a/src/Sql/Sql/Properties/Resources.resx +++ b/src/Sql/Sql/Properties/Resources.resx @@ -635,9 +635,9 @@ 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. - 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. + 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. - 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. + 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. \ No newline at end of file From 127934722dac904fad95a78d105e4e20c08ec615 Mon Sep 17 00:00:00 2001 From: Perica Trajkov Date: Fri, 4 Sep 2020 16:38:00 +0200 Subject: [PATCH 4/5] Adding missing version for locations --- .../Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs b/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs index 493aae2b0f41..b3243aeab072 100644 --- a/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs +++ b/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs @@ -52,7 +52,7 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase protected const string NewByInstancePoolResourceIdParameterSet = "NewByInstancePoolResourceIdParameterSet"; - protected static readonly string[] ListOfRegionsToShowWarningMessageForGeoBackupStorage = { "eastasia", "southeastasia", "brazilsouth" }; + protected static readonly string[] ListOfRegionsToShowWarningMessageForGeoBackupStorage = { "eastasia", "southeastasia", "brazilsouth", "east asia", "southeast asia", "brazil south" }; /// /// Gets or sets the instance pool parent object From 895270410289cba05425b368e179541225c7d03c Mon Sep 17 00:00:00 2001 From: Perica Trajkov Date: Mon, 7 Sep 2020 11:31:27 +0200 Subject: [PATCH 5/5] Regenerating help file and updating Changelog.md --- src/Sql/Sql/ChangeLog.md | 1 + src/Sql/Sql/help/New-AzSqlInstance.md | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/Sql/Sql/ChangeLog.md b/src/Sql/Sql/ChangeLog.md index cbbe0162323c..d5a144da58b7 100644 --- a/src/Sql/Sql/ChangeLog.md +++ b/src/Sql/Sql/ChangeLog.md @@ -21,6 +21,7 @@ * Added BackupStorageRedundancy to `New-AzSqlInstance` and `Get-AzSqlInstance` * Added cmdlet `Get-AzSqlServerActiveDirectoryOnlyAuthentication` * Added cmdlet `Enable-AzSqlServerActiveDirectoryOnlyAuthentication` +* Added Force parameter to `New-AzSqlInstance` ## Version 2.9.1 * Fixed potential server name case insensitive error in `New-AzSqlServer` and `Set-AzSqlServer` diff --git a/src/Sql/Sql/help/New-AzSqlInstance.md b/src/Sql/Sql/help/New-AzSqlInstance.md index 5c048241408b..74fe5109fa3e 100644 --- a/src/Sql/Sql/help/New-AzSqlInstance.md +++ b/src/Sql/Sql/help/New-AzSqlInstance.md @@ -19,8 +19,8 @@ New-AzSqlInstance [-Name] [-ResourceGroupName] -AdministratorC -Edition -ComputeGeneration [-Collation ] [-PublicDataEndpointEnabled] [-ProxyOverride ] [-TimezoneId ] [-Tag ] [-AssignIdentity] [-DnsZonePartner ] [-InstancePoolName ] [-MinimalTlsVersion ] - [-BackupStorageRedundancy ] [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] - [] + [-BackupStorageRedundancy ] [-AsJob] [-Force] [-DefaultProfile ] [-WhatIf] + [-Confirm] [] ``` ### NewByInstancePoolParentObjectParameterSet @@ -29,7 +29,7 @@ New-AzSqlInstance [-InstancePool] [-Name] -AdministratorCredential [-StorageSizeInGB ] -VCore [-Collation ] [-PublicDataEndpointEnabled] [-ProxyOverride ] [-TimezoneId ] [-Tag ] [-AssignIdentity] [-DnsZonePartner ] [-MinimalTlsVersion ] [-BackupStorageRedundancy ] - [-AsJob] [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-AsJob] [-Force] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ### NewByInstancePoolResourceIdParameterSet @@ -37,7 +37,7 @@ New-AzSqlInstance [-InstancePool] [-Name] New-AzSqlInstance [-InstancePoolResourceId] [-Name] -AdministratorCredential [-StorageSizeInGB ] -VCore [-Collation ] [-PublicDataEndpointEnabled] [-ProxyOverride ] [-TimezoneId ] [-Tag ] [-AssignIdentity] - [-DnsZonePartner ] [-MinimalTlsVersion ] [-BackupStorageRedundancy ] [-AsJob] + [-DnsZonePartner ] [-MinimalTlsVersion ] [-BackupStorageRedundancy ] [-AsJob] [-Force] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` @@ -48,7 +48,7 @@ New-AzSqlInstance [-Name] [-ResourceGroupName] -AdministratorC -SkuName [-Collation ] [-PublicDataEndpointEnabled] [-ProxyOverride ] [-TimezoneId ] [-Tag ] [-AssignIdentity] [-DnsZonePartner ] [-InstancePoolName ] [-MinimalTlsVersion ] [-BackupStorageRedundancy ] [-AsJob] - [-DefaultProfile ] [-WhatIf] [-Confirm] [] + [-Force] [-DefaultProfile ] [-WhatIf] [-Confirm] [] ``` ## DESCRIPTION @@ -310,6 +310,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 +``` + ### -InstancePool The instance pool parent object.