Skip to content

Commit bbd46f0

Browse files
Adding Warning message for 3 regions when Geo backup storage redundancy is choosen on MI creation (#12849)
* Adding Warning message for 3 regions when Geo backup storage redundancy is choosen * Adding IgnoreCase=false to parameter BackupStorageRedundancy * Small string fix * Adding missing version for locations * Regenerating help file and updating Changelog.md Co-authored-by: Perica Trajkov <[email protected]>
1 parent debfb78 commit bbd46f0

File tree

5 files changed

+77
-6
lines changed

5 files changed

+77
-6
lines changed

src/Sql/Sql/ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
* Added BackupStorageRedundancy to `New-AzSqlInstance` and `Get-AzSqlInstance`
2222
* Added cmdlet `Get-AzSqlServerActiveDirectoryOnlyAuthentication`
2323
* Added cmdlet `Enable-AzSqlServerActiveDirectoryOnlyAuthentication`
24+
* Added Force parameter to `New-AzSqlInstance`
2425

2526
## Version 2.9.1
2627
* Fixed potential server name case insensitive error in `New-AzSqlServer` and `Set-AzSqlServer`

src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Microsoft.Rest.Azure;
2020
using System.Collections;
2121
using System.Collections.Generic;
22+
using System.Globalization;
2223
using System.Linq;
2324
using System.Management.Automation;
2425
using Microsoft.Azure.Management.Sql.Models;
@@ -51,6 +52,8 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase
5152
protected const string NewByInstancePoolResourceIdParameterSet =
5253
"NewByInstancePoolResourceIdParameterSet";
5354

55+
protected static readonly string[] ListOfRegionsToShowWarningMessageForGeoBackupStorage = { "eastasia", "southeastasia", "brazilsouth", "east asia", "southeast asia", "brazil south" };
56+
5457
/// <summary>
5558
/// Gets or sets the instance pool parent object
5659
/// </summary>
@@ -310,7 +313,7 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase
310313
/// </summary>
311314
[Parameter(Mandatory = false,
312315
HelpMessage = "The Backup storage redundancy used to store backups for the Sql Azure Managed Instance. Options are: Local, Zone and Geo ")]
313-
[ValidateSet("Local", "Zone", "Geo")]
316+
[ValidateSet("Local", "Zone", "Geo", IgnoreCase = false)]
314317
public string BackupStorageRedundancy { get; set; }
315318

316319
/// <summary>
@@ -319,6 +322,12 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase
319322
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")]
320323
public SwitchParameter AsJob { get; set; }
321324

325+
/// <summary>
326+
/// Defines whether it is ok to skip the requesting of confirmation
327+
/// </summary>
328+
[Parameter(HelpMessage = "Skip confirmation message for performing the action")]
329+
public SwitchParameter Force { get; set; }
330+
322331
/// <summary>
323332
/// Overriding to add warning message
324333
/// </summary>
@@ -366,6 +375,28 @@ public override void ExecuteCmdlet()
366375
}
367376
}
368377

378+
if (ListOfRegionsToShowWarningMessageForGeoBackupStorage.Contains(this.Location.ToLower()))
379+
{
380+
if (this.BackupStorageRedundancy == null)
381+
{
382+
if (!Force.IsPresent && !ShouldContinue(
383+
string.Format(CultureInfo.InvariantCulture, Properties.Resources.DoYouWantToProceed, this.Name),
384+
string.Format(CultureInfo.InvariantCulture, Properties.Resources.GeoBackupRedundancyNotChoosenWarning, this.Name)))
385+
{
386+
return;
387+
}
388+
}
389+
else if (string.Equals(this.BackupStorageRedundancy, "Geo", System.StringComparison.OrdinalIgnoreCase))
390+
{
391+
if (!Force.IsPresent && !ShouldContinue(
392+
string.Format(CultureInfo.InvariantCulture, Properties.Resources.DoYouWantToProceed, this.Name),
393+
string.Format(CultureInfo.InvariantCulture, Properties.Resources.GeoBackupRedundancyChoosenWarning, this.Name)))
394+
{
395+
return;
396+
}
397+
}
398+
}
399+
369400
base.ExecuteCmdlet();
370401
}
371402

src/Sql/Sql/Properties/Resources.Designer.cs

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Sql/Sql/Properties/Resources.resx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,4 +634,10 @@
634634
<data name="ServerNameInvalid" xml:space="preserve">
635635
<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>
636636
</data>
637+
<data name="GeoBackupRedundancyChoosenWarning" xml:space="preserve">
638+
<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>
639+
</data>
640+
<data name="GeoBackupRedundancyNotChoosenWarning" xml:space="preserve">
641+
<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>
642+
</data>
637643
</root>

src/Sql/Sql/help/New-AzSqlInstance.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ New-AzSqlInstance [-Name] <String> [-ResourceGroupName] <String> -AdministratorC
1919
-Edition <String> -ComputeGeneration <String> [-Collation <String>] [-PublicDataEndpointEnabled]
2020
[-ProxyOverride <String>] [-TimezoneId <String>] [-Tag <Hashtable>] [-AssignIdentity]
2121
[-DnsZonePartner <String>] [-InstancePoolName <String>] [-MinimalTlsVersion <String>]
22-
[-BackupStorageRedundancy <String>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
23-
[<CommonParameters>]
22+
[-BackupStorageRedundancy <String>] [-AsJob] [-Force] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
23+
[-Confirm] [<CommonParameters>]
2424
```
2525

2626
### NewByInstancePoolParentObjectParameterSet
@@ -29,15 +29,15 @@ New-AzSqlInstance [-InstancePool] <AzureSqlInstancePoolModel> [-Name] <String>
2929
-AdministratorCredential <PSCredential> [-StorageSizeInGB <Int32>] -VCore <Int32> [-Collation <String>]
3030
[-PublicDataEndpointEnabled] [-ProxyOverride <String>] [-TimezoneId <String>] [-Tag <Hashtable>]
3131
[-AssignIdentity] [-DnsZonePartner <String>] [-MinimalTlsVersion <String>] [-BackupStorageRedundancy <String>]
32-
[-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
32+
[-AsJob] [-Force] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
3333
```
3434

3535
### NewByInstancePoolResourceIdParameterSet
3636
```
3737
New-AzSqlInstance [-InstancePoolResourceId] <String> [-Name] <String> -AdministratorCredential <PSCredential>
3838
[-StorageSizeInGB <Int32>] -VCore <Int32> [-Collation <String>] [-PublicDataEndpointEnabled]
3939
[-ProxyOverride <String>] [-TimezoneId <String>] [-Tag <Hashtable>] [-AssignIdentity]
40-
[-DnsZonePartner <String>] [-MinimalTlsVersion <String>] [-BackupStorageRedundancy <String>] [-AsJob]
40+
[-DnsZonePartner <String>] [-MinimalTlsVersion <String>] [-BackupStorageRedundancy <String>] [-AsJob] [-Force]
4141
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
4242
```
4343

@@ -48,7 +48,7 @@ New-AzSqlInstance [-Name] <String> [-ResourceGroupName] <String> -AdministratorC
4848
-SkuName <String> [-Collation <String>] [-PublicDataEndpointEnabled] [-ProxyOverride <String>]
4949
[-TimezoneId <String>] [-Tag <Hashtable>] [-AssignIdentity] [-DnsZonePartner <String>]
5050
[-InstancePoolName <String>] [-MinimalTlsVersion <String>] [-BackupStorageRedundancy <String>] [-AsJob]
51-
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
51+
[-Force] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
5252
```
5353

5454
## DESCRIPTION
@@ -310,6 +310,21 @@ Accept pipeline input: False
310310
Accept wildcard characters: False
311311
```
312312
313+
### -Force
314+
Skip confirmation message for performing the action
315+
316+
```yaml
317+
Type: System.Management.Automation.SwitchParameter
318+
Parameter Sets: (All)
319+
Aliases:
320+
321+
Required: False
322+
Position: Named
323+
Default value: None
324+
Accept pipeline input: False
325+
Accept wildcard characters: False
326+
```
327+
313328
### -InstancePool
314329
The instance pool parent object.
315330

0 commit comments

Comments
 (0)