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/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs b/src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs
index bcbb949f45d9..b3243aeab072 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", "east asia", "southeast asia", "brazil south" };
+
///
/// Gets or sets the instance pool parent object
///
@@ -310,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; }
///
@@ -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/Properties/Resources.Designer.cs b/src/Sql/Sql/Properties/Resources.Designer.cs
index 4505924f7970..01faa0f02f9a 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..59a6b050f793 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
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.