mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-02 09:35:40 -05:00
Fix connecting to MI login bug (#21821)
This PR fixes a regression for migration login for MI instances that was introduced in https://github.com/microsoft/azuredatastudio/pull/21776/files#diff-93c1a62583fa32d99f775b71ad27922cf31f660d10717ecc6966784306de1b6f. After that change, support for MI would fail as MI server types were going into the Sql VM path in sqlutils because the underlying logic for isSqlServerVM() was returning wrong results. The new approach uses the targetType set in StateMachine to extract the correct serverName for connection string based on the targetType. Testing: - Tested SQL VM login migration end to end - Tested SQL MI login migration end to end This change also bumps the sql-migration version to 1.3.0
This commit is contained in:
@@ -17,6 +17,7 @@ import { SKURecommendationPage } from '../wizard/skuRecommendationPage';
|
||||
import { excludeDatabases, getConnectionProfile, LoginTableInfo, SourceDatabaseInfo, TargetDatabaseInfo } from '../api/sqlUtils';
|
||||
import { LoginMigrationModel, LoginMigrationStep } from './loginMigrationModel';
|
||||
import { TdeMigrationDbResult, TdeMigrationModel } from './tdeModels';
|
||||
import { NetworkInterfaceModel } from '../api/dataModels/azure/networkInterfaceModel';
|
||||
const localize = nls.loadMessageBundle();
|
||||
|
||||
export enum ValidateIrState {
|
||||
@@ -528,6 +529,30 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
return this._skuRecommendationResults;
|
||||
}
|
||||
|
||||
public setTargetServerName(): void {
|
||||
switch (this._targetType) {
|
||||
case MigrationTargetType.SQLMI:
|
||||
const sqlMi = this._targetServerInstance as SqlManagedInstance;
|
||||
this._targetServerName = sqlMi.properties.fullyQualifiedDomainName;
|
||||
case MigrationTargetType.SQLDB:
|
||||
const sqlDb = this._targetServerInstance as AzureSqlDatabaseServer;
|
||||
this._targetServerName = sqlDb.properties.fullyQualifiedDomainName;
|
||||
case MigrationTargetType.SQLVM:
|
||||
// For sqlvm, we need to use ip address from the network interface to connect to the server
|
||||
const sqlVm = this._targetServerInstance as SqlVMServer;
|
||||
const networkInterfaces = Array.from(sqlVm.networkInterfaces.values());
|
||||
this._targetServerName = NetworkInterfaceModel.getIpAddress(networkInterfaces);
|
||||
}
|
||||
}
|
||||
|
||||
public get targetServerName(): string {
|
||||
// If the target server name is not already set, return it
|
||||
if (!this._targetServerName) {
|
||||
this.setTargetServerName();
|
||||
}
|
||||
|
||||
return this._targetServerName;
|
||||
}
|
||||
|
||||
public async getSourceConnectionString(): Promise<string> {
|
||||
return await azdata.connection.getConnectionString(this._sourceConnectionId, true);
|
||||
@@ -535,7 +560,7 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
||||
|
||||
public async getTargetConnectionString(): Promise<string> {
|
||||
const connectionProfile = getConnectionProfile(
|
||||
this._targetServerInstance,
|
||||
this.targetServerName,
|
||||
this._targetServerInstance.id,
|
||||
this._targetUserName,
|
||||
this._targetPassword,
|
||||
|
||||
Reference in New Issue
Block a user