diff --git a/src/Microsoft.SqlTools.ServiceLayer/HostLoader.cs b/src/Microsoft.SqlTools.ServiceLayer/HostLoader.cs
index 414bf7a3..58e0a65b 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/HostLoader.cs
+++ b/src/Microsoft.SqlTools.ServiceLayer/HostLoader.cs
@@ -27,9 +27,6 @@ using Microsoft.SqlTools.ServiceLayer.Hosting;
using Microsoft.SqlTools.ServiceLayer.LanguageExtensibility;
using Microsoft.SqlTools.ServiceLayer.LanguageServices;
using Microsoft.SqlTools.ServiceLayer.Metadata;
-#if INCLUDE_MIGRATION
-using Microsoft.SqlTools.ServiceLayer.Migration;
-#endif
using Microsoft.SqlTools.ServiceLayer.ModelManagement;
using Microsoft.SqlTools.ServiceLayer.NotebookConvert;
using Microsoft.SqlTools.ServiceLayer.ObjectManagement;
@@ -162,11 +159,6 @@ namespace Microsoft.SqlTools.ServiceLayer
NotebookConvertService.Instance.InitializeService(serviceHost);
serviceProvider.RegisterSingleService(NotebookConvertService.Instance);
-#if INCLUDE_MIGRATION
- MigrationService.Instance.InitializeService(serviceHost);
- serviceProvider.RegisterSingleService(MigrationService.Instance);
-#endif
-
TableDesignerService.Instance.InitializeService(serviceHost);
serviceProvider.RegisterSingleService(TableDesignerService.Instance);
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.csproj b/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.csproj
index 3f097e40..156e5ccf 100644
--- a/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.csproj
+++ b/src/Microsoft.SqlTools.ServiceLayer/Microsoft.SqlTools.ServiceLayer.csproj
@@ -21,30 +21,18 @@
true
-
-
-
- Microsoft.SqlServer.SqlToolsServiceLayer.Tool
- 1.3.0
- .NET client SQL Tools Service application, usable as a dotnet tool. This package is intended to be used by internal applications only and should not be referenced directly.
- true
- $(AssemblyName)
- ./nupkg
-
-
-
-
-
-
-
- $(DefineConstants);INCLUDE_MIGRATION
-
-
-
-
-
-
-
+
+ Microsoft.SqlServer.SqlToolsServiceLayer.Tool
+ 1.3.0
+ .NET client SQL Tools Service application, usable as a dotnet tool. This package is intended to be used by internal applications only and should not be referenced directly.
+ true
+ $(AssemblyName)
+ ./nupkg
+
+
+
+
+
@@ -56,9 +44,6 @@
-
-
-
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/CertificateMigrationProgressEvent.cs b/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/CertificateMigrationProgressEvent.cs
deleted file mode 100644
index fe3678eb..00000000
--- a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/CertificateMigrationProgressEvent.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-#nullable disable
-
-using Microsoft.SqlTools.Hosting.Protocol.Contracts;
-
-namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
-{
- ///
- /// Parameters for the certificate migration progress event
- ///
- public class CertificateMigrationProgressParams
- {
- ///
- /// Database name
- ///
- public string Name { get; set; }
-
- ///
- /// Message related to the success status. true should describe a positive outcome. false should have an error.
- ///
- public string Message { get; set; }
-
- ///
- /// Result of migration
- ///
- public bool Success { get; set; }
- }
-
-
- ///
- /// Create a certificate migration request. This should be register at the client.
- ///
- public class CertificateMigrationProgressEvent
- {
- ///
- /// Name and parameters for the event definition.
- ///
- public static readonly
- EventType Type =
- EventType.Create("migration/tdemigrationprogress");
- }
-}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/CertificateMigrationRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/CertificateMigrationRequest.cs
deleted file mode 100644
index 0028c037..00000000
--- a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/CertificateMigrationRequest.cs
+++ /dev/null
@@ -1,113 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-#nullable disable
-
-using System.Collections.Generic;
-using Microsoft.SqlTools.Hosting.Protocol.Contracts;
-
-namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
-{
- ///
- /// Parameters for the certificate migration operation
- ///
- public class CertificateMigrationParams
- {
- ///
- /// List of databses to migrate the certificates
- ///
- public List EncryptedDatabases { get; set; } = new List();
-
- ///
- /// Source connection string to the server
- ///
- public string SourceSqlConnectionString { get; set; }
-
- ///
- /// Target subscription id
- ///
- public string TargetSubscriptionId { get; set; }
-
- ///
- /// Target resource group name
- ///
- public string TargetResourceGroupName { get; set; }
-
- ///
- /// Target manages instance name
- ///
- public string TargetManagedInstanceName { get; set; }
-
- ///
- /// Place where certificates will be exported
- ///
- public string NetworkSharePath { get; set; }
-
- ///
- /// Domain for the user credentials able to read from the shared path
- ///
- public string NetworkShareDomain { get; set; }
-
- ///
- /// Username for the credentials able to read from the shared path
- ///
- public string NetworkShareUserName { get; set; }
-
- ///
- /// Password for the credentials able to read from the shared path
- ///
- public string NetworkSharePassword { get; set; }
-
- ///
- /// Access token for the ARM client
- ///
- public string AccessToken { get; set; }
- }
-
- ///
- /// Result for the certificate migration operation
- ///
- public class CertificateMigrationResult
- {
- ///
- /// List of the status of each certificate migration result attempted.
- ///
- public List MigrationStatuses { get; set; } = new List();
- }
-
- ///
- /// Result for an individual database certificate migration
- ///
- public class CertificateMigrationEntryResult
- {
- ///
- /// The name of the database this result represent
- ///
- public string DbName { get; set; }
-
- ///
- /// The result of the migration.
- ///
- public bool Success { get; set; }
-
- ///
- /// Description of the success status or the error message encountered when the migration was not successful
- ///
- public string Message { get; set; }
- }
-
- ///
- /// Certificate migration request definition
- ///
- public class CertificateMigrationRequest
- {
- ///
- /// Name, parameter and return type for the certicate migration operation
- ///
- public static readonly
- RequestType Type =
- RequestType.Create("migration/tdemigration");
- }
-}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/GetSkuRecommendationsRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/GetSkuRecommendationsRequest.cs
deleted file mode 100644
index bf858146..00000000
--- a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/GetSkuRecommendationsRequest.cs
+++ /dev/null
@@ -1,183 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-#nullable disable
-
-using Microsoft.SqlServer.Migration.SkuRecommendation.Contracts.Models;
-using Microsoft.SqlServer.Migration.SkuRecommendation.Models.Sql;
-using Microsoft.SqlTools.Hosting.Protocol.Contracts;
-using System.Collections.Generic;
-
-namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
-{
- public class GetSkuRecommendationsParams
- {
- ///
- /// Folder from which collected performance data will be read from
- ///
- public string DataFolder { get; set; }
-
- ///
- /// Interval at which collected performance data was originally queried at, in seconds
- ///
- public int PerfQueryIntervalInSec { get; set; }
-
- ///
- /// List of target platforms to consider when generating recommendations
- ///
- public List TargetPlatforms { get; set; }
-
- ///
- /// Name of the SQL instance to generate recommendations for
- ///
- public string TargetSqlInstance { get; set; }
-
- ///
- /// Target percentile to use when performing perf data aggregation
- ///
- public int TargetPercentile { get; set; }
-
- ///
- /// Scaling ("comfort") factor when evalulating performance requirements
- ///
- public int ScalingFactor { get; set; }
-
- ///
- /// Start time of collected data points to consider
- ///
- /// TO-DO: do we really need this? it's pretty safe to assume that most users would want us to evaluate all the collected data and not just part of it
- ///
- public string StartTime { get; set; }
-
- ///
- /// End time of collected data points to consider
- ///
- /// TO-DO: do we really need this? it's pretty safe to assume that most users would want us to evaluate all the collected data and not just part of it
- ///
- public string EndTime { get; set; }
-
- ///
- /// Whether or not to consider preview SKUs when generating SKU recommendations
- ///
- public bool IncludePreviewSkus { get; set; }
-
- ///
- /// List of databases to consider when generating recommendations
- ///
- public List DatabaseAllowList { get; set; }
- }
-
- public class GetSkuRecommendationsResult
- {
- ///
- /// List of SQL DB recommendation results, if applicable
- ///
- public List SqlDbRecommendationResults { get; set; }
-
- ///
- /// How long the SQL DB recommendations took to generate, in milliseconds. Equal to -1 if SQL DB recommendations are not applicable.
- ///
- public long SqlDbRecommendationDurationInMs { get; set; }
-
- ///
- /// List of SQL MI recommendation results, if applicable
- ///
- public List SqlMiRecommendationResults { get; set; }
-
- ///
- /// How long the SQL MI recommendations took to generate, in milliseconds. Equal to -1 if SQL MI recommendations are not applicable.
- ///
- public long SqlMiRecommendationDurationInMs { get; set; }
-
- ///
- /// List of SQL VM recommendation results, if applicable
- ///
- public List SqlVmRecommendationResults { get; set; }
-
- ///
- /// How long the SQL VM recommendations took to generate, in milliseconds. Equal to -1 if SQL VM recommendations are not applicable.
- ///
- public long SqlVmRecommendationDurationInMs { get; set; }
-
- ///
- /// List of SQL DB recommendation results generated by the elastic model, if applicable
- ///
- public List ElasticSqlDbRecommendationResults { get; set; }
-
- ///
- /// How long the SQL DB recommendations took to generate using the elastic model, in milliseconds. Equal to -1 if SQL DB elastic recommendations are not applicable.
- ///
- public long ElasticSqlDbRecommendationDurationInMs { get; set; }
-
- ///
- /// List of SQL MI recommendation results generated by the elastic model, if applicable
- ///
- public List ElasticSqlMiRecommendationResults { get; set; }
-
- ///
- /// How long the SQL MI recommendations took to generate using the elastic model, in milliseconds. Equal to -1 if SQL MI elastic recommendations are not applicable.
- ///
- public long ElasticSqlMiRecommendationDurationInMs { get; set; }
-
- ///
- /// List of SQL VM recommendation results generated by the elastic model, if applicable
- ///
- public List ElasticSqlVmRecommendationResults { get; set; }
-
- ///
- /// How long the SQL VM recommendations took to generate using the elastic model, in milliseconds. Equal to -1 if SQL VM elastic recommendations are not applicable.
- ///
- public long ElasticSqlVmRecommendationDurationInMs { get; set; }
-
- ///
- /// SQL instance requirements, representing an aggregated view of the performance requirements of the source instance
- ///
- public SqlInstanceRequirements InstanceRequirements { get; set; }
-
- ///
- /// File paths where the recommendation reports were saved
- ///
- public List SkuRecommendationReportPaths { get; set; }
-
- ///
- /// File paths where the recommendation reports generated by the elastic model were saved
- ///
- public List ElasticSkuRecommendationReportPaths { get; set; }
- }
-
- // Helper class containing recommendation results, durations, and report paths, which is recommendation model-agnostic
- internal class RecommendationResultSet {
- internal List sqlDbResults;
- internal List sqlMiResults;
- internal List sqlVmResults;
- internal long sqlDbDurationInMs;
- internal long sqlMiDurationInMs;
- internal long sqlVmDurationInMs;
- internal string sqlDbReportPath;
- internal string sqlMiReportPath;
- internal string sqlVmReportPath;
-
- // Create a new empty RecommendationResultSet
- internal RecommendationResultSet()
- {
- this.sqlDbResults = new List();
- this.sqlMiResults = new List();
- this.sqlVmResults = new List();
- this.sqlDbDurationInMs = -1;
- this.sqlMiDurationInMs = -1;
- this.sqlVmDurationInMs = -1;
- this.sqlDbReportPath = "";
- this.sqlMiReportPath = "";
- this.sqlVmReportPath = "";
- }
- }
-
- public class GetSkuRecommendationsRequest
- {
- public static readonly
- RequestType Type =
- RequestType.Create("migration/getskurecommendations");
- }
-}
\ No newline at end of file
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/ImpactedObjectInfo.cs b/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/ImpactedObjectInfo.cs
deleted file mode 100644
index 62f4cdaf..00000000
--- a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/ImpactedObjectInfo.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-#nullable disable
-
-namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
-{
- ///
- /// Describes an item returned by SQL Assessment RPC methods
- ///
- public class ImpactedObjectInfo
- {
- public string Name { get; set; }
- public string ImpactDetail { get; set; }
- public string ObjectType { get; set; }
- }
-}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/MigrationAssessmentInfo.cs b/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/MigrationAssessmentInfo.cs
deleted file mode 100644
index 0706998f..00000000
--- a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/MigrationAssessmentInfo.cs
+++ /dev/null
@@ -1,92 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-#nullable disable
-
-namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
-{
- ///
- /// Describes an item returned by SQL Assessment RPC methods
- ///
- public class MigrationAssessmentInfo
- {
- ///
- /// Gets or sets assessment ruleset version.
- ///
- public string RulesetVersion { get; set; }
-
- ///
- /// Gets or sets assessment ruleset name
- ///
- public string RulesetName { get; set; }
-
- ///
- /// Gets or sets assessment ruleset name
- ///
- public string RuleId { get; set; }
-
- ///
- /// Gets or sets the assessed object's name.
- ///
- public string TargetType { get; set; }
-
- ///
- /// Gets or sets the database name.
- ///
- public string DatabaseName { get; set; }
-
- ///
- /// Gets or sets the server name.
- ///
- public string ServerName { get; set; }
-
- ///
- /// Gets or sets check's ID.
- ///
- public string CheckId { get; set; }
-
- ///
- /// Gets or sets tags assigned to this item.
- ///
- public string[] Tags { get; set; }
-
- ///
- /// Gets or sets a display name for this item.
- ///
- public string DisplayName { get; set; }
-
- ///
- /// Gets or sets a brief description of the item's purpose.
- ///
- public string Description { get; set; }
-
- ///
- /// Gets or sets a containing
- /// an link to a page providing detailed explanation
- /// of the best practice.
- ///
- public string HelpLink { get; set; }
-
- ///
- /// Gets or sets a indicating
- /// severity level assigned to this items.
- /// Values are: "Information", "Warning", "Critical".
- ///
- public string Level { get; set; }
-
- public string Message { get; set; }
-
- public string AppliesToMigrationTargetPlatform { get; set; }
-
- public string IssueCategory { get; set; }
-
- public ImpactedObjectInfo[] ImpactedObjects { get; set; }
-
- ///
- /// This flag is set if the assessment result is a blocker for migration to Target Platform.
- ///
- public bool DatabaseRestoreFails { get; set; }
- }
-}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/MigrationAssessmentsRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/MigrationAssessmentsRequest.cs
deleted file mode 100644
index 71d33e39..00000000
--- a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/MigrationAssessmentsRequest.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-#nullable disable
-
-using Microsoft.SqlTools.Hosting.Protocol.Contracts;
-using Microsoft.SqlServer.Migration.Assessment.Common.Contracts.Models;
-
-namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
-{
- public class MigrationAssessmentsParams
- {
- ///
- /// Owner URI
- ///
- public string OwnerUri { get; set; }
-
- ///
- /// List of databases to assess
- ///
- public string[] Databases { get; set; }
-
- ///
- /// Folder path to XEvents files to be assessed, if applicable. Empty string to disable XEvents assessment.
- ///
- public string XEventsFilesFolderPath { get; set; }
- }
-
- public class MigrationAssessmentResult
- {
- ///
- /// Errors that happen while running the assessment
- ///
- public ErrorModel[] Errors { get; set; }
- ///
- /// Result of the assessment
- ///
- public ServerAssessmentProperties AssessmentResult { get; set; }
- ///
- /// Start time of the assessment
- ///
- public string StartTime { get; set; }
- ///
- /// End time of the assessment
- ///
- public string EndedTime { get; set; }
- ///
- /// Contains the raw assessment response
- ///
- public ISqlMigrationAssessmentModel RawAssessmentResult { get; set; }
- ///
- /// File path where the assessment report was saved
- ///
- public string AssessmentReportPath { get; set; }
- }
-
- ///
- /// Retreive metadata for the table described in the TableMetadataParams value
- ///
- public class MigrationAssessmentsRequest
- {
- public static readonly
- RequestType Type =
- RequestType.Create("migration/getassessments");
- }
-}
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/MigrationObjectProperties.cs b/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/MigrationObjectProperties.cs
deleted file mode 100644
index fb0119da..00000000
--- a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/MigrationObjectProperties.cs
+++ /dev/null
@@ -1,135 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-#nullable disable
-
-using Microsoft.SqlServer.Migration.Assessment.Common.Contracts.TargetAssessment.Models;
-
-namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
-{
- public class ServerAssessmentProperties
- {
- ///
- /// Name of the server
- ///
- public string Name { get; set; }
- ///
- /// Cpu cores for the server host
- ///
- public long CpuCoreCount { get; set; }
- ///
- /// Server host physical memory size
- ///
- public double PhysicalServerMemory { get; set; }
- ///
- /// Host operating system of the SQL server
- ///
- public string ServerHostPlatform { get; set; }
- ///
- /// Version of the SQL server
- ///
- public string ServerVersion { get; set; }
- ///
- /// SQL server engine edition
- ///
- public string ServerEngineEdition { get; set; }
- ///
- /// SQL server edition
- ///
- public string ServerEdition { get; set; }
- ///
- /// We use this flag to indicate if the SQL server is part of the failover cluster
- ///
- public bool IsClustered { get; set; }
- ///
- /// Returns the total number of dbs assessed
- ///
- public long NumberOfUserDatabases { get; set; }
- ///
- /// Returns the assessment status
- ///
- public int SqlAssessmentStatus { get; set; }
- ///
- /// Count of Dbs assessed
- ///
- public long AssessedDatabaseCount{get; set;}
- ///
- /// Give assessed server stats for SQL MI compatibility
- ///
- public IServerTargetReadiness SQLManagedInstanceTargetReadiness { get; set; }
- ///
- /// Server assessment results
- ///
- public MigrationAssessmentInfo[] Items { get; set; }
- ///
- /// Server assessment errors
- ///
- public ErrorModel[] Errors { get; set; }
- ///
- /// List of databases that are assessed
- ///
- public DatabaseAssessmentProperties[] Databases { get; set; }
- }
-
- public class DatabaseAssessmentProperties
- {
- ///
- /// Name of the database
- ///
- public string Name { get; set; }
- ///
- /// Compatibility level of the database
- ///
- public string CompatibilityLevel { get; set; }
- ///
- /// Size of the database
- ///
- public double DatabaseSize { get; set; }
- ///
- /// Flag that indicates if the database is replicated
- ///
- public bool IsReplicationEnabled { get; set; }
- ///
- /// Time taken for assessing the database
- ///
- public double AssessmentTimeInMilliseconds { get; set; }
- ///
- /// Database Assessment Results
- ///
- public MigrationAssessmentInfo[] Items { get; set; }
- ///
- /// Database assessment errors
- ///
- public ErrorModel[] Errors {get; set;}
- ///
- /// Flags that indicate if the database is ready for migration
- ///
- public IDatabaseTargetReadiness SQLManagedInstanceTargetReadiness { get; set; }
- }
-
- public class ErrorModel
- {
- ///
- /// Id of the assessment error
- ///
- public string ErrorId { get; set; }
- ///
- /// Error message
- ///
- public string Message { get; set; }
- ///
- /// Summary of the Error
- ///
- public string ErrorSummary { get; set; }
- ///
- /// Possible causes for the error
- ///
- public string PossibleCauses { get; set; }
- ///
- /// Possible mitigation for the error
- ///
- public string Guidance { get; set; }
- }
-}
\ No newline at end of file
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/PerfDataCollectionRequest.cs b/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/PerfDataCollectionRequest.cs
deleted file mode 100644
index 88a2075a..00000000
--- a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/PerfDataCollectionRequest.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-#nullable disable
-
-using Microsoft.SqlTools.Hosting.Protocol.Contracts;
-using System;
-using System.Collections.Generic;
-
-namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
-{
- public class StartPerfDataCollectionParams
- {
- ///
- /// Uri identifier for the connection
- ///
- public string OwnerUri { get; set; }
-
- ///
- /// Folder from which collected performance data will be written to
- ///
- public string DataFolder { get; set; }
-
- ///
- /// Interval at which performance data will be collected, in seconds
- ///
- public int PerfQueryIntervalInSec { get; set; }
-
- ///
- /// Interval at which static (common) data will be collected, in seconds
- ///
- public int StaticQueryIntervalInSec { get; set; }
-
- ///
- /// Number of iterations of performance data collection to run before aggregating and saving to disk
- ///
- public int NumberOfIterations { get; set; }
- }
-
- public class StopPerfDataCollectionParams
- {
- // TO-DO: currently stop data collection doesn't require any parameters
- }
-
- public class RefreshPerfDataCollectionParams
- {
- ///
- /// The last time data collection status was refreshed
- ///
- public DateTime LastRefreshedTime { get; set; }
- }
-
- public class StartPerfDataCollectionResult
- {
- ///
- /// The time data collection started
- ///
- public DateTime DateTimeStarted { get; set; }
- }
-
- public class StopPerfDataCollectionResult
- {
- ///
- /// The time data collection stopped
- ///
- public DateTime DateTimeStopped { get; set; }
- }
-
- public class RefreshPerfDataCollectionResult
- {
- ///
- /// List of status messages captured during data collection
- ///
- public List Messages { get; set; }
-
- ///
- /// List of error messages captured during data collection
- ///
- public List Errors { get; set; }
-
- ///
- /// The last time data collecton status was refreshed
- ///
- public DateTime RefreshTime { get; set; }
-
- ///
- /// Whether or not data collection is currently running
- ///
- public bool IsCollecting { get; set; }
- }
-
- public class StartPerfDataCollectionRequest
- {
- public static readonly
- RequestType Type =
- RequestType.Create("migration/startperfdatacollection");
- }
-
- public class StopPerfDataCollectionRequest
- {
- public static readonly
- RequestType Type =
- RequestType.Create("migration/stopperfdatacollection");
- }
-
- public class RefreshPerfDataCollectionRequest
- {
- public static readonly
- RequestType Type =
- RequestType.Create("migration/refreshperfdatacollection");
- }
-}
\ No newline at end of file
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/StartLoginMigration.cs b/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/StartLoginMigration.cs
deleted file mode 100644
index 36c0f67e..00000000
--- a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/StartLoginMigration.cs
+++ /dev/null
@@ -1,137 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-#nullable disable
-
-using Microsoft.SqlServer.DataCollection.Common.Contracts.OperationsInfrastructure;
-using Microsoft.SqlTools.Hosting.Protocol.Contracts;
-using System.Collections.Generic;
-
-namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
-{
- ///
- /// Represents the steps in login migration.
- ///
- public enum LoginMigrationStep
- {
- ///
- /// Run pre-migration validations
- ///
- StartValidations,
-
- ///
- /// Step to hash passwords and migrate logins
- ///
- MigrateLogins,
-
- ///
- /// Step to establish users and logins from source to target
- ///
- EstablishUserMapping,
-
-
- ///
- /// Step to migrate server roles
- ///
- MigrateServerRoles,
-
- ///
- /// Step to establish roles
- ///
- EstablishServerRoleMapping,
-
- ///
- /// Step to map all the grant/deny permissions for logins
- ///
- SetLoginPermissions,
-
- ///
- /// Step to map all server roles grant/deny permissions
- ///
- SetServerRolePermissions
- }
-
- public class StartLoginMigrationParams
- {
- ///
- /// Connection string to connect to source
- ///
- public string SourceConnectionString { get; set; }
-
- ///
- /// Connection string to connect to target
- ///
- public string TargetConnectionString { get; set; }
-
- ///
- /// List of logins to migrate
- ///
- public List LoginList { get; set; }
-
- ///
- /// Azure active directory domain name (required for Windows Auth)
- ///
- public string AADDomainName{ get; set; }
- }
-
- public class LoginMigrationResult
- {
- ///
- /// Start time of the assessment
- ///
- public IDictionary> ExceptionMap { get; set; }
-
- ///
- /// The login migration step that just completed
- ///
- public LoginMigrationStep CompletedStep { get; set; }
-
- ///
- /// How long this step took
- ///
- public string ElapsedTime{ get; set; }
- }
-
- public class StartLoginMigrationRequest
- {
- public static readonly
- RequestType Type =
- RequestType.Create("migration/startloginmigration");
- }
-
- public class ValidateLoginMigrationRequest
- {
- public static readonly
- RequestType Type =
- RequestType.Create("migration/validateloginmigration");
- }
-
- public class MigrateLoginsRequest
- {
- public static readonly
- RequestType Type =
- RequestType.Create("migration/migratelogins");
- }
-
- public class EstablishUserMappingRequest
- {
- public static readonly
- RequestType Type =
- RequestType.Create("migration/establishusermapping");
- }
- public class MigrateServerRolesAndSetPermissionsRequest
- {
- public static readonly
- RequestType Type =
- RequestType.Create("migration/migrateserverrolesandsetpermissions");
- }
-
- public class LoginMigrationNotification
- {
- public static readonly
- EventType Type =
- EventType.Create("migration/loginmigrationnotification");
- }
-}
\ No newline at end of file
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/ValidateNetworkFileShare.cs b/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/ValidateNetworkFileShare.cs
deleted file mode 100644
index 5434737d..00000000
--- a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/ValidateNetworkFileShare.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-#nullable disable
-
-using Microsoft.SqlTools.Hosting.Protocol.Contracts;
-
-namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
-{
- public class ValidateNetworkFileShareRequestParams
- {
- public string Path { get; set; }
- public string Username { get; set; }
- public string Password { get; set; }
- }
-
- public class ValidateNetworkFileShareRequest
- {
- public static readonly RequestType Type = RequestType.Create("migration/validateNetworkFileShare");
- }
-}
\ No newline at end of file
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/ValidateWindowsAccount.cs b/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/ValidateWindowsAccount.cs
deleted file mode 100644
index ccb95895..00000000
--- a/src/Microsoft.SqlTools.ServiceLayer/Migration/Contracts/ValidateWindowsAccount.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-#nullable disable
-
-using Microsoft.SqlTools.Hosting.Protocol.Contracts;
-
-namespace Microsoft.SqlTools.ServiceLayer.Migration.Contracts
-{
- public class ValidateWindowsAccountRequestParams
- {
- public string Username { get; set; }
- public string Password { get; set; }
- }
-
- public class ValidateWindowsAccountRequest
- {
- public static readonly RequestType Type = RequestType.Create("migration/validateWindowsAccount");
- }
-}
\ No newline at end of file
diff --git a/src/Microsoft.SqlTools.ServiceLayer/Migration/MigrationService.cs b/src/Microsoft.SqlTools.ServiceLayer/Migration/MigrationService.cs
deleted file mode 100644
index cf6d3ffb..00000000
--- a/src/Microsoft.SqlTools.ServiceLayer/Migration/MigrationService.cs
+++ /dev/null
@@ -1,1068 +0,0 @@
-//
-// Copyright (c) Microsoft. All rights reserved.
-// Licensed under the MIT license. See LICENSE file in the project root for full license information.
-//
-
-#nullable disable
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Threading.Tasks;
-using System.Globalization;
-using System.Reflection;
-using System.Data;
-using System.Diagnostics;
-using Newtonsoft.Json;
-using Microsoft.SqlServer.DataCollection.Common;
-using Microsoft.SqlServer.Management.Assessment.Checks;
-using Microsoft.SqlServer.Management.Assessment;
-using Microsoft.SqlServer.Migration.Assessment.Common.Contracts.Models;
-using Microsoft.SqlServer.Migration.Assessment.Common.Engine;
-using Microsoft.SqlTools.Hosting.Protocol;
-using Microsoft.SqlTools.ServiceLayer.Connection.Contracts;
-using Microsoft.SqlTools.ServiceLayer.Connection;
-using Microsoft.SqlTools.ServiceLayer.Hosting;
-using Microsoft.SqlTools.ServiceLayer.Migration.Contracts;
-using Microsoft.SqlTools.Utility;
-using Microsoft.SqlServer.Migration.Logins;
-using Microsoft.SqlServer.Migration.SkuRecommendation.Aggregation;
-using Microsoft.SqlServer.Migration.SkuRecommendation.Models.Sql;
-using Microsoft.SqlServer.Migration.SkuRecommendation;
-using Microsoft.SqlServer.Migration.SkuRecommendation.Contracts.Constants;
-using Microsoft.SqlServer.Migration.SkuRecommendation.Billing;
-using Microsoft.SqlServer.Migration.SkuRecommendation.Contracts;
-using Microsoft.SqlServer.Migration.SkuRecommendation.Contracts.Models.Sku;
-using Microsoft.SqlServer.Migration.SkuRecommendation.Contracts.Models;
-using Microsoft.SqlServer.Migration.SkuRecommendation.Contracts.Exceptions;
-using Microsoft.SqlServer.Migration.SkuRecommendation.Contracts.Models.Environment;
-using Microsoft.SqlServer.Migration.SkuRecommendation.ElasticStrategy;
-using Microsoft.SqlServer.Migration.SkuRecommendation.ElasticStrategy.AzureSqlManagedInstance;
-using Microsoft.SqlServer.Migration.SkuRecommendation.ElasticStrategy.AzureSqlDatabase;
-using Microsoft.SqlServer.Migration.SkuRecommendation.Models;
-using Microsoft.SqlServer.Migration.SkuRecommendation.Utils;
-using Microsoft.SqlServer.DataCollection.Common.Contracts.OperationsInfrastructure;
-using System.Threading;
-using Microsoft.SqlServer.Migration.Logins.Contracts;
-using Microsoft.SqlServer.Migration.Assessment.Common.Models;
-using Microsoft.SqlServer.Migration.Assessment.Common.Utils;
-using Microsoft.SqlTools.ServiceLayer.Migration.Utils;
-using Microsoft.SqlServer.Migration.Tde;
-using Microsoft.SqlServer.Migration.Tde.Common;
-using Microsoft.SqlTools.ServiceLayer.Migration.Models;
-
-namespace Microsoft.SqlTools.ServiceLayer.Migration
-{
- ///
- /// Main class for Migration Service functionality
- ///
- public sealed class MigrationService : IDisposable
- {
- private static ConnectionService connectionService = null;
-
- private static readonly Lazy instance = new Lazy(() => new MigrationService());
-
- private bool disposed;
-
- ///
- /// Construct a new MigrationService instance with default parameters
- ///
- public MigrationService()
- {
- }
-
- ///
- /// Gets the singleton instance object
- ///
- public static MigrationService Instance
- {
- get { return instance.Value; }
- }
-
- ///
- /// Internal for testing purposes only
- ///
- internal static ConnectionService ConnectionService
- {
- get
- {
- connectionService ??= ConnectionService.Instance;
- return connectionService;
- }
- set
- {
- connectionService = value;
- }
- }
-
- ///
- /// Gets the used to run assessment operations.
- ///
- internal Engine Engine { get; } = new Engine();
-
- ///
- /// Service host object for sending/receiving requests/events.
- /// Internal for testing purposes.
- ///
- internal IProtocolEndpoint ServiceHost
- {
- get;
- set;
- }
-
- ///
- /// Controller for collecting performance data for SKU recommendation
- ///
- internal SqlDataQueryController DataCollectionController
- {
- get;
- set;
- }
-
- ///
- /// Initializes the Migration Service instance
- ///
- public void InitializeService(ServiceHost serviceHost)
- {
- this.ServiceHost = serviceHost;
- this.ServiceHost.SetRequestHandler(MigrationAssessmentsRequest.Type, HandleMigrationAssessmentsRequest, true);
- this.ServiceHost.SetRequestHandler(StartPerfDataCollectionRequest.Type, HandleStartPerfDataCollectionRequest, true);
- this.ServiceHost.SetRequestHandler(StopPerfDataCollectionRequest.Type, HandleStopPerfDataCollectionRequest, true);
- this.ServiceHost.SetRequestHandler(RefreshPerfDataCollectionRequest.Type, HandleRefreshPerfDataCollectionRequest, true);
- this.ServiceHost.SetRequestHandler(GetSkuRecommendationsRequest.Type, HandleGetSkuRecommendationsRequest, true);
- this.ServiceHost.SetRequestHandler(StartLoginMigrationRequest.Type, HandleStartLoginMigration, true);
- this.ServiceHost.SetRequestHandler(ValidateLoginMigrationRequest.Type, HandleValidateLoginMigration, true);
- this.ServiceHost.SetRequestHandler(MigrateLoginsRequest.Type, HandleMigrateLogins, true);
- this.ServiceHost.SetRequestHandler(EstablishUserMappingRequest.Type, HandleEstablishUserMapping, true);
- this.ServiceHost.SetRequestHandler(MigrateServerRolesAndSetPermissionsRequest.Type, HandleMigrateServerRolesAndSetPermissions, true);
- this.ServiceHost.SetRequestHandler(CertificateMigrationRequest.Type, HandleTdeCertificateMigrationRequest);
- }
-
- ///
- /// Handle request to start a migration session
- ///
- internal async Task HandleMigrationAssessmentsRequest(
- MigrationAssessmentsParams parameters,
- RequestContext requestContext)
- {
- string randomUri = Guid.NewGuid().ToString();
- try
- {
- // get connection
- if (!ConnectionService.TryFindConnection(parameters.OwnerUri, out var connInfo))
- {
- await requestContext.SendError("Could not find migration connection");
- return;
- }
-
- ConnectParams connectParams = new ConnectParams
- {
- OwnerUri = randomUri,
- Connection = connInfo.ConnectionDetails,
- Type = ConnectionType.Default
- };
-
- await ConnectionService.Connect(connectParams);
-
- var connection = await ConnectionService.Instance.GetOrOpenConnection(randomUri, ConnectionType.Default);
- var connectionStrings = new List();
- if (parameters.Databases != null)
- {
- foreach (string database in parameters.Databases)
- {
- connInfo.ConnectionDetails.DatabaseName = database;
- connectionStrings.Add(ConnectionService.BuildConnectionString(connInfo.ConnectionDetails));
- }
- string[] assessmentConnectionStrings = connectionStrings.ToArray();
- var results = await GetAssessmentItems(assessmentConnectionStrings, parameters.XEventsFilesFolderPath);
- await requestContext.SendResult(results);
- }
- }
- finally
- {
- ConnectionService.Disconnect(new DisconnectParams { OwnerUri = randomUri, Type = null });
- }
- }
-
- ///
- /// Handle request to start performance data collection process
- ///
- internal async Task HandleStartPerfDataCollectionRequest(
- StartPerfDataCollectionParams parameters,
- RequestContext requestContext)
- {
- string randomUri = Guid.NewGuid().ToString();
- try
- {
- // get connection
- if (!ConnectionService.TryFindConnection(parameters.OwnerUri, out var connInfo))
- {
- await requestContext.SendError("Could not find migration connection");
- return;
- }
-
- ConnectParams connectParams = new ConnectParams
- {
- OwnerUri = randomUri,
- Connection = connInfo.ConnectionDetails,
- Type = ConnectionType.Default
- };
-
- await ConnectionService.Connect(connectParams);
- var connection = await ConnectionService.Instance.GetOrOpenConnection(randomUri, ConnectionType.Default);
- var connectionString = ConnectionService.BuildConnectionString(connInfo.ConnectionDetails);
-
- this.DataCollectionController = new SqlDataQueryController(
- connectionString,
- parameters.DataFolder,
- parameters.PerfQueryIntervalInSec,
- parameters.NumberOfIterations,
- parameters.StaticQueryIntervalInSec,
- null);
-
- this.DataCollectionController.Start();
-
- // TO-DO: what should be returned?
- await requestContext.SendResult(new StartPerfDataCollectionResult() { DateTimeStarted = DateTime.UtcNow });
- }
- finally
- {
- ConnectionService.Disconnect(new DisconnectParams { OwnerUri = randomUri, Type = null });
- }
- }
-
- ///
- /// Handle request to stop performance data collection process
- ///
- internal async Task HandleStopPerfDataCollectionRequest(
- StopPerfDataCollectionParams parameters,
- RequestContext requestContext)
- {
- this.DataCollectionController.Dispose();
-
- // TO-DO: what should be returned?
- await requestContext.SendResult(new StopPerfDataCollectionResult() { DateTimeStopped = DateTime.UtcNow });
- }
-
- ///
- /// Handle request to refresh performance data collection status
- ///
- internal async Task HandleRefreshPerfDataCollectionRequest(
- RefreshPerfDataCollectionParams parameters,
- RequestContext requestContext)
- {
- bool isCollecting = !(this.DataCollectionController is null) ? this.DataCollectionController.IsRunning() : false;
- List messages = !(this.DataCollectionController is null) ? this.DataCollectionController.FetchLatestMessages(parameters.LastRefreshedTime) : new List();
- List errors = !(this.DataCollectionController is null) ? this.DataCollectionController.FetchLatestErrors(parameters.LastRefreshedTime) : new List();
-
- RefreshPerfDataCollectionResult result = new RefreshPerfDataCollectionResult()
- {
- RefreshTime = DateTime.UtcNow,
- IsCollecting = isCollecting,
- Messages = messages,
- Errors = errors,
- };
-
- await requestContext.SendResult(result);
- }
- ///
- /// Handle request to generate SKU recommendations
- ///
- internal async Task HandleGetSkuRecommendationsRequest(
- GetSkuRecommendationsParams parameters,
- RequestContext requestContext)
- {
- try
- {
- SqlAssessmentConfiguration.EnableLocalLogging = true;
- SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath = Path.GetDirectoryName(Logger.LogFileFullPath);
-
- CsvRequirementsAggregator aggregator = new CsvRequirementsAggregator(parameters.DataFolder);
- SqlInstanceRequirements req = aggregator.ComputeSqlInstanceRequirements(
- agentId: null,
- instanceId: parameters.TargetSqlInstance,
- targetPercentile: parameters.TargetPercentile,
- startTime: DateTime.ParseExact(parameters.StartTime, RecommendationConstants.TimestampDateTimeFormat, CultureInfo.InvariantCulture),
- endTime: DateTime.ParseExact(parameters.EndTime, RecommendationConstants.TimestampDateTimeFormat, CultureInfo.InvariantCulture),
- collectionInterval: parameters.PerfQueryIntervalInSec,
- dbsToInclude: new HashSet(parameters.DatabaseAllowList),
- hostRequirements: new SqlServerHostRequirements() { NICCount = 1 });
-
- RecommendationResultSet baselineResults;
- 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
- {
- SqlDbRecommendationResults = baselineResults.sqlDbResults,
- SqlDbRecommendationDurationInMs = baselineResults.sqlDbDurationInMs,
- SqlMiRecommendationResults = baselineResults.sqlMiResults,
- SqlMiRecommendationDurationInMs = baselineResults.sqlMiDurationInMs,
- SqlVmRecommendationResults = baselineResults.sqlVmResults,
- SqlVmRecommendationDurationInMs = baselineResults.sqlVmDurationInMs,
- ElasticSqlDbRecommendationResults = elasticResults.sqlDbResults,
- ElasticSqlDbRecommendationDurationInMs = elasticResults.sqlDbDurationInMs,
- ElasticSqlMiRecommendationResults = elasticResults.sqlMiResults,
- ElasticSqlMiRecommendationDurationInMs = elasticResults.sqlMiDurationInMs,
- ElasticSqlVmRecommendationResults = elasticResults.sqlVmResults,
- ElasticSqlVmRecommendationDurationInMs = elasticResults.sqlVmDurationInMs,
- InstanceRequirements = req,
- SkuRecommendationReportPaths = new List { baselineResults.sqlDbReportPath, baselineResults.sqlMiReportPath, baselineResults.sqlVmReportPath },
- ElasticSkuRecommendationReportPaths = new List { elasticResults.sqlDbReportPath, elasticResults.sqlMiReportPath, elasticResults.sqlVmReportPath },
- };
-
- await requestContext.SendResult(results);
- }
- catch (FailedToQueryCountersException e)
- {
- await requestContext.SendError($"Unable to read collected performance data from {parameters.DataFolder}. Please specify another folder or start data collection instead.");
- }
- catch (Exception e)
- {
- await requestContext.SendError(e.ToString());
- }
- }
-
- internal async Task HandleStartLoginMigration(
- StartLoginMigrationParams parameters,
- RequestContext requestContext)
- {
- try
- {
- ILoginsMigration loginMigration = new LoginsMigration(parameters.SourceConnectionString, parameters.TargetConnectionString,
- null, parameters.LoginList, parameters.AADDomainName);
-
- IDictionary> exceptionMap = new Dictionary>();
-
- exceptionMap.AddExceptions(await loginMigration.StartValidations(CancellationToken.None));
- exceptionMap.AddExceptions(await loginMigration.MigrateLogins(CancellationToken.None));
- exceptionMap.AddExceptions(loginMigration.MigrateServerRoles(CancellationToken.None));
- exceptionMap.AddExceptions(loginMigration.EstablishUserMapping(CancellationToken.None));
- exceptionMap.AddExceptions(await loginMigration.EstablishServerRoleMapping(CancellationToken.None));
- exceptionMap.AddExceptions(loginMigration.SetLoginPermissions(CancellationToken.None));
- exceptionMap.AddExceptions(loginMigration.SetServerRolePermissions(CancellationToken.None));
-
- LoginMigrationResult results = new LoginMigrationResult()
- {
- ExceptionMap = exceptionMap
- };
-
- await requestContext.SendResult(results);
- }
- catch (Exception e)
- {
- await requestContext.SendError(e.ToString());
- }
- }
-
- internal async Task HandleValidateLoginMigration(
- StartLoginMigrationParams parameters,
- RequestContext requestContext)
- {
- try
- {
- ILoginsMigration loginMigration = new LoginsMigration(parameters.SourceConnectionString, parameters.TargetConnectionString,
- null, parameters.LoginList, parameters.AADDomainName);
-
- IDictionary> exceptionMap = new Dictionary>();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- exceptionMap.AddExceptions(await loginMigration.StartValidations(CancellationToken.None));
- stopWatch.Stop();
- TimeSpan elapsedTime = stopWatch.Elapsed;
-
- LoginMigrationResult results = new LoginMigrationResult()
- {
- ExceptionMap = exceptionMap,
- CompletedStep = LoginMigrationStep.StartValidations,
- ElapsedTime = MigrationServiceHelper.FormatTimeSpan(elapsedTime)
-
- };
-
- await requestContext.SendResult(results);
- }
- catch (Exception e)
- {
- await requestContext.SendError(e.ToString());
- }
- }
-
- internal async Task HandleMigrateLogins(
- StartLoginMigrationParams parameters,
- RequestContext requestContext)
- {
- try
- {
- ILoginsMigration loginMigration = new LoginsMigration(parameters.SourceConnectionString, parameters.TargetConnectionString,
- null, parameters.LoginList, parameters.AADDomainName);
-
- IDictionary> exceptionMap = new Dictionary>();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- exceptionMap.AddExceptions(await loginMigration.StartValidations(CancellationToken.None));
- exceptionMap.AddExceptions(await loginMigration.MigrateLogins(CancellationToken.None));
- stopWatch.Stop();
- TimeSpan elapsedTime = stopWatch.Elapsed;
-
- LoginMigrationResult results = new LoginMigrationResult()
- {
- ExceptionMap = exceptionMap,
- CompletedStep = LoginMigrationStep.MigrateLogins,
- ElapsedTime = MigrationServiceHelper.FormatTimeSpan(elapsedTime)
- };
-
- await requestContext.SendResult(results);
- }
- catch (Exception e)
- {
- await requestContext.SendError(e.ToString());
- }
- }
-
- internal async Task HandleEstablishUserMapping(
- StartLoginMigrationParams parameters,
- RequestContext requestContext)
- {
- try
- {
- ILoginsMigration loginMigration = new LoginsMigration(parameters.SourceConnectionString, parameters.TargetConnectionString,
- null, parameters.LoginList, parameters.AADDomainName);
-
- IDictionary> exceptionMap = new Dictionary>();
-
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- exceptionMap.AddExceptions(await loginMigration.StartValidations(CancellationToken.None));
- exceptionMap.AddExceptions(loginMigration.EstablishUserMapping(CancellationToken.None));
- stopWatch.Stop();
- TimeSpan elapsedTime = stopWatch.Elapsed;
-
- LoginMigrationResult results = new LoginMigrationResult()
- {
- ExceptionMap = exceptionMap,
- CompletedStep = LoginMigrationStep.EstablishUserMapping,
- ElapsedTime = MigrationServiceHelper.FormatTimeSpan(elapsedTime)
- };
-
- await requestContext.SendResult(results);
- }
- catch (Exception e)
- {
- await requestContext.SendError(e.ToString());
- }
- }
-
- internal async Task HandleMigrateServerRolesAndSetPermissions(
- StartLoginMigrationParams parameters,
- RequestContext requestContext)
- {
- try
- {
- ILoginsMigration loginMigration = new LoginsMigration(parameters.SourceConnectionString, parameters.TargetConnectionString,
- null, parameters.LoginList, parameters.AADDomainName);
-
- IDictionary> exceptionMap = new Dictionary>();
- Stopwatch stopWatch = new Stopwatch();
- stopWatch.Start();
- exceptionMap.AddExceptions(await loginMigration.StartValidations(CancellationToken.None));
- stopWatch.Stop();
- TimeSpan elapsedTime = stopWatch.Elapsed;
-
- await this.ServiceHost.SendEvent(
- LoginMigrationNotification.Type,
- new LoginMigrationResult()
- {
- ExceptionMap = exceptionMap,
- CompletedStep = LoginMigrationStep.StartValidations,
- ElapsedTime = MigrationServiceHelper.FormatTimeSpan(elapsedTime)
- });
-
- stopWatch.Restart();
- exceptionMap.AddExceptions(loginMigration.MigrateServerRoles(CancellationToken.None));
- stopWatch.Stop();
- elapsedTime = stopWatch.Elapsed;
-
- await this.ServiceHost.SendEvent(
- LoginMigrationNotification.Type,
- new LoginMigrationResult()
- {
- ExceptionMap = exceptionMap,
- CompletedStep = LoginMigrationStep.MigrateServerRoles,
- ElapsedTime = MigrationServiceHelper.FormatTimeSpan(elapsedTime)
- });
-
- stopWatch.Restart();
- exceptionMap.AddExceptions(await loginMigration.EstablishServerRoleMapping(CancellationToken.None));
- stopWatch.Stop();
- elapsedTime = stopWatch.Elapsed;
-
- await this.ServiceHost.SendEvent(
- LoginMigrationNotification.Type,
- new LoginMigrationResult()
- {
- ExceptionMap = exceptionMap,
- CompletedStep = LoginMigrationStep.EstablishServerRoleMapping,
- ElapsedTime = MigrationServiceHelper.FormatTimeSpan(elapsedTime)
- });
-
- stopWatch.Restart();
- exceptionMap.AddExceptions(loginMigration.SetLoginPermissions(CancellationToken.None));
- stopWatch.Stop();
- elapsedTime = stopWatch.Elapsed;
-
- await this.ServiceHost.SendEvent(
- LoginMigrationNotification.Type,
- new LoginMigrationResult()
- {
- ExceptionMap = exceptionMap,
- CompletedStep = LoginMigrationStep.SetLoginPermissions,
- ElapsedTime = MigrationServiceHelper.FormatTimeSpan(elapsedTime)
- });
-
- stopWatch.Restart();
- exceptionMap.AddExceptions(loginMigration.SetServerRolePermissions(CancellationToken.None));
- stopWatch.Stop();
- elapsedTime = stopWatch.Elapsed;
-
- await this.ServiceHost.SendEvent(
- LoginMigrationNotification.Type,
- new LoginMigrationResult()
- {
- ExceptionMap = exceptionMap,
- CompletedStep = LoginMigrationStep.SetServerRolePermissions,
- ElapsedTime = MigrationServiceHelper.FormatTimeSpan(elapsedTime)
- });
-
- LoginMigrationResult results = new LoginMigrationResult()
- {
- ExceptionMap = exceptionMap,
- CompletedStep = LoginMigrationStep.SetServerRolePermissions,
- ElapsedTime = MigrationServiceHelper.FormatTimeSpan(elapsedTime)
- };
-
- await requestContext.SendResult(results);
- }
- catch (Exception e)
- {
- await requestContext.SendError(e.ToString());
- }
- }
-
- internal RecommendationResultSet GenerateBaselineRecommendations(SqlInstanceRequirements req, GetSkuRecommendationsParams parameters)
- {
- RecommendationResultSet resultSet = new RecommendationResultSet();
-
- SkuRecommendationServiceProvider provider = new SkuRecommendationServiceProvider(new AzureSqlSkuBillingServiceProvider());
- AzurePreferences prefs = new AzurePreferences()
- {
- EligibleSkuCategories = null, // eligible SKU list will be adjusted with each recommendation type
- ScalingFactor = parameters.ScalingFactor / 100.0,
- TargetEnvironment = TargetEnvironmentType.Production
- };
-
- // generate SQL DB recommendations, if applicable
- if (parameters.TargetPlatforms.Contains("AzureSqlDatabase"))
- {
- Stopwatch sqlDbStopwatch = new Stopwatch();
- sqlDbStopwatch.Start();
-
- prefs.EligibleSkuCategories = GetEligibleSkuCategories("AzureSqlDatabase", parameters.IncludePreviewSkus);
- resultSet.sqlDbResults = provider.GetSkuRecommendation(prefs, req);
-
- sqlDbStopwatch.Stop();
- resultSet.sqlDbDurationInMs = sqlDbStopwatch.ElapsedMilliseconds;
-
- SkuRecommendationReport sqlDbReport = new SkuRecommendationReport(
- new Dictionary> { { req, resultSet.sqlDbResults } },
- AzureSqlTargetPlatform.AzureSqlDatabase.ToString());
- var sqlDbRecommendationReportFileName = String.Format("SkuRecommendationReport-AzureSqlDatabase-Baseline-{0}", DateTime.UtcNow.ToString("yyyyMMddHH-mmss", CultureInfo.InvariantCulture));
- var sqlDbRecommendationReportFullPath = Path.Combine(SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath, sqlDbRecommendationReportFileName);
- ExportRecommendationResultsAction.ExportRecommendationResults(sqlDbReport, SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath, false, sqlDbRecommendationReportFileName);
- resultSet.sqlDbReportPath = sqlDbRecommendationReportFullPath + ".html";
- }
-
- // generate SQL MI recommendations, if applicable
- if (parameters.TargetPlatforms.Contains("AzureSqlManagedInstance"))
- {
- Stopwatch sqlMiStopwatch = new Stopwatch();
- sqlMiStopwatch.Start();
-
- prefs.EligibleSkuCategories = GetEligibleSkuCategories("AzureSqlManagedInstance", parameters.IncludePreviewSkus);
- resultSet.sqlMiResults = provider.GetSkuRecommendation(prefs, req);
-
- sqlMiStopwatch.Stop();
- resultSet.sqlMiDurationInMs = sqlMiStopwatch.ElapsedMilliseconds;
-
- SkuRecommendationReport sqlMiReport = new SkuRecommendationReport(
- new Dictionary> { { req, resultSet.sqlMiResults } },
- AzureSqlTargetPlatform.AzureSqlManagedInstance.ToString());
- var sqlMiRecommendationReportFileName = String.Format("SkuRecommendationReport-AzureSqlManagedInstance-Baseline-{0}", DateTime.UtcNow.ToString("yyyyMMddHH-mmss", CultureInfo.InvariantCulture));
- var sqlMiRecommendationReportFullPath = Path.Combine(SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath, sqlMiRecommendationReportFileName);
- ExportRecommendationResultsAction.ExportRecommendationResults(sqlMiReport, SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath, false, sqlMiRecommendationReportFileName);
- resultSet.sqlMiReportPath = sqlMiRecommendationReportFullPath + ".html";
- }
-
- // generate SQL VM recommendations, if applicable
- if (parameters.TargetPlatforms.Contains("AzureSqlVirtualMachine"))
- {
- Stopwatch sqlVmStopwatch = new Stopwatch();
- sqlVmStopwatch.Start();
-
- prefs.EligibleSkuCategories = GetEligibleSkuCategories("AzureSqlVirtualMachine", parameters.IncludePreviewSkus);
- resultSet.sqlVmResults = provider.GetSkuRecommendation(prefs, req);
-
- sqlVmStopwatch.Stop();
- resultSet.sqlVmDurationInMs = sqlVmStopwatch.ElapsedMilliseconds;
-
- SkuRecommendationReport sqlVmReport = new SkuRecommendationReport(
- new Dictionary> { { req, resultSet.sqlVmResults } },
- AzureSqlTargetPlatform.AzureSqlVirtualMachine.ToString());
- var sqlVmRecommendationReportFileName = String.Format("SkuRecommendationReport-AzureSqlVirtualMachine-Baseline-{0}", DateTime.UtcNow.ToString("yyyyMMddHH-mmss", CultureInfo.InvariantCulture));
- var sqlVmRecommendationReportFullPath = Path.Combine(SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath, sqlVmRecommendationReportFileName);
- ExportRecommendationResultsAction.ExportRecommendationResults(sqlVmReport, SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath, false, sqlVmRecommendationReportFileName);
- resultSet.sqlVmReportPath = sqlVmRecommendationReportFullPath + ".html";
- }
-
- return resultSet;
- }
-
- internal RecommendationResultSet GenerateElasticRecommendations(SqlInstanceRequirements req, GetSkuRecommendationsParams parameters)
- {
- RecommendationResultSet resultSet = new RecommendationResultSet();
-
- CsvAggregatorForElasticStrategy elasticaggregator = new CsvAggregatorForElasticStrategy(
- instanceId: parameters.TargetSqlInstance,
- directory: parameters.DataFolder,
- queryInterval: parameters.PerfQueryIntervalInSec,
- logger: null,
- dbsToInclude: new HashSet(parameters.DatabaseAllowList));
-
- // generate SQL DB recommendations, if applicable
- if (parameters.TargetPlatforms.Contains("AzureSqlDatabase"))
- {
- Stopwatch sqlDbStopwatch = new Stopwatch();
- sqlDbStopwatch.Start();
-
- List eligibleSkuCategories = GetEligibleSkuCategories("AzureSqlDatabase", parameters.IncludePreviewSkus);
- ElasticStrategySKURecommendationPipeline pi = new ElasticStrategySKURecommendationPipeline(eligibleSkuCategories);
- DataTable SqlMISpec = pi.SqlMISpec.Copy();
- MISkuRecParams MiSkuRecParams = new MISkuRecParams(pi.SqlGPMIFileSpec, SqlMISpec, elasticaggregator.FileLevelTs, elasticaggregator.InstanceTs, pi.MILookupTable, Convert.ToDouble(parameters.ScalingFactor) / 100.0, parameters.TargetSqlInstance);
- DbSkuRecParams DbSkuRecParams = new DbSkuRecParams(pi.SqlDbSpec, elasticaggregator.DatabaseTs, pi.DbLookupTable, Convert.ToDouble(parameters.ScalingFactor) / 100.0, parameters.TargetSqlInstance);
- resultSet.sqlDbResults = pi.ElasticStrategyGetSkuRecommendation(MiSkuRecParams, DbSkuRecParams, req);
-
- sqlDbStopwatch.Stop();
- resultSet.sqlDbDurationInMs = sqlDbStopwatch.ElapsedMilliseconds;
-
- SkuRecommendationReport sqlDbReport = new SkuRecommendationReport(
- new Dictionary> { { req, resultSet.sqlDbResults } },
- AzureSqlTargetPlatform.AzureSqlDatabase.ToString());
- var sqlDbRecommendationReportFileName = String.Format("SkuRecommendationReport-AzureSqlDatabase-Elastic-{0}", DateTime.UtcNow.ToString("yyyyMMddHH-mmss", CultureInfo.InvariantCulture));
- var sqlDbRecommendationReportFullPath = Path.Combine(SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath, sqlDbRecommendationReportFileName);
- ExportRecommendationResultsAction.ExportRecommendationResults(sqlDbReport, SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath, false, sqlDbRecommendationReportFileName);
- resultSet.sqlDbReportPath = sqlDbRecommendationReportFullPath + ".html";
- }
-
- // generate SQL MI recommendations, if applicable
- if (parameters.TargetPlatforms.Contains("AzureSqlManagedInstance"))
- {
- Stopwatch sqlMiStopwatch = new Stopwatch();
- sqlMiStopwatch.Start();
-
- List eligibleSkuCategories = GetEligibleSkuCategories("AzureSqlManagedInstance", parameters.IncludePreviewSkus);
- ElasticStrategySKURecommendationPipeline pi = new ElasticStrategySKURecommendationPipeline(eligibleSkuCategories);
- DataTable SqlMISpec = pi.SqlMISpec.Copy();
- MISkuRecParams MiSkuRecParams = new MISkuRecParams(pi.SqlGPMIFileSpec, SqlMISpec, elasticaggregator.FileLevelTs, elasticaggregator.InstanceTs, pi.MILookupTable, Convert.ToDouble(parameters.ScalingFactor) / 100.0, parameters.TargetSqlInstance);
- DbSkuRecParams DbSkuRecParams = new DbSkuRecParams(pi.SqlDbSpec, elasticaggregator.DatabaseTs, pi.DbLookupTable, Convert.ToDouble(parameters.ScalingFactor) / 100.0, parameters.TargetSqlInstance);
- resultSet.sqlMiResults = pi.ElasticStrategyGetSkuRecommendation(MiSkuRecParams, DbSkuRecParams, req);
-
- sqlMiStopwatch.Stop();
- resultSet.sqlMiDurationInMs = sqlMiStopwatch.ElapsedMilliseconds;
-
- SkuRecommendationReport sqlMiReport = new SkuRecommendationReport(
- new Dictionary> { { req, resultSet.sqlMiResults } },
- AzureSqlTargetPlatform.AzureSqlManagedInstance.ToString());
- var sqlMiRecommendationReportFileName = String.Format("SkuRecommendationReport-AzureSqlManagedInstance-Elastic-{0}", DateTime.UtcNow.ToString("yyyyMMddHH-mmss", CultureInfo.InvariantCulture));
- var sqlMiRecommendationReportFullPath = Path.Combine(SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath, sqlMiRecommendationReportFileName);
- ExportRecommendationResultsAction.ExportRecommendationResults(sqlMiReport, SqlAssessmentConfiguration.ReportsAndLogsRootFolderPath, false, sqlMiRecommendationReportFileName);
- resultSet.sqlMiReportPath = sqlMiRecommendationReportFullPath + ".html";
- }
-
- // generate SQL VM recommendations, if applicable
- if (parameters.TargetPlatforms.Contains("AzureSqlVirtualMachine"))
- {
- // elastic model currently doesn't support VM recommendation, return empty list
- resultSet.sqlVmResults = new List { };
- resultSet.sqlVmDurationInMs = -1;
- resultSet.sqlVmReportPath = String.Empty;
- }
-
- return resultSet;
- }
-
- internal class AssessmentRequest : IAssessmentRequest
- {
- private readonly Check[] checks = null;
-
- public AssessmentRequest(ISqlObjectLocator locator)
- {
- Target = locator ?? throw new ArgumentNullException(nameof(locator));
- }
-
- public EvaluationContext