Adding a flag for migration blocker flag in sql assessment and switching to new APIs (#1242)

* Adding a flag for migration blocker in sql assessment and switching to new APIs

* Fixing var names
This commit is contained in:
Aasim Khan
2021-09-08 15:15:56 -07:00
committed by GitHub
parent 93728df53d
commit 6f5cac4cb5
5 changed files with 18 additions and 19 deletions

View File

@@ -24,7 +24,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.0.305]" /> <PackageReference Update="Microsoft.SqlServer.Assessment" Version="[1.0.305]" />
<PackageReference Update="Microsoft.SqlServer.Migration.Assessment" Version="1.0.20210714.5" /> <PackageReference Update="Microsoft.SqlServer.Migration.Assessment" Version="1.0.20210902.7" />
<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" />
<PackageReference Update="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.10.0" /> <PackageReference Update="Microsoft.CodeAnalysis.CSharp.Workspaces" Version="3.10.0" />

View File

@@ -27,16 +27,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
/// </summary> /// </summary>
public string RuleId { get; set; } public string RuleId { get; set; }
/// <summary>
/// Gets or sets assessed target's type.
/// Supported values: 1 - server, 2 - database.
/// </summary>
public SqlObjectType TargetType { get; set; }
/// <summary> /// <summary>
/// Gets or sets the assessed object's name. /// Gets or sets the assessed object's name.
/// </summary> /// </summary>
public string TargetName { get; set; } public string TargetType { get; set; }
/// <summary> /// <summary>
/// Gets or sets the database name. /// Gets or sets the database name.
@@ -89,5 +83,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
public string IssueCategory { get; set; } public string IssueCategory { get; set; }
public ImpactedObjectInfo[] ImpactedObjects { get; set; } public ImpactedObjectInfo[] ImpactedObjects { get; set; }
/// <summary>
/// This flag is set if the assessment result is a blocker for migration to Target Platform.
/// </summary>
public bool DatabaseRestoreFails { get; set; }
} }
} }

View File

@@ -174,10 +174,10 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration
internal async Task<MigrationAssessmentResult> GetAssessmentItems(string[] connectionStrings) internal async Task<MigrationAssessmentResult> GetAssessmentItems(string[] connectionStrings)
{ {
SqlAssessmentConfiguration.EnableLocalLogging = true; SqlAssessmentConfiguration.EnableLocalLogging = true;
SqlAssessmentConfiguration.EnableReportCreation = true;
SqlAssessmentConfiguration.AssessmentReportAndLogsRootFolderPath = Path.GetDirectoryName(Logger.LogFileFullPath); SqlAssessmentConfiguration.AssessmentReportAndLogsRootFolderPath = Path.GetDirectoryName(Logger.LogFileFullPath);
DmaEngine engine = new DmaEngine(connectionStrings); DmaEngine engine = new DmaEngine(connectionStrings);
ISqlMigrationAssessmentModel contextualizedAssessmentResult = await engine.GetTargetAssessmentResultsList(System.Threading.CancellationToken.None); ISqlMigrationAssessmentModel contextualizedAssessmentResult = await engine.GetTargetAssessmentResultsListWithCheck(System.Threading.CancellationToken.None);
engine.SaveAssessmentResultsToJson(contextualizedAssessmentResult, false);
var server = (contextualizedAssessmentResult.Servers.Count > 0)? ParseServerAssessmentInfo(contextualizedAssessmentResult.Servers[0], engine): null; var server = (contextualizedAssessmentResult.Servers.Count > 0)? ParseServerAssessmentInfo(contextualizedAssessmentResult.Servers[0], engine): null;
return new MigrationAssessmentResult() return new MigrationAssessmentResult()
{ {
@@ -246,25 +246,25 @@ namespace Microsoft.SqlTools.ServiceLayer.Migration
{ {
return assessmentResults.Select(r => return assessmentResults.Select(r =>
{ {
var check = engine.GetRuleMetadata(r.FeatureId, r.AppliesToMigrationTargetPlatform);
return new MigrationAssessmentInfo() return new MigrationAssessmentInfo()
{ {
CheckId = check.Id, CheckId = r.Check.Id,
Description = check.Description, Description = r.Check.Description,
DisplayName = check.DisplayName, DisplayName = r.Check.DisplayName,
HelpLink = check.HelpLink, HelpLink = r.Check.HelpLink,
Level = check.Level.ToString(), Level = r.Check.Level.ToString(),
TargetName = r.AppliesToMigrationTargetPlatform.ToString(), TargetType = r.TargetType.ToString(),
DatabaseName = r.DatabaseName, DatabaseName = r.DatabaseName,
ServerName = r.ServerName, ServerName = r.ServerName,
Tags = check.Tags.ToArray(), Tags = r.Check.Tags.ToArray(),
RulesetName = Engine.Configuration.DefaultRuleset.Name, RulesetName = Engine.Configuration.DefaultRuleset.Name,
RulesetVersion = Engine.Configuration.DefaultRuleset.Version.ToString(), RulesetVersion = Engine.Configuration.DefaultRuleset.Version.ToString(),
RuleId = r.FeatureId.ToString(), RuleId = r.FeatureId.ToString(),
Message = r.Message, Message = r.Message,
AppliesToMigrationTargetPlatform = r.AppliesToMigrationTargetPlatform.ToString(), AppliesToMigrationTargetPlatform = r.AppliesToMigrationTargetPlatform.ToString(),
IssueCategory = r.IssueCategory.ToString(), IssueCategory = r.IssueCategory.ToString(),
ImpactedObjects = ParseImpactedObjects(r.ImpactedObjects) ImpactedObjects = ParseImpactedObjects(r.ImpactedObjects),
DatabaseRestoreFails = r.DatabaseRestoreFails
}; };
}).ToArray(); }).ToArray();
} }