mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 10:58:30 -05:00
[SQL Migration] Upgrade Microsoft.SqlServer.Migration.Assessment (#1734)
* WIP - update NuGet and add xevent assessment request * Update API * Update nupkg to official build * Add try/catch around individual recommendation models * Clean up * Add HS to SQL DB SKU recommendation input
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
<PackageReference Update="Microsoft.Azure.Kusto.Data" Version="9.0.4" />
|
<PackageReference Update="Microsoft.Azure.Kusto.Data" Version="9.0.4" />
|
||||||
<PackageReference Update="Microsoft.Azure.Kusto.Language" Version="9.0.4" />
|
<PackageReference Update="Microsoft.Azure.Kusto.Language" Version="9.0.4" />
|
||||||
<PackageReference Update="Microsoft.SqlServer.Assessment" Version="[1.1.9]" />
|
<PackageReference Update="Microsoft.SqlServer.Assessment" Version="[1.1.9]" />
|
||||||
<PackageReference Update="Microsoft.SqlServer.Migration.Assessment" Version="1.0.20221014.16" />
|
<PackageReference Update="Microsoft.SqlServer.Migration.Assessment" Version="1.0.20221028.23" />
|
||||||
<PackageReference Update="Microsoft.SqlServer.Management.SqlParser" Version="160.22519.0" />
|
<PackageReference Update="Microsoft.SqlServer.Management.SqlParser" Version="160.22519.0" />
|
||||||
<PackageReference Update="Microsoft.Azure.OperationalInsights" Version="1.0.0" />
|
<PackageReference Update="Microsoft.Azure.OperationalInsights" Version="1.0.0" />
|
||||||
<PackageReference Update="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" />
|
<PackageReference Update="Microsoft.CodeAnalysis.CSharp" Version="3.10.0" />
|
||||||
|
|||||||
Binary file not shown.
@@ -156,6 +156,20 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
|||||||
internal string sqlDbReportPath;
|
internal string sqlDbReportPath;
|
||||||
internal string sqlMiReportPath;
|
internal string sqlMiReportPath;
|
||||||
internal string sqlVmReportPath;
|
internal string sqlVmReportPath;
|
||||||
|
|
||||||
|
// Create a new empty RecommendationResultSet
|
||||||
|
internal RecommendationResultSet()
|
||||||
|
{
|
||||||
|
this.sqlDbResults = new List<SkuRecommendationResult>();
|
||||||
|
this.sqlMiResults = new List<SkuRecommendationResult>();
|
||||||
|
this.sqlVmResults = new List<SkuRecommendationResult>();
|
||||||
|
this.sqlDbDurationInMs = -1;
|
||||||
|
this.sqlMiDurationInMs = -1;
|
||||||
|
this.sqlVmDurationInMs = -1;
|
||||||
|
this.sqlDbReportPath = "";
|
||||||
|
this.sqlMiReportPath = "";
|
||||||
|
this.sqlVmReportPath = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetSkuRecommendationsRequest
|
public class GetSkuRecommendationsRequest
|
||||||
|
|||||||
@@ -10,8 +10,20 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
|
|||||||
{
|
{
|
||||||
public class MigrationAssessmentsParams
|
public class MigrationAssessmentsParams
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Owner URI
|
||||||
|
/// </summary>
|
||||||
public string OwnerUri { get; set; }
|
public string OwnerUri { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of databases to assess
|
||||||
|
/// </summary>
|
||||||
public string[] Databases { get; set; }
|
public string[] Databases { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Folder path to XEvents files to be assessed, if applicable. Empty string to disable XEvents assessment.
|
||||||
|
/// </summary>
|
||||||
|
public string XEventsFilesFolderPath { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MigrationAssessmentResult
|
public class MigrationAssessmentResult
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ using Microsoft.SqlServer.Migration.SkuRecommendation.ElasticStrategy.AzureSqlMa
|
|||||||
using Microsoft.SqlServer.Migration.SkuRecommendation.ElasticStrategy.AzureSqlDatabase;
|
using Microsoft.SqlServer.Migration.SkuRecommendation.ElasticStrategy.AzureSqlDatabase;
|
||||||
using Microsoft.SqlServer.Migration.SkuRecommendation.Models;
|
using Microsoft.SqlServer.Migration.SkuRecommendation.Models;
|
||||||
using Microsoft.SqlServer.Migration.SkuRecommendation.Utils;
|
using Microsoft.SqlServer.Migration.SkuRecommendation.Utils;
|
||||||
|
using Microsoft.SqlServer.Migration.Assessment.Common.Models;
|
||||||
|
using Microsoft.SqlServer.Migration.Assessment.Common.Utils;
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.Migration
|
namespace Microsoft.SqlTools.ServiceLayer.Migration
|
||||||
{
|
{
|
||||||
@@ -157,7 +159,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration
|
|||||||
connectionStrings.Add(ConnectionService.BuildConnectionString(connInfo.ConnectionDetails));
|
connectionStrings.Add(ConnectionService.BuildConnectionString(connInfo.ConnectionDetails));
|
||||||
}
|
}
|
||||||
string[] assessmentConnectionStrings = connectionStrings.ToArray();
|
string[] assessmentConnectionStrings = connectionStrings.ToArray();
|
||||||
var results = await GetAssessmentItems(assessmentConnectionStrings);
|
var results = await GetAssessmentItems(assessmentConnectionStrings, parameters.XEventsFilesFolderPath);
|
||||||
await requestContext.SendResult(results);
|
await requestContext.SendResult(results);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -271,8 +273,26 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration
|
|||||||
dbsToInclude: new HashSet<string>(parameters.DatabaseAllowList),
|
dbsToInclude: new HashSet<string>(parameters.DatabaseAllowList),
|
||||||
hostRequirements: new SqlServerHostRequirements() { NICCount = 1 });
|
hostRequirements: new SqlServerHostRequirements() { NICCount = 1 });
|
||||||
|
|
||||||
RecommendationResultSet baselineResults = GenerateBaselineRecommendations(req, parameters);
|
RecommendationResultSet baselineResults;
|
||||||
RecommendationResultSet elasticResults = GenerateElasticRecommendations(req, parameters);
|
RecommendationResultSet elasticResults;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
baselineResults = GenerateBaselineRecommendations(req, parameters);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
baselineResults = new RecommendationResultSet();
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
elasticResults = GenerateElasticRecommendations(req, parameters);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
elasticResults = new RecommendationResultSet();
|
||||||
|
}
|
||||||
|
|
||||||
GetSkuRecommendationsResult results = new GetSkuRecommendationsResult
|
GetSkuRecommendationsResult results = new GetSkuRecommendationsResult
|
||||||
{
|
{
|
||||||
@@ -586,11 +606,16 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal async Task<MigrationAssessmentResult> GetAssessmentItems(string[] connectionStrings)
|
internal async Task<MigrationAssessmentResult> GetAssessmentItems(string[] connectionStrings, string xEventsFilesFolderPath)
|
||||||
{
|
{
|
||||||
SqlAssessmentConfiguration.EnableLocalLogging = true;
|
SqlAssessmentConfiguration.EnableLocalLogging = true;
|
||||||
SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath = Path.GetDirectoryName(Logger.LogFileFullPath);
|
SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath = Path.GetDirectoryName(Logger.LogFileFullPath);
|
||||||
DmaEngine engine = new DmaEngine(connectionStrings);
|
|
||||||
|
SqlConnectionLocator locator = new SqlConnectionLocator();
|
||||||
|
locator.ConnectionStrings.AddRange(connectionStrings);
|
||||||
|
locator.XeventsFilesFolderPath = xEventsFilesFolderPath;
|
||||||
|
DmaEngine engine = new DmaEngine(locator);
|
||||||
|
|
||||||
ISqlMigrationAssessmentModel contextualizedAssessmentResult = await engine.GetTargetAssessmentResultsListWithCheck(System.Threading.CancellationToken.None);
|
ISqlMigrationAssessmentModel contextualizedAssessmentResult = await engine.GetTargetAssessmentResultsListWithCheck(System.Threading.CancellationToken.None);
|
||||||
var assessmentReportFileName = String.Format("SqlAssessmentReport-{0}.json", DateTime.UtcNow.ToString("yyyyMMddHH-mmss", CultureInfo.InvariantCulture));
|
var assessmentReportFileName = String.Format("SqlAssessmentReport-{0}.json", DateTime.UtcNow.ToString("yyyyMMddHH-mmss", CultureInfo.InvariantCulture));
|
||||||
var assessmentReportFullPath = Path.Combine(SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath, assessmentReportFileName);
|
var assessmentReportFullPath = Path.Combine(SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath, assessmentReportFileName);
|
||||||
@@ -715,7 +740,7 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration
|
|||||||
switch (targetPlatform)
|
switch (targetPlatform)
|
||||||
{
|
{
|
||||||
case "AzureSqlDatabase":
|
case "AzureSqlDatabase":
|
||||||
// Gen5 BC/GP DB
|
// Gen5 BC/GP/HS DB
|
||||||
eligibleSkuCategories.Add(new AzureSqlSkuPaaSCategory(
|
eligibleSkuCategories.Add(new AzureSqlSkuPaaSCategory(
|
||||||
AzureSqlTargetPlatform.AzureSqlDatabase,
|
AzureSqlTargetPlatform.AzureSqlDatabase,
|
||||||
AzureSqlPurchasingModel.vCore,
|
AzureSqlPurchasingModel.vCore,
|
||||||
@@ -729,16 +754,22 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration
|
|||||||
AzureSqlPaaSServiceTier.GeneralPurpose,
|
AzureSqlPaaSServiceTier.GeneralPurpose,
|
||||||
ComputeTier.Provisioned,
|
ComputeTier.Provisioned,
|
||||||
AzureSqlPaaSHardwareType.Gen5));
|
AzureSqlPaaSHardwareType.Gen5));
|
||||||
|
eligibleSkuCategories.Add(new AzureSqlSkuPaaSCategory(
|
||||||
|
AzureSqlTargetPlatform.AzureSqlDatabase,
|
||||||
|
AzureSqlPurchasingModel.vCore,
|
||||||
|
AzureSqlPaaSServiceTier.HyperScale,
|
||||||
|
ComputeTier.Provisioned,
|
||||||
|
AzureSqlPaaSHardwareType.Gen5));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "AzureSqlManagedInstance":
|
case "AzureSqlManagedInstance":
|
||||||
// Gen5 BC/GP MI
|
// Gen5 BC/GP MI
|
||||||
eligibleSkuCategories.Add(new AzureSqlSkuPaaSCategory(
|
eligibleSkuCategories.Add(new AzureSqlSkuPaaSCategory(
|
||||||
AzureSqlTargetPlatform.AzureSqlManagedInstance,
|
AzureSqlTargetPlatform.AzureSqlManagedInstance,
|
||||||
AzureSqlPurchasingModel.vCore,
|
AzureSqlPurchasingModel.vCore,
|
||||||
AzureSqlPaaSServiceTier.BusinessCritical,
|
AzureSqlPaaSServiceTier.BusinessCritical,
|
||||||
ComputeTier.Provisioned,
|
ComputeTier.Provisioned,
|
||||||
AzureSqlPaaSHardwareType.Gen5));
|
AzureSqlPaaSHardwareType.Gen5));
|
||||||
|
|
||||||
eligibleSkuCategories.Add(new AzureSqlSkuPaaSCategory(
|
eligibleSkuCategories.Add(new AzureSqlSkuPaaSCategory(
|
||||||
AzureSqlTargetPlatform.AzureSqlManagedInstance,
|
AzureSqlTargetPlatform.AzureSqlManagedInstance,
|
||||||
|
|||||||
Reference in New Issue
Block a user