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

Enabling GPv2 in powershell #24880

Merged
merged 11 commits into from
Jul 9, 2024
1 change: 1 addition & 0 deletions src/Sql/Sql/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* Changed default FailoverPolicy value for `New-AzSqlDatabaseFailoverGroup`, `Set-AzSqlDatabaseFailoverGroup` from `Automatic` to `Manual`
* Added `ManualCutover` and `PerformCutover` parameters to `Set-AzSqlInstance` for Azure Sql Sterling database to Azure Sql Hyperscale database
* Added `OperationPhaseDetails` parameter to `Get-AzSqlDatabaseActivity` and updated `DatabaseOperations` Api to version `2022-11-01-preview` for .Net Sdk
* Added `IsGeneralPurposeV2` and `StorageIOps` parameters to `New-AzSqlInstance`, `Set-AzSqlInstance` to enable the creation of GPv2 instances

## Version 4.14.1
* Made 1.2 as default for MinimalTlsVersion when creating new Sql Server from Powershell
Expand Down
6 changes: 6 additions & 0 deletions src/Sql/Sql/Common/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,18 @@ public class Constants
public const string LicenseTypeLicenseIncluded = "LicenseIncluded";
public const string GeneralPurposeGen4 = "GP_Gen4";
public const string GeneralPurposeGen5 = "GP_Gen5";
public const string GeneralPurposeG8IH = "GP_G8IH";
public const string GeneralPurposeG8IM = "GP_G8IM";
public const string BusinessCriticalGen4 = "BC_Gen4";
public const string BusinessCriticalGen5 = "BC_Gen5";
public const string BusinessCriticalG8IH = "BC_G8IH";
public const string BusinessCriticalG8IM = "BC_G8IM";
public const string BusinessCriticalEdition = "BusinessCritical";
public const string GeneralPurposeEdition = "GeneralPurpose";
public const string ComputeGenerationGen4 = "Gen4";
public const string ComputeGenerationGen5 = "Gen5";
public const string ComputeGenerationG8IH = "G8IH";
public const string ComputeGenerationG8IM = "G8IM";
public const string CollationSqlLatin1 = "SQL_Latin1_General_CP1_CI_AS";
public const string CollationLatin1 = "Latin1_General_100_CS_AS_SC";
}
Expand Down
26 changes: 23 additions & 3 deletions src/Sql/Sql/ManagedInstance/Cmdlet/NewAzureSqlManagedInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase
Mandatory = true,
HelpMessage = "The SKU name for the instance e.g. 'GP_Gen4', 'BC_Gen4'.")]
[ValidateNotNullOrEmpty]
[PSArgumentCompleter(Constants.GeneralPurposeGen4, Constants.GeneralPurposeGen5, Constants.BusinessCriticalGen4, Constants.BusinessCriticalGen5)]
[PSArgumentCompleter(Constants.GeneralPurposeGen5, Constants.GeneralPurposeG8IH, Constants.GeneralPurposeG8IM,
Constants.BusinessCriticalGen5, Constants.BusinessCriticalG8IH, Constants.BusinessCriticalG8IM)]
public string SkuName { get; set; }

/// <summary>
Expand All @@ -205,7 +206,7 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase
Mandatory = true,
HelpMessage = "The compute generation for the instance.")]
[ValidateNotNullOrEmpty]
[PSArgumentCompleter(Constants.ComputeGenerationGen4, Constants.ComputeGenerationGen5)]
[PSArgumentCompleter(Constants.ComputeGenerationGen5, Constants.ComputeGenerationG8IH, Constants.ComputeGenerationG8IM)]
public string ComputeGeneration { get; set; }

/// <summary>
Expand Down Expand Up @@ -415,6 +416,19 @@ public class NewAzureSqlManagedInstance : ManagedInstanceCmdletBase
[PSArgumentCompleter("Regular", "Freemium")]
public string PricingModel { get; set; }

/// <summary>
/// Gets or sets whether or not this is a GPv2 variant of General Purpose edition.
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "Whether or not this is a GPv2 variant of General Purpose edition.")]
public bool? IsGeneralPurposeV2 { get; set; }

/// <summary>
/// Gets or sets the Storage IOps for instance
/// </summary>
[Parameter(Mandatory = false,
HelpMessage = "Determines how much Storage IOps to associate with instance.")]
public int StorageIOps { get; set; }

/// <summary>
/// Overriding to add warning message
/// </summary>
Expand Down Expand Up @@ -585,7 +599,13 @@ protected override IEnumerable<Model.AzureSqlManagedInstanceModel> ApplyUserInpu
ZoneRedundant = this.ZoneRedundant.IsPresent ? this.ZoneRedundant.ToBool() : (bool?)null,
ServicePrincipal = ResourceServicePrincipalHelper.GetServicePrincipalObjectFromType(this.ServicePrincipalType ?? null),
DatabaseFormat = this.DatabaseFormat,
PricingModel = this.PricingModel
PricingModel = this.PricingModel,
IsGeneralPurposeV2 = this.IsGeneralPurposeV2,
// `-StorageIOps 0` as a parameter to this cmdlet means "use default".
// For non-MI database, we can just pass in 0 and the server will treat 0 as default.
// However this is (currently) not the case for MI. We need to convert the 0 to null
// here in client before sending to the server.
StorageIOps = SqlSkuUtils.ValueIfNonZero(this.StorageIOps)
});
return newEntity;
}
Expand Down
22 changes: 21 additions & 1 deletion src/Sql/Sql/ManagedInstance/Cmdlet/SetAzureSqlManagedInstance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public class SetAzureSqlManagedInstance : ManagedInstanceCmdletBase
[Parameter(Mandatory = false,
HelpMessage = "The compute generation for the instance.")]
[ValidateNotNullOrEmpty]
[PSArgumentCompleter(Constants.ComputeGenerationGen5)]
[PSArgumentCompleter(Constants.ComputeGenerationGen5, Constants.ComputeGenerationG8IH, Constants.ComputeGenerationG8IM)]
public string ComputeGeneration { get; set; }

/// <summary>
Expand Down Expand Up @@ -284,6 +284,19 @@ public class SetAzureSqlManagedInstance : ManagedInstanceCmdletBase
[PSArgumentCompleter("Regular", "Freemium")]
public string PricingModel { get; set; }

/// <summary>
/// Gets or sets whether or not this is a GPv2 variant of General Purpose edition.
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "Whether or not this is a GPv2 variant of General Purpose edition.")]
public bool? IsGeneralPurposeV2 { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

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

better to add tests for added parameters and record the tests.


/// <summary>
/// Gets or sets the Storage IOps for instance
/// </summary>
[Parameter(Mandatory = false,
HelpMessage = "Determines how much Storage IOps to associate with instance.")]
public int? StorageIOps { get; set; }

/// <summary>
/// Get the instance to update
/// </summary>
Expand Down Expand Up @@ -373,6 +386,13 @@ protected override IEnumerable<AzureSqlManagedInstanceModel> ApplyUserInputToMod
updateData[0].ServicePrincipal = ResourceServicePrincipalHelper.GetServicePrincipalObjectFromType(this.ServicePrincipalType ?? null);
updateData[0].DatabaseFormat = this.DatabaseFormat?? updateData[0].DatabaseFormat;
updateData[0].PricingModel = this.PricingModel ?? updateData[0].PricingModel;
// If this parameter was not set by the user, we do not want to pick up its current value.
// This is due to the fact that this update might have a target edition that does not use this parameter.
updateData[0].IsGeneralPurposeV2 = this.IsGeneralPurposeV2;
// If this parameter was not set by the user, we do not want to pick up its current value.
// This is due to the fact that this update might have a target edition that does not use this parameter.
// If the target edition uses the parameter, the current value will get picked up later in the update process.
updateData[0].StorageIOps = this.StorageIOps;

return updateData;
}
Expand Down
10 changes: 10 additions & 0 deletions src/Sql/Sql/ManagedInstance/Model/AzureSqlManagedInstanceModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ public class AzureSqlManagedInstanceModel
/// </summary>
public Management.Internal.Resources.Models.Sku Sku { get; set; }

/// <summary>
/// Gets or sets whether or not this is a GPv2 variant of General Purpose edition.
/// </summary>
public bool? IsGeneralPurposeV2 { get; set; }

/// <summary>
/// Gets or sets the fully qualified domain name of the managed instance
/// </summary>
Expand Down Expand Up @@ -93,6 +98,11 @@ public class AzureSqlManagedInstanceModel
/// </summary>
public int? StorageSizeInGB { get; set; }

/// <summary>
/// Gets or sets the maximum storage IOps.
/// </summary>
public int? StorageIOps { get; set; }

/// <summary>
/// Gets or sets the Managed Instance collation
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,9 @@ public AzureSqlManagedInstanceModel UpsertManagedInstance(AzureSqlManagedInstanc
ZoneRedundant = model.ZoneRedundant,
ServicePrincipal = ResourceServicePrincipalHelper.UnwrapServicePrincipalObject(model.ServicePrincipal),
DatabaseFormat = model.DatabaseFormat,
PricingModel = model.PricingModel
PricingModel = model.PricingModel,
IsGeneralPurposeV2 = model.IsGeneralPurposeV2,
StorageIOps = model.StorageIOps
});

return CreateManagedInstanceModelFromResponse(resp);
Expand Down Expand Up @@ -262,6 +264,7 @@ private static AzureSqlManagedInstanceModel CreateManagedInstanceModelFromRespon
managedInstance.LicenseType = resp.LicenseType;
managedInstance.VCores = resp.VCores;
managedInstance.StorageSizeInGB = resp.StorageSizeInGb;
managedInstance.StorageIOps = resp.StorageIOps;
managedInstance.Collation = resp.Collation;
managedInstance.PublicDataEndpointEnabled = resp.PublicDataEndpointEnabled;
managedInstance.ProxyOverride = resp.ProxyOverride;
Expand All @@ -284,6 +287,8 @@ private static AzureSqlManagedInstanceModel CreateManagedInstanceModelFromRespon
managedInstance.Sku = sku;
managedInstance.Administrators = resp.Administrators;

managedInstance.IsGeneralPurposeV2 = resp.IsGeneralPurposeV2;

if (managedInstance.Administrators != null && managedInstance.Administrators.AdministratorType == null)
{
managedInstance.Administrators.AdministratorType = "ActiveDirectory";
Expand Down
20 changes: 19 additions & 1 deletion src/Sql/Sql/help/Get-AzSqlInstance.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,15 @@ ManagedInstanceName : managedInstance1
Tags :
Identity : Microsoft.Azure.Management.Sql.Models.ResourceIdentity
Sku : Microsoft.Azure.Management.Internal.Resources.Models.Sku
IsGeneralPurposeV2 :
FullyQualifiedDomainName : managedInstance1.wcusxxxxxxxxxxxxx.database.windows.net
AdministratorLogin : adminLogin1
AdministratorPassword :
SubnetId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourcegroup01/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name
LicenseType : BasePrice
VCores : 8
StorageSizeInGB : 512
StorageIOps :
ZoneRedundant : false

Location : westcentralus
Expand All @@ -77,20 +79,22 @@ ManagedInstanceName : managedInstance2
Tags :
Identity : Microsoft.Azure.Management.Sql.Models.ResourceIdentity
Sku : Microsoft.Azure.Management.Internal.Resources.Models.Sku
IsGeneralPurposeV2 :
FullyQualifiedDomainName : managedInstance2.wcusxxxxxxxxxxxxx.database.windows.net
AdministratorLogin : adminLogin2
AdministratorPassword :
SubnetId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourcegroup01/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name
LicenseType : BasePrice
VCores : 8
StorageSizeInGB : 512
StorageIOps :
DnsZone : ad35cna0mw
ZoneRedundant : false
```

This command gets information about all instances assigned to the resource group ResourceGroup01.

### Example 2: Get information about an instance
### Example 2: Get information about an instance
```powershell
Get-AzSqlInstance -Name "managedInstance1" -ResourceGroupName "ResourceGroup01"
```
Expand All @@ -103,13 +107,15 @@ ManagedInstanceName : managedInstance1
Tags :
Identity : Microsoft.Azure.Management.Sql.Models.ResourceIdentity
Sku : Microsoft.Azure.Management.Internal.Resources.Models.Sku
IsGeneralPurposeV2 :
FullyQualifiedDomainName : managedInstance1.wcusxxxxxxxxxxxxx.database.windows.net
AdministratorLogin : adminLogin1
AdministratorPassword :
SubnetId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourcegroup01/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name
LicenseType : BasePrice
VCores : 8
StorageSizeInGB : 512
StorageIOps :
DnsZone : ad35cna0mw
ZoneRedundant : false
```
Expand All @@ -129,13 +135,15 @@ ManagedInstanceName : managedInstance1
Tags :
Identity : Microsoft.Azure.Management.Sql.Models.ResourceIdentity
Sku : Microsoft.Azure.Management.Internal.Resources.Models.Sku
IsGeneralPurposeV2 :
FullyQualifiedDomainName : managedInstance1.wcusxxxxxxxxxxxxx.database.windows.net
AdministratorLogin : adminLogin1
AdministratorPassword :
SubnetId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourcegroup01/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name
LicenseType : BasePrice
VCores : 8
StorageSizeInGB : 512
StorageIOps :
DnsZone : ad35cna0mw
ZoneRedundant : false

Expand All @@ -146,13 +154,15 @@ ManagedInstanceName : managedInstance2
Tags :
Identity : Microsoft.Azure.Management.Sql.Models.ResourceIdentity
Sku : Microsoft.Azure.Management.Internal.Resources.Models.Sku
IsGeneralPurposeV2 :
FullyQualifiedDomainName : managedInstance2.wcusxxxxxxxxxxxxx.database.windows.net
AdministratorLogin : adminLogin2
AdministratorPassword :
SubnetId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourcegroup01/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name
LicenseType : BasePrice
VCores : 8
StorageSizeInGB : 512
StorageIOps :
DnsZone : ad35cna0mw
ZoneRedundant : false
```
Expand Down Expand Up @@ -308,13 +318,15 @@ ManagedInstanceName : managedInstance1
Tags :
Identity : Microsoft.Azure.Management.Sql.Models.ResourceIdentity
Sku : Microsoft.Azure.Management.Internal.Resources.Models.Sku
IsGeneralPurposeV2 :
FullyQualifiedDomainName : managedInstance1.wcusxxxxxxxxxxxxx.database.windows.net
AdministratorLogin : adminLogin1
AdministratorPassword :
SubnetId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourcegroup01/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name
LicenseType : BasePrice
VCores : 8
StorageSizeInGB : 512
StorageIOps :
DnsZone : ad35cna0mw
InstancePoolName :
ZoneRedundant : false
Expand All @@ -334,13 +346,15 @@ ManagedInstanceName : managedInstance1
Tags :
Identity : Microsoft.Azure.Management.Sql.Models.ResourceIdentity
Sku : Microsoft.Azure.Management.Internal.Resources.Models.Sku
IsGeneralPurposeV2 :
FullyQualifiedDomainName : managedInstance1.wcusxxxxxxxxxxxxx.database.windows.net
AdministratorLogin : adminLogin1
AdministratorPassword :
SubnetId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourcegroup01/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name
LicenseType : BasePrice
VCores : 8
StorageSizeInGB : 512
StorageIOps :
Administrators : Microsoft.Azure.Management.Sql.Models.ManagedInstanceExternalAdministrator
ZoneRedundant : false

Expand All @@ -351,13 +365,15 @@ ManagedInstanceName : managedInstance2
Tags :
Identity : Microsoft.Azure.Management.Sql.Models.ResourceIdentity
Sku : Microsoft.Azure.Management.Internal.Resources.Models.Sku
IsGeneralPurposeV2 :
FullyQualifiedDomainName : managedInstance2.wcusxxxxxxxxxxxxx.database.windows.net
AdministratorLogin : adminLogin2
AdministratorPassword :
SubnetId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourcegroup01/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name
LicenseType : BasePrice
VCores : 8
StorageSizeInGB : 512
StorageIOps :
DnsZone : ad35cna0mw
Administrators : Microsoft.Azure.Management.Sql.Models.ManagedInstanceExternalAdministrator
ZoneRedundant : false
Expand Down Expand Up @@ -392,13 +408,15 @@ ManagedInstanceName : managedInstance1
Tags :
Identity : Microsoft.Azure.Management.Sql.Models.ResourceIdentity
Sku : Microsoft.Azure.Management.Internal.Resources.Models.Sku
IsGeneralPurposeV2 :
FullyQualifiedDomainName : managedInstance1.wcusxxxxxxxxxxxxx.database.windows.net
AdministratorLogin : adminLogin1
AdministratorPassword :
SubnetId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourcegroup01/providers/Microsoft.Network/virtualNetworks/vnet_name/subnets/subnet_name
LicenseType : BasePrice
VCores : 8
StorageSizeInGB : 512
StorageIOps :
DnsZone : ad35cna0mw
Administrators : Microsoft.Azure.Management.Sql.Models.ManagedInstanceExternalAdministrator
ZoneRedundant : false
Expand Down
Loading
Loading