[SQL-Migration] Login Migration Improvements (#21694)

This PR adds various login migration improvements:

- Enabled windows login by prompting user for AAD domain name if a windows login is selected
image
- Adds new login details dialog which gives granular status on each step of the login migration for each login
image
- Checks if windows login migration is supported for selected target type, and only collections source windows logins accordingly
- Perf optimization by source and target login in background of step 1 in order to significantly speed up loading of page 2
This commit is contained in:
AkshayMata
2023-01-23 15:29:44 -08:00
committed by GitHub
parent 9d4d5374d7
commit 03f6a9b188
10 changed files with 820 additions and 93 deletions

View File

@@ -14,7 +14,7 @@ import { WIZARD_INPUT_COMPONENT_WIDTH } from './wizardController';
import * as utils from '../api/utils';
import { azureResource } from 'azurecore';
import { AzureSqlDatabaseServer, SqlVMServer } from '../api/azure';
import { collectTargetDatabaseInfo, TargetDatabaseInfo, isSysAdmin } from '../api/sqlUtils';
import { collectSourceLogins, collectTargetLogins, isSysAdmin, LoginTableInfo } from '../api/sqlUtils';
export class LoginMigrationTargetSelectionPage extends MigrationWizardPage {
private _view!: azdata.ModelView;
@@ -328,6 +328,14 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage {
await this.populateAzureAccountsDropdown();
await this.populateSubscriptionDropdown();
await this.populateLocationDropdown();
// Collect source login info here, as it will speed up loading the next page
const sourceLogins: LoginTableInfo[] = [];
sourceLogins.push(...await collectSourceLogins(
this.migrationStateModel.sourceConnectionId,
this.migrationStateModel.isWindowsAuthMigrationSupported));
this.migrationStateModel._loginMigrationModel.collectedSourceLogins = true;
this.migrationStateModel._loginMigrationModel.loginsOnSource = sourceLogins;
console.log(this.migrationStateModel._targetType);
}));
@@ -599,18 +607,22 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage {
const targetDatabaseServer = this.migrationStateModel._targetServerInstance as AzureSqlDatabaseServer;
const userName = this.migrationStateModel._targetUserName;
const password = this.migrationStateModel._targetPassword;
const targetDatabases: TargetDatabaseInfo[] = [];
const loginsOnTarget: string[] = [];
if (targetDatabaseServer && userName && password) {
try {
connectionButtonLoadingContainer.loading = true;
await utils.updateControlDisplay(this._connectionResultsInfoBox, false);
this.wizard.nextButton.enabled = false;
targetDatabases.push(
...await collectTargetDatabaseInfo(
loginsOnTarget.push(
...await collectTargetLogins(
targetDatabaseServer,
userName,
password));
await this._showConnectionResults(targetDatabases);
password,
this.migrationStateModel.isWindowsAuthMigrationSupported));
this.migrationStateModel._loginMigrationModel.collectedTargetLogins = true;
this.migrationStateModel._loginMigrationModel.loginsOnTarget = loginsOnTarget;
await this._showConnectionResults(loginsOnTarget);
} catch (error) {
this.wizard.message = {
level: azdata.window.MessageLevel.Error,
@@ -618,7 +630,7 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage {
description: constants.SQL_TARGET_CONNECTION_ERROR(error.message),
};
await this._showConnectionResults(
targetDatabases,
loginsOnTarget,
constants.AZURE_SQL_TARGET_CONNECTION_ERROR_TITLE);
}
finally {
@@ -653,19 +665,16 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage {
}
private async _showConnectionResults(
databases: TargetDatabaseInfo[],
logins: string[],
errorMessage?: string): Promise<void> {
const hasError = errorMessage !== undefined;
const hasDatabases = databases.length > 0;
this._connectionResultsInfoBox.style = hasError
? 'error'
: hasDatabases
? 'success'
: 'warning';
: 'success';
this._connectionResultsInfoBox.text = hasError
? constants.SQL_TARGET_CONNECTION_ERROR(errorMessage)
: constants.SQL_TARGET_CONNECTION_SUCCESS_LOGINS(databases.length.toLocaleString());
: constants.SQL_TARGET_CONNECTION_SUCCESS_LOGINS(logins.length.toLocaleString());
await utils.updateControlDisplay(this._connectionResultsInfoBox, true);
if (!hasError) {