diff --git a/extensions/sql-migration/src/constants/strings.ts b/extensions/sql-migration/src/constants/strings.ts index b2e87c648628..42c8e778800b 100644 --- a/extensions/sql-migration/src/constants/strings.ts +++ b/extensions/sql-migration/src/constants/strings.ts @@ -126,6 +126,10 @@ export const PERF_DATA_COLLECTION_ERROR = (serverName: string, errors: string[]) }; export const SKU_RECOMMENDATION_ASSESSMENT_ERROR_BYPASS = localize('sql.migration.wizard.sku.assessment.error.bypass', 'Check this option to skip assessment and continue the migration.'); export const SKU_RECOMMENDATION_ASSESSMENT_ERROR_DETAIL = localize('sql.migration.wizard.sku.assessment.error.detail', '[There are no assessment results to validate readiness of your database migration. By checking this box, you acknowledge you want to proceed migrating your database to the desired Azure SQL target.]',); +export const AZURE_SQL_MI_DB_COUNT_THRESHOLD_EXCEEDS_ERROR = (selectedDbCount: number): string => { + return localize('sql.migration.select.azure.mi.db.count.threshold.exceeds.error', 'Error: Azure SQL Managed Instance supports maximum {0} user databases per instance. Select {0} or less database(s) to proceed further.', selectedDbCount); +}; +export const AZURE_SQL_MI_DB_COUNT_UNDER_THRESHOLD = localize('sql.migration.select.azure.mi.db.count.under.threshold', 'To proceed, press Select button'); export const REFRESH_ASSESSMENT_BUTTON_LABEL = localize('sql.migration.refresh.assessment.button.label', "Refresh assessment"); export const SKU_RECOMMENDATION_CHOOSE_A_TARGET = localize('sql.migration.wizard.sku.choose_a_target', "Choose your Azure SQL target"); export const SKU_RECOMMENDATION_CHOOSE_A_TARGET_HELP = localize('sql.migration.wizard.sku.choose_a_target.help', "Not sure which Azure SQL target is right for you? Learn more"); diff --git a/extensions/sql-migration/src/dialog/assessment/sqlDatabasesTree.ts b/extensions/sql-migration/src/dialog/assessment/sqlDatabasesTree.ts index e725fece1c1a..6ae22cdef782 100644 --- a/extensions/sql-migration/src/dialog/assessment/sqlDatabasesTree.ts +++ b/extensions/sql-migration/src/dialog/assessment/sqlDatabasesTree.ts @@ -14,6 +14,8 @@ import { selectDatabasesFromList } from '../../constants/helper'; import { getSourceConnectionProfile } from '../../api/sqlUtils'; import { SqlMigrationAssessmentResultItem, SqlMigrationImpactedObjectInfo } from '../../service/contracts'; +const AZURE_SQL_MI_DB_COUNT_THRESHOLD = 100; + const styleLeft: azdata.CssStyles = { 'border': 'none', 'text-align': 'left', @@ -888,6 +890,14 @@ export class SqlDatabaseTree { ]); }); } else { + if (this._targetType === MigrationTargetType.SQLMI && selectedDbs?.length > AZURE_SQL_MI_DB_COUNT_THRESHOLD) { + this._dialog.okButton.enabled = false; + this._dialog.message = { + level: azdata.window.MessageLevel.Error, + text: constants.AZURE_SQL_MI_DB_COUNT_THRESHOLD_EXCEEDS_ERROR(AZURE_SQL_MI_DB_COUNT_THRESHOLD), + }; + } + instanceTableValues = [[ { value: this.createIconTextCell(IconPathHelper.sqlServerLogo, this._serverName), @@ -933,8 +943,24 @@ export class SqlDatabaseTree { } private async updateValuesOnSelection() { + const selectedDbsCount = this.selectedDbs()?.length; + if (this._targetType === MigrationTargetType.SQLMI && selectedDbsCount > AZURE_SQL_MI_DB_COUNT_THRESHOLD) { + this._dialog.okButton.enabled = false; + this._dialog.message = { + level: azdata.window.MessageLevel.Error, + text: constants.AZURE_SQL_MI_DB_COUNT_THRESHOLD_EXCEEDS_ERROR(AZURE_SQL_MI_DB_COUNT_THRESHOLD) + }; + } + else if (!this._dialog.okButton.enabled) { + this._dialog.okButton.enabled = true; + this._dialog.message = { + level: azdata.window.MessageLevel.Information, + text: constants.AZURE_SQL_MI_DB_COUNT_UNDER_THRESHOLD + }; + } + await this._databaseCount.updateProperties({ - 'value': constants.DATABASES(this.selectedDbs()?.length, this._model._databasesForAssessment?.length) + 'value': constants.DATABASES(selectedDbsCount, this._model._databasesForAssessment?.length) }); }