Skip to content
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
1 change: 1 addition & 0 deletions src/Sql/Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
33 changes: 32 additions & 1 deletion src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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" };

/// <summary>
/// Gets or sets the instance pool parent object
/// </summary>
Expand Down Expand Up @@ -310,7 +313,7 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase
/// </summary>
[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; }

/// <summary>
Expand All @@ -319,6 +322,12 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase
[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>
/// Overriding to add warning message
/// </summary>
Expand Down Expand Up @@ -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();
}

Expand Down
18 changes: 18 additions & 0 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.

6 changes: 6 additions & 0 deletions src/Sql/Sql/Properties/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -634,4 +634,10 @@
<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>
<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>
</root>
25 changes: 20 additions & 5 deletions src/Sql/Sql/help/New-AzSqlInstance.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ New-AzSqlInstance [-Name] <String> [-ResourceGroupName] <String> -AdministratorC
-Edition <String> -ComputeGeneration <String> [-Collation <String>] [-PublicDataEndpointEnabled]
[-ProxyOverride <String>] [-TimezoneId <String>] [-Tag <Hashtable>] [-AssignIdentity]
[-DnsZonePartner <String>] [-InstancePoolName <String>] [-MinimalTlsVersion <String>]
[-BackupStorageRedundancy <String>] [-AsJob] [-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm]
[<CommonParameters>]
[-BackupStorageRedundancy <String>] [-AsJob] [-Force] [-DefaultProfile <IAzureContextContainer>] [-WhatIf]
[-Confirm] [<CommonParameters>]
```

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

### NewByInstancePoolResourceIdParameterSet
```
New-AzSqlInstance [-InstancePoolResourceId] <String> [-Name] <String> -AdministratorCredential <PSCredential>
[-StorageSizeInGB <Int32>] -VCore <Int32> [-Collation <String>] [-PublicDataEndpointEnabled]
[-ProxyOverride <String>] [-TimezoneId <String>] [-Tag <Hashtable>] [-AssignIdentity]
[-DnsZonePartner <String>] [-MinimalTlsVersion <String>] [-BackupStorageRedundancy <String>] [-AsJob]
[-DnsZonePartner <String>] [-MinimalTlsVersion <String>] [-BackupStorageRedundancy <String>] [-AsJob] [-Force]
[-DefaultProfile <IAzureContextContainer>] [-WhatIf] [-Confirm] [<CommonParameters>]
```

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

## DESCRIPTION
Expand Down Expand Up @@ -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.

Expand Down