mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-28 09:35:37 -05:00
Retrieve Azure SLO details in Database Handler (#2094)
This commit is contained in:
@@ -21,19 +21,13 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
[DebuggerDisplay("{Name,nq}")]
|
||||
public class AzureEdition
|
||||
{
|
||||
public static readonly AzureEdition Basic = new AzureEdition("Basic", "SR.BasicAzureEdition");
|
||||
public static readonly AzureEdition Standard = new AzureEdition("Standard", "SR.StandardAzureEdition");
|
||||
public static readonly AzureEdition Premium = new AzureEdition("Premium", "SR.PremiumAzureEdition");
|
||||
public static readonly AzureEdition DataWarehouse = new AzureEdition("DataWarehouse", "SR.DataWarehouseAzureEdition");
|
||||
public static readonly AzureEdition GeneralPurpose = new AzureEdition("GeneralPurpose", "SR.GeneralPurposeAzureEdition");
|
||||
public static readonly AzureEdition BusinessCritical = new AzureEdition("BusinessCritical", "SR.BusinessCriticalAzureEdition");
|
||||
|
||||
public static readonly AzureEdition Hyperscale = new AzureEdition("Hyperscale", "SR.HyperscaleAzureEdition");
|
||||
// Free does not offer DatabaseSize >=1GB, hence it's not "supported".
|
||||
//public static readonly AzureEdition Free = new AzureEdition("Free", SR.FreeAzureEdition);
|
||||
// Stretch and system do not seem to be applicable, so I'm commenting them out
|
||||
//public static readonly AzureEdition Stretch = new AzureEdition("Stretch", SR.StretchAzureEdition);
|
||||
//public static readonly AzureEdition System = new AzureEdition("System", SR.SystemAzureEdition);
|
||||
public static readonly AzureEdition Basic = new AzureEdition("Basic", SR.BasicAzureEdition);
|
||||
public static readonly AzureEdition Standard = new AzureEdition("Standard", SR.StandardAzureEdition);
|
||||
public static readonly AzureEdition Premium = new AzureEdition("Premium", SR.PremiumAzureEdition);
|
||||
public static readonly AzureEdition DataWarehouse = new AzureEdition("DataWarehouse", SR.DataWarehouseAzureEdition);
|
||||
public static readonly AzureEdition GeneralPurpose = new AzureEdition("GeneralPurpose", SR.GeneralPurposeAzureEdition);
|
||||
public static readonly AzureEdition BusinessCritical = new AzureEdition("BusinessCritical", SR.BusinessCriticalAzureEdition);
|
||||
public static readonly AzureEdition Hyperscale = new AzureEdition("Hyperscale", SR.HyperscaleAzureEdition);
|
||||
|
||||
internal string Name { get; private set; }
|
||||
internal string DisplayName { get; private set; }
|
||||
@@ -320,6 +314,18 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{ "LRS", "Local" },
|
||||
{ "ZRS", "Zone" }
|
||||
};
|
||||
private static readonly string[] backupRedundancyLevels = bsrAPIToUIValueMapping.Values.ToArray();
|
||||
|
||||
/// <summary>
|
||||
/// All valid backup storage redundancy levels for an Azure SQL database
|
||||
/// </summary>
|
||||
public static string[] BackupStorageRedundancyLevels
|
||||
{
|
||||
get
|
||||
{
|
||||
return backupRedundancyLevels;
|
||||
}
|
||||
}
|
||||
|
||||
//KeyValuePair contains the BackupStorageRedundancy values for all azure editions.
|
||||
private static readonly KeyValuePair<int, string[]> keyValuePair = new KeyValuePair<int, string[]>(0, bsrAPIToUIValueMapping.Values.ToArray());
|
||||
@@ -516,7 +522,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
/// We do this so that the AzureEdition enum can have values such as NONE or DEFAULT added
|
||||
/// without requiring clients to explicitly filter out those values themselves each time.
|
||||
/// <returns></returns>
|
||||
public static IEnumerable<AzureEdition> GetValidAzureEditionOptions(object unused)
|
||||
public static IEnumerable<AzureEdition> GetValidAzureEditionOptions()
|
||||
{
|
||||
yield return AzureEdition.Basic;
|
||||
yield return AzureEdition.Standard;
|
||||
@@ -524,10 +530,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
yield return AzureEdition.DataWarehouse;
|
||||
yield return AzureEdition.BusinessCritical;
|
||||
yield return AzureEdition.GeneralPurpose;
|
||||
//yield return AzureEdition.Free;
|
||||
yield return AzureEdition.Hyperscale;
|
||||
//yield return AzureEdition.Stretch;
|
||||
//yield return AzureEdition.System;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ using Microsoft.SqlTools.ServiceLayer.Management;
|
||||
using AzureEdition = Microsoft.SqlTools.ServiceLayer.Admin.AzureSqlDbHelper.AzureEdition;
|
||||
using System;
|
||||
using System.Data;
|
||||
using Microsoft.SqlTools.Utility;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
@@ -91,58 +93,56 @@ namespace Microsoft.SqlTools.ServiceLayer.Admin
|
||||
{
|
||||
return AzureSqlDbHelper.GetAzureEditionDisplayName(this.currentState.azureEdition);
|
||||
}
|
||||
// set
|
||||
// {
|
||||
// AzureEdition edition;
|
||||
// if (AzureSqlDbHelper.TryGetAzureEditionFromDisplayName(value, out edition))
|
||||
// {
|
||||
// //Try to get the ServiceLevelObjective from the api,if not the default hardcoded service level objectives will be retrieved.
|
||||
// string serverLevelObjective = AzureServiceLevelObjectiveProvider.TryGetAzureServiceLevelObjective(value, AzureServiceLocation);
|
||||
set
|
||||
{
|
||||
AzureEdition edition;
|
||||
if (AzureSqlDbHelper.TryGetAzureEditionFromDisplayName(value, out edition))
|
||||
{
|
||||
//Try to get the ServiceLevelObjective from the api,if not the default hardcoded service level objectives will be retrieved.
|
||||
// string serverLevelObjective = AzureServiceLevelObjectiveProvider.TryGetAzureServiceLevelObjective(value, AzureServiceLocation);
|
||||
|
||||
// if (!string.IsNullOrEmpty(serverLevelObjective))
|
||||
// {
|
||||
// this.currentState.azureEdition = edition;
|
||||
// this.currentState.currentServiceLevelObjective = serverLevelObjective;
|
||||
// // Instead of creating db instance with default Edition, update EditionToCreate while selecting Edition from the UI.
|
||||
// this.EditionToCreate = MapAzureEditionToDbEngineEdition(edition);
|
||||
// string storageAccountType = AzureServiceLevelObjectiveProvider.TryGetAzureStorageType(value, AzureServiceLocation);
|
||||
// if (!string.IsNullOrEmpty(storageAccountType))
|
||||
// {
|
||||
// this.currentState.backupStorageRedundancy = storageAccountType;
|
||||
// }
|
||||
// if (!string.IsNullOrEmpty(serverLevelObjective))
|
||||
// {
|
||||
// this.currentState.azureEdition = edition;
|
||||
// this.currentState.currentServiceLevelObjective = serverLevelObjective;
|
||||
// // Instead of creating db instance with default Edition, update EditionToCreate while selecting Edition from the UI.
|
||||
// this.EditionToCreate = MapAzureEditionToDbEngineEdition(edition);
|
||||
// string storageAccountType = AzureServiceLevelObjectiveProvider.TryGetAzureStorageType(value, AzureServiceLocation);
|
||||
// if (!string.IsNullOrEmpty(storageAccountType))
|
||||
// {
|
||||
// this.currentState.backupStorageRedundancy = storageAccountType;
|
||||
// }
|
||||
|
||||
// // Try to get the azure maxsize from the api,if not the default hardcoded maxsize will be retrieved.
|
||||
// DbSize dbSize = AzureServiceLevelObjectiveProvider.TryGetAzureMaxSize(value, serverLevelObjective, AzureServiceLocation);
|
||||
// if (!string.IsNullOrEmpty(dbSize.ToString()))
|
||||
// {
|
||||
// this.currentState.maxSize = new DbSize(dbSize.Size, dbSize.SizeUnit);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// if (edition == this.currentState.azureEdition)
|
||||
// { //No changes, return early since we don't need to do any of the changes below
|
||||
// return;
|
||||
// }
|
||||
// // Try to get the azure maxsize from the api,if not the default hardcoded maxsize will be retrieved.
|
||||
// DbSize dbSize = AzureServiceLevelObjectiveProvider.TryGetAzureMaxSize(value, serverLevelObjective, AzureServiceLocation);
|
||||
// if (!string.IsNullOrEmpty(dbSize.ToString()))
|
||||
// {
|
||||
// this.currentState.maxSize = new DbSize(dbSize.Size, dbSize.SizeUnit);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
if (edition == this.currentState.azureEdition)
|
||||
{ // No changes, return early since we don't need to do any of the changes below
|
||||
return;
|
||||
}
|
||||
|
||||
// this.currentState.azureEdition = edition;
|
||||
// this.EditionToCreate = MapAzureEditionToDbEngineEdition(edition);
|
||||
// this.CurrentServiceLevelObjective = AzureSqlDbHelper.GetDefaultServiceObjective(edition);
|
||||
// this.BackupStorageRedundancy = AzureSqlDbHelper.GetDefaultBackupStorageRedundancy(edition);
|
||||
// var defaultSize = AzureSqlDbHelper.GetDatabaseDefaultSize(edition);
|
||||
this.currentState.azureEdition = edition;
|
||||
this.EditionToCreate = MapAzureEditionToDbEngineEdition(edition);
|
||||
this.CurrentServiceLevelObjective = AzureSqlDbHelper.GetDefaultServiceObjective(edition);
|
||||
this.BackupStorageRedundancy = AzureSqlDbHelper.GetDefaultBackupStorageRedundancy(edition);
|
||||
var defaultSize = AzureSqlDbHelper.GetDatabaseDefaultSize(edition);
|
||||
|
||||
// this.MaxSize = defaultSize == null ? String.Empty : defaultSize.ToString();
|
||||
// }
|
||||
// this.NotifyObservers();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// //Can't really do much if we fail to parse the display name so just leave it as is and log a message
|
||||
// System.Diagnostics.Debug.Assert(false,
|
||||
// string.Format(CultureInfo.InvariantCulture,
|
||||
// "Failed to parse edition display name '{0}' back into AzureEdition", value));
|
||||
// }
|
||||
// }
|
||||
this.MaxSize = defaultSize == null ? String.Empty : defaultSize.ToString();
|
||||
// }
|
||||
this.NotifyObservers();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Can't really do much if we fail to parse the display name so just leave it as is and log a message
|
||||
Logger.Write(TraceEventType.Error, $"Failed to parse edition display name '{value}' back into AzureEdition");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user