mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-20 17:22:51 -05:00
Adding windows auth support to sql-migration and misc bug fixes. (#14816)
* - Added coming soon message for learn more. - Potential fix for learn more message * Renaming of controller to sqlMigrationService * Surfacing some errors -Azure account is stale error -Migration Service creation error. * Adding refresh azure token validation. * Fixing some errors pointed during PR -Fixing property names -Fixing count * Fixing migration status - Adding special error handling for resource not found error - Deleting unfound migrations from local cache - Using prefetched migration status for view all Misc fixes: - Using SQL server version name instead of number - Fixing Icons on sku recommendation page - Fixing table column width in cutover dialog - Adding spinner button to refresh. * Fixing all strings in migration service page and dialog * fixed a string error in create service dialog * Adding source config page to migration to support windows auth Some refactorings for sqlDatabaseTree (still WIP) * refactoring assessments code 1 introducing new interface for server assessments * Filtering out non windows sql vms Retaining selections made by user on assessments dialog * Fix compile errors on sqlDatabaseTree * Exposing migration status errors in cutover dialog * Updating extension verion * Correcting typos Fixing compilation erros Removing en-us from url Fixing function names Make UI calls unblocking * Unblocking dialog in case of failed assessments Localizing string removing blocking code from UI Fixing comments * Fixed broken assessment page logic
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as azdata from 'azdata';
|
||||
import { SKURecommendation } from './product';
|
||||
import { MigrationTargetType } from './stateMachine';
|
||||
|
||||
export interface Base {
|
||||
uuid: string;
|
||||
@@ -21,6 +21,15 @@ export interface GatherInformationRequest extends BaseRequest {
|
||||
connection: azdata.connection.Connection;
|
||||
}
|
||||
|
||||
export interface Checks {
|
||||
|
||||
}
|
||||
|
||||
export interface SKURecommendation {
|
||||
product: MigrationTargetType;
|
||||
checks: Checks;
|
||||
}
|
||||
|
||||
export interface SKURecommendations {
|
||||
recommendations: SKURecommendation[];
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import { IconPath } from 'azdata';
|
||||
import * as nls from 'vscode-nls';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export type MigrationProductType = 'AzureSQLMI' | 'AzureSQLVM';
|
||||
export interface MigrationProduct {
|
||||
readonly type: MigrationProductType;
|
||||
}
|
||||
|
||||
export interface Check {
|
||||
|
||||
}
|
||||
|
||||
export interface Checks {
|
||||
// fill some information
|
||||
checks: Check;
|
||||
// If there is not going to be any more information, use Check[] directly
|
||||
}
|
||||
|
||||
export interface Product extends MigrationProduct {
|
||||
readonly name: string;
|
||||
readonly learnMoreLink?: string;
|
||||
readonly icon?: IconPath;
|
||||
}
|
||||
|
||||
export class Product implements Product {
|
||||
constructor(public readonly type: MigrationProductType, public readonly name: string, public readonly icon?: IconPath, public readonly learnMoreLink?: string) {
|
||||
|
||||
}
|
||||
|
||||
static FromMigrationProduct(migrationProduct: MigrationProduct) {
|
||||
// TODO: populatie from some lookup table;
|
||||
|
||||
const product: Product | undefined = ProductLookupTable[migrationProduct.type];
|
||||
return new Product(migrationProduct.type, product?.name ?? '', product.icon ?? '');
|
||||
}
|
||||
}
|
||||
|
||||
export interface SKURecommendation {
|
||||
product: MigrationProduct;
|
||||
checks: Checks;
|
||||
}
|
||||
|
||||
|
||||
export const ProductLookupTable: { [key in MigrationProductType]: Product } = {
|
||||
'AzureSQLMI': {
|
||||
type: 'AzureSQLMI',
|
||||
name: localize('sql.migration.products.azuresqlmi.name', 'Azure Managed Instance (Microsoft managed)'),
|
||||
icon: 'sqlMI.svg'
|
||||
},
|
||||
'AzureSQLVM': {
|
||||
type: 'AzureSQLVM',
|
||||
name: localize('sql.migration.products.azuresqlvm.name', 'Azure SQL Virtual Machine (Customer managed)'),
|
||||
icon: 'sqlVM.svg'
|
||||
}
|
||||
};
|
||||
@@ -33,6 +33,11 @@ export enum State {
|
||||
EXIT,
|
||||
}
|
||||
|
||||
export enum MigrationTargetType {
|
||||
SQLVM = 'sqlvm',
|
||||
SQLMI = 'sqlmi'
|
||||
}
|
||||
|
||||
export enum MigrationCutover {
|
||||
ONLINE,
|
||||
OFFLINE
|
||||
@@ -82,6 +87,11 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
public _azureAccount!: azdata.Account;
|
||||
public _accountTenants!: azurecore.Tenant[];
|
||||
|
||||
public _connecionProfile!: azdata.connection.ConnectionProfile;
|
||||
public _authenticationType!: string;
|
||||
public _sqlServerUsername!: string;
|
||||
public _sqlServerPassword!: string;
|
||||
|
||||
public _subscriptions!: azureResource.AzureResourceSubscription[];
|
||||
|
||||
public _targetSubscription!: azureResource.AzureResourceSubscription;
|
||||
@@ -103,9 +113,12 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
private _stateChangeEventEmitter = new vscode.EventEmitter<StateChangeEvent>();
|
||||
private _currentState: State;
|
||||
private _gatheringInformationError: string | undefined;
|
||||
private _skuRecommendations: SKURecommendations | undefined;
|
||||
private _assessmentResults: mssql.SqlMigrationAssessmentResultItem[] | undefined;
|
||||
|
||||
private _skuRecommendations: SKURecommendations | undefined;
|
||||
public _assessmentResults!: ServerAssessement;
|
||||
public _vmDbs: string[] = [];
|
||||
public _miDbs: string[] = [];
|
||||
public _targetType!: MigrationTargetType;
|
||||
public refreshDatabaseBackupPage!: boolean;
|
||||
|
||||
constructor(
|
||||
@@ -127,18 +140,52 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
|
||||
public set currentState(newState: State) {
|
||||
const oldState = this.currentState;
|
||||
|
||||
this._currentState = newState;
|
||||
|
||||
this._stateChangeEventEmitter.fire({ oldState, newState: this.currentState });
|
||||
}
|
||||
|
||||
public get assessmentResults(): mssql.SqlMigrationAssessmentResultItem[] | undefined {
|
||||
public async getServerAssessments(): Promise<ServerAssessement> {
|
||||
const excludeDbs: string[] = [
|
||||
'master',
|
||||
'tempdb',
|
||||
'msdb',
|
||||
'model'
|
||||
];
|
||||
|
||||
const ownerUri = await azdata.connection.getUriForConnection(this.sourceConnectionId);
|
||||
|
||||
const assessmentResults = await this.migrationService.getAssessments(
|
||||
ownerUri
|
||||
);
|
||||
|
||||
const serverDatabases = await (await azdata.connection.listDatabases(this.sourceConnectionId)).filter((name) => !excludeDbs.includes(name));
|
||||
const serverLevelAssessments: mssql.SqlMigrationAssessmentResultItem[] = [];
|
||||
const databaseLevelAssessments = serverDatabases.map(db => {
|
||||
return {
|
||||
name: db,
|
||||
issues: <mssql.SqlMigrationAssessmentResultItem[]>[]
|
||||
};
|
||||
});
|
||||
|
||||
assessmentResults?.items.forEach((item) => {
|
||||
const dbIndex = serverDatabases.indexOf(item.databaseName);
|
||||
if (dbIndex === -1) {
|
||||
serverLevelAssessments.push(item);
|
||||
} else {
|
||||
databaseLevelAssessments[dbIndex].issues.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
this._assessmentResults = {
|
||||
issues: serverLevelAssessments,
|
||||
databaseAssessments: databaseLevelAssessments
|
||||
};
|
||||
|
||||
return this._assessmentResults;
|
||||
}
|
||||
|
||||
public set assessmentResults(assessmentResults: mssql.SqlMigrationAssessmentResultItem[] | undefined) {
|
||||
this._assessmentResults = assessmentResults;
|
||||
public getDatabaseAssessments(databaseName: string): mssql.SqlMigrationAssessmentResultItem[] | undefined {
|
||||
return this._assessmentResults.databaseAssessments.find(databaseAsssessment => databaseAsssessment.name === databaseName)?.issues;
|
||||
}
|
||||
|
||||
public get gatheringInformationError(): string | undefined {
|
||||
@@ -212,6 +259,17 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
return this._accountTenants[index];
|
||||
}
|
||||
|
||||
public async getSourceConnectionProfile(): Promise<azdata.connection.ConnectionProfile> {
|
||||
const sqlConnections = await azdata.connection.getConnections();
|
||||
return sqlConnections.find((value) => {
|
||||
if (value.connectionId === this.sourceConnectionId) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
})!;
|
||||
}
|
||||
|
||||
public async getSubscriptionsDropdownValues(): Promise<azdata.CategoryValue[]> {
|
||||
let subscriptionsValues: azdata.CategoryValue[] = [];
|
||||
try {
|
||||
@@ -289,7 +347,9 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
let virtualMachineValues: azdata.CategoryValue[] = [];
|
||||
try {
|
||||
this._targetSqlVirtualMachines = await getAvailableSqlVMs(this._azureAccount, subscription);
|
||||
virtualMachineValues = this._targetSqlVirtualMachines.map((virtualMachine) => {
|
||||
virtualMachineValues = this._targetSqlVirtualMachines.filter((virtualMachine) => {
|
||||
return virtualMachine.properties.sqlImageOffer.toLowerCase().includes('-ws'); //filtering out all non windows sql vms.
|
||||
}).map((virtualMachine) => {
|
||||
return {
|
||||
name: virtualMachine.id,
|
||||
displayName: `${virtualMachine.name}`
|
||||
@@ -470,7 +530,6 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
const connectionPassword = await azdata.connection.getCredentials(this.sourceConnectionId);
|
||||
|
||||
const requestBody: StartDatabaseMigrationRequest = {
|
||||
location: this._sqlMigrationService?.properties.location!,
|
||||
@@ -492,8 +551,9 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
},
|
||||
sourceSqlConnection: {
|
||||
dataSource: currentConnection?.serverName!,
|
||||
username: currentConnection?.userName!,
|
||||
password: connectionPassword.password
|
||||
authentication: this._authenticationType,
|
||||
username: this._sqlServerUsername,
|
||||
password: this._sqlServerPassword
|
||||
},
|
||||
scope: this._targetServerInstance.id
|
||||
}
|
||||
@@ -531,3 +591,11 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export interface ServerAssessement {
|
||||
issues: mssql.SqlMigrationAssessmentResultItem[];
|
||||
databaseAssessments: {
|
||||
name: string;
|
||||
issues: mssql.SqlMigrationAssessmentResultItem[];
|
||||
}[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user