SQL-Migration: enable cross subscription service migration (#22876)

* x subscription migration support

* refresh after cutover

* fix service irregular status load behavior

* queue service status requests, fix typo

* add migationTargetServerName helper method

* save context before api call
This commit is contained in:
brian-harris
2023-04-27 16:28:32 -07:00
committed by GitHub
parent 65f8915b7e
commit fe32180c71
15 changed files with 347 additions and 240 deletions

View File

@@ -228,7 +228,7 @@ export class DatabaseBackupPage extends MigrationWizardPage {
description: constants.DATABASE_BACKUP_NETWORK_SHARE_WINDOWS_USER_INFO,
width: WIZARD_INPUT_COMPONENT_WIDTH,
requiredIndicator: true,
CSSStyles: { ...styles.LABEL_CSS }
CSSStyles: { ...styles.LABEL_CSS },
}).component();
this._windowsUserAccountText = this._view.modelBuilder.inputBox()
.withProps({
@@ -627,7 +627,13 @@ export class DatabaseBackupPage extends MigrationWizardPage {
// check for storage account connectivity
if ((this.migrationStateModel.isSqlMiTarget || this.migrationStateModel.isSqlVmTarget)) {
if (!(await canTargetConnectToStorageAccount(this.migrationStateModel._targetType, this.migrationStateModel._targetServerInstance, selectedStorageAccount, this.migrationStateModel._azureAccount, this.migrationStateModel._targetSubscription))) {
if (!(await canTargetConnectToStorageAccount(
this.migrationStateModel._targetType,
this.migrationStateModel._targetServerInstance,
selectedStorageAccount,
this.migrationStateModel._azureAccount,
this.migrationStateModel._targetSubscription))) {
this._inaccessibleStorageAccounts = [selectedStorageAccount.name];
} else {
this._inaccessibleStorageAccounts = [];
@@ -661,7 +667,11 @@ export class DatabaseBackupPage extends MigrationWizardPage {
// check for storage account connectivity
const selectedStorageAccount = this.migrationStateModel._storageAccounts.find(sa => sa.name === (this._networkShareContainerStorageAccountDropdown.value as azdata.CategoryValue).displayName);
if ((this.migrationStateModel.isSqlMiTarget || this.migrationStateModel.isSqlVmTarget) && selectedStorageAccount) {
if (!(await canTargetConnectToStorageAccount(this.migrationStateModel._targetType, this.migrationStateModel._targetServerInstance, selectedStorageAccount, this.migrationStateModel._azureAccount, this.migrationStateModel._targetSubscription))) {
if (!(await canTargetConnectToStorageAccount(
this.migrationStateModel._targetType,
this.migrationStateModel._targetServerInstance,
selectedStorageAccount, this.migrationStateModel._azureAccount,
this.migrationStateModel._targetSubscription))) {
this._inaccessibleStorageAccounts = [selectedStorageAccount.name];
} else {
this._inaccessibleStorageAccounts = [];
@@ -1129,7 +1139,13 @@ export class DatabaseBackupPage extends MigrationWizardPage {
this._inaccessibleStorageAccounts = this._inaccessibleStorageAccounts.filter(storageAccountName => storageAccountName.toLowerCase() !== oldSelectedStorageAccount.toLowerCase());
}
if (!(await canTargetConnectToStorageAccount(this.migrationStateModel._targetType, this.migrationStateModel._targetServerInstance, selectedStorageAccount, this.migrationStateModel._azureAccount, this.migrationStateModel._targetSubscription))) {
if (!(await canTargetConnectToStorageAccount(
this.migrationStateModel._targetType,
this.migrationStateModel._targetServerInstance,
selectedStorageAccount,
this.migrationStateModel._azureAccount,
this.migrationStateModel._targetSubscription))) {
this._inaccessibleStorageAccounts = this._inaccessibleStorageAccounts.filter(storageAccountName => storageAccountName.toLowerCase() !== selectedStorageAccount.name.toLowerCase());
this._inaccessibleStorageAccounts.push(selectedStorageAccount.name);
}
@@ -1452,10 +1468,10 @@ export class DatabaseBackupPage extends MigrationWizardPage {
private async getSubscriptionValues(): Promise<void> {
this._networkShareContainerSubscription.value = this.migrationStateModel._targetSubscription.name;
this._networkShareContainerLocation.value = await this.migrationStateModel.getLocationDisplayName(this.migrationStateModel._targetServerInstance.location);
this._networkShareContainerLocation.value = await this.migrationStateModel._location.displayName;
this._blobContainerSubscription.value = this.migrationStateModel._targetSubscription.name;
this._blobContainerLocation.value = await this.migrationStateModel.getLocationDisplayName(this.migrationStateModel._targetServerInstance.location);
this._blobContainerLocation.value = this.migrationStateModel._location.displayName;
this.migrationStateModel._databaseBackup.subscription = this.migrationStateModel._targetSubscription;

View File

@@ -10,7 +10,7 @@ import { MigrationMode, MigrationStateModel, NetworkContainerType, StateChangeEv
import { CreateSqlMigrationServiceDialog } from '../dialog/createSqlMigrationService/createSqlMigrationServiceDialog';
import * as constants from '../constants/strings';
import { WIZARD_INPUT_COMPONENT_WIDTH } from './wizardController';
import { getFullResourceGroupFromId, getLocationDisplayName, getSqlMigrationService, getSqlMigrationServiceAuthKeys, getSqlMigrationServiceMonitoringData, SqlVMServer } from '../api/azure';
import { getFullResourceGroupFromId, getSqlMigrationService, getSqlMigrationServiceAuthKeys, getSqlMigrationServiceMonitoringData, SqlVMServer } from '../api/azure';
import { IconPathHelper } from '../constants/iconPathHelper';
import { logError, TelemetryViews } from '../telemetry';
import * as utils from '../api/utils';
@@ -19,7 +19,7 @@ import * as styles from '../constants/styles';
export class IntergrationRuntimePage extends MigrationWizardPage {
private _view!: azdata.ModelView;
private _statusLoadingComponent!: azdata.LoadingComponent;
private _subscription!: azdata.TextComponent;
private _subscriptionDropdown!: azdata.DropDownComponent;
private _location!: azdata.TextComponent;
private _resourceGroupDropdown!: azdata.DropDownComponent;
private _dmsDropdown!: azdata.DropDownComponent;
@@ -27,7 +27,6 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
private _dmsStatusInfoBox!: azdata.InfoBoxComponent;
private _authKeyTable!: azdata.DeclarativeTableComponent;
private _refreshButton!: azdata.ButtonComponent;
private _connectionStatusLoader!: azdata.LoadingComponent;
private _copy1!: azdata.ButtonComponent;
private _copy2!: azdata.ButtonComponent;
private _refresh1!: azdata.ButtonComponent;
@@ -157,8 +156,13 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
this._networkShareButton.onDidChangeCheckedState(async checked => {
if (checked) {
this.migrationStateModel._databaseBackup.networkContainerType = NetworkContainerType.NETWORK_SHARE;
await utils.updateControlDisplay(this._dmsInfoContainer, true);
this.migrationStateModel.refreshDatabaseBackupPage = true;
const hasService = this.migrationStateModel._sqlMigrationService !== undefined;
await utils.updateControlDisplay(this._dmsInfoContainer, hasService);
if (hasService) {
await this.loadStatus();
}
}
}));
@@ -271,15 +275,13 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
this.migrationStateModel._databaseBackup.networkContainerType = NetworkContainerType.BLOB_CONTAINER;
this._blobContainerButton.checked = true;
this._subscription.value = this.migrationStateModel._targetSubscription.name;
this._location.value = await getLocationDisplayName(
this.migrationStateModel._targetServerInstance.location);
await this.loadSubscriptionsDropdown();
this._location.value = this.migrationStateModel._location.displayName;
await utils.updateControlDisplay(
this._dmsInfoContainer,
isSqlDbTarget || isNetworkShare);
await this.loadResourceGroupDropdown();
}
public async onPageLeave(pageChangeInfo: azdata.window.WizardPageChangeInfo): Promise<void> {
@@ -306,13 +308,32 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
value: constants.SUBSCRIPTION,
CSSStyles: { ...styles.LABEL_CSS }
}).component();
this._subscription = this._view.modelBuilder.text()
this._subscriptionDropdown = this._view.modelBuilder.dropDown()
.withProps({
enabled: false,
ariaLabel: constants.MIGRATION_SERVICE_SELECT_SERVICE_LABEL,
width: WIZARD_INPUT_COMPONENT_WIDTH,
editable: true,
required: true,
fireOnTextChange: true,
placeholder: constants.SELECT_A_SERVICE,
CSSStyles: { 'margin': '0' }
}).component();
this._disposables.push(
this._subscriptionDropdown.onValueChanged(async (value) => {
if (value && value !== 'undefined' && value !== constants.SERVICE_NOT_FOUND) {
const selectedSubscription = this.migrationStateModel._subscriptions.find(
sub => `${sub.name} - ${sub.id}` === value);
this.migrationStateModel._sqlMigrationServiceSubscription = (selectedSubscription)
? selectedSubscription
: undefined!;
} else {
this.migrationStateModel._sqlMigrationServiceSubscription = undefined!;
}
await this.loadResourceGroupDropdown();
}));
const locationLabel = this._view.modelBuilder.text()
.withProps({
value: constants.LOCATION,
@@ -349,8 +370,11 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
this.migrationStateModel._sqlMigrationServiceResourceGroup = (selectedResourceGroup)
? selectedResourceGroup
: undefined!;
this.populateDms();
}
else {
this.migrationStateModel._sqlMigrationServiceResourceGroup = undefined!;
}
this.loadDmsDropdown();
}));
const migrationServiceDropdownLabel = this._view.modelBuilder.text()
@@ -379,15 +403,18 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
dms => dms.name === value
&& dms.properties.resourceGroup.toLowerCase() === resourceGroupName);
if (selectedDms) {
this.migrationStateModel._sqlMigrationService = selectedDms;
await this.loadStatus();
}
const showShirStatus = selectedDms !== undefined &&
(this.migrationStateModel.isSqlDbTarget ||
this.migrationStateModel.isBackupContainerNetworkShare);
this.migrationStateModel._sqlMigrationService = selectedDms;
await utils.updateControlDisplay(
this._dmsInfoContainer,
this.migrationStateModel.isSqlDbTarget ||
this.migrationStateModel.isBackupContainerNetworkShare);
showShirStatus);
if (showShirStatus) {
await this.loadStatus();
}
} else {
this.migrationStateModel._sqlMigrationService = undefined;
await utils.updateControlDisplay(this._dmsInfoContainer, false);
@@ -414,15 +441,15 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
this.migrationStateModel._sqlMigrationServiceResourceGroup = createdDmsResult.resourceGroup;
this.migrationStateModel._sqlMigrationService = createdDmsResult.service;
await this.loadResourceGroupDropdown();
this.populateDms();
}));
return this._view.modelBuilder.flexContainer()
.withItems([
descriptionText,
subscriptionLabel,
this._subscription,
this._subscriptionDropdown,
locationLabel,
this._location,
resourceGroupLabel,
@@ -534,48 +561,71 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
authenticationKeysLabel,
this._authKeyTable]);
this._connectionStatusLoader = this._view.modelBuilder.loadingComponent()
.withItem(statusContainer)
.withProps({ loading: false })
.component();
container.addItems([
connectionLabelContainer,
this._connectionStatusLoader]);
statusContainer]);
return container;
}
public async loadSubscriptionsDropdown(): Promise<void> {
try {
this._subscriptionDropdown.loading = true;
this.migrationStateModel._subscriptions = await utils.getAzureSubscriptions(
this.migrationStateModel._azureAccount);
const sub = this.migrationStateModel._sqlMigrationServiceSubscription
?? this.migrationStateModel._targetSubscription;
this._subscriptionDropdown.values = await utils.getAzureSubscriptionsDropdownValues(
this.migrationStateModel._subscriptions);
utils.selectDefaultDropdownValue(this._subscriptionDropdown, sub?.id, false);
} catch (e) {
logError(TelemetryViews.IntegrationRuntimePage, 'Error loadSubscriptionsDropdown', e);
} finally {
this._subscriptionDropdown.loading = false;
}
}
public async loadResourceGroupDropdown(): Promise<void> {
try {
this._resourceGroupDropdown.loading = true;
this._dmsDropdown.loading = true;
const account = this.migrationStateModel._azureAccount;
const subscription = this.migrationStateModel._sqlMigrationServiceSubscription;
const serviceId = this.migrationStateModel._sqlMigrationService?.id;
const resourceGroup = this.migrationStateModel._sqlMigrationServiceResourceGroup?.name ??
serviceId !== undefined
? getFullResourceGroupFromId(serviceId!)
: undefined;
this.migrationStateModel._sqlMigrationServices = await utils.getAzureSqlMigrationServices(
this.migrationStateModel._azureAccount,
this.migrationStateModel._targetSubscription);
const migrationServices = await utils.getAzureSqlMigrationServices(
account,
subscription);
this.migrationStateModel._resourceGroups = utils.getServiceResourceGroupsByLocation(
this.migrationStateModel._sqlMigrationServices,
const resourceGroups = utils.getServiceResourceGroupsByLocation(
migrationServices,
this.migrationStateModel._location);
this._resourceGroupDropdown.values = utils.getResourceDropdownValues(
this.migrationStateModel._resourceGroups,
resourceGroups,
constants.RESOURCE_GROUP_NOT_FOUND);
const resourceGroup = this.migrationStateModel._sqlMigrationService
? getFullResourceGroupFromId(this.migrationStateModel._sqlMigrationService?.id)
: undefined;
this.migrationStateModel._sqlMigrationServices = migrationServices;
this.migrationStateModel._resourceGroups = resourceGroups;
utils.selectDefaultDropdownValue(this._resourceGroupDropdown, resourceGroup, false);
} catch (e) {
logError(TelemetryViews.IntegrationRuntimePage, 'Error loadResourceGroupDropdown', e);
} finally {
this._dmsDropdown.loading = false;
this._resourceGroupDropdown.loading = false;
}
}
public populateDms(): void {
public loadDmsDropdown(): void {
try {
this._dmsDropdown.loading = true;
const serviceId = this.migrationStateModel._sqlMigrationService?.id;
this._dmsDropdown.values = utils.getAzureResourceDropdownValues(
this.migrationStateModel._sqlMigrationServices,
this.migrationStateModel._location,
@@ -584,53 +634,77 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
utils.selectDefaultDropdownValue(
this._dmsDropdown,
this.migrationStateModel._sqlMigrationService?.id,
serviceId,
false);
} catch (e) {
logError(TelemetryViews.IntegrationRuntimePage, 'Error loadDmsDropdown', e);
} finally {
this._dmsDropdown.loading = false;
}
}
private _lastIn = 0;
private async loadStatus(): Promise<void> {
const callSequence = ++this._lastIn;
let serviceName = '';
try {
this._statusLoadingComponent.loading = true;
if (callSequence === this._lastIn) {
this._statusLoadingComponent.loading = true;
}
const service = this.migrationStateModel._sqlMigrationService;
if (service) {
const account = this.migrationStateModel._azureAccount;
const subscription = this.migrationStateModel._sqlMigrationServiceSubscription;
const resourceGroup = service.properties.resourceGroup;
const location = service.location;
serviceName = service.name;
if (service?.properties?.integrationRuntimeState) {
service.properties.integrationRuntimeState = undefined;
}
if (this.migrationStateModel._sqlMigrationService) {
const migrationService = await getSqlMigrationService(
this.migrationStateModel._azureAccount,
this.migrationStateModel._targetSubscription,
this.migrationStateModel._sqlMigrationService.properties.resourceGroup,
this.migrationStateModel._sqlMigrationService.location,
this.migrationStateModel._sqlMigrationService.name);
this.migrationStateModel._sqlMigrationService = migrationService;
account,
subscription,
resourceGroup,
location,
serviceName);
// exit if new call has started
if (callSequence !== this._lastIn) { return; }
const migrationServiceMonitoringStatus = await getSqlMigrationServiceMonitoringData(
this.migrationStateModel._azureAccount,
this.migrationStateModel._targetSubscription,
this.migrationStateModel._sqlMigrationService.properties.resourceGroup,
this.migrationStateModel._sqlMigrationService.location,
this.migrationStateModel._sqlMigrationService!.name);
this.migrationStateModel._nodeNames = migrationServiceMonitoringStatus.nodes.map(
account,
subscription,
resourceGroup,
location,
serviceName);
const nodeNames = migrationServiceMonitoringStatus.nodes.map(
node => node.nodeName);
// exit if new call has started
if (callSequence !== this._lastIn) { return; }
const migrationServiceAuthKeys = await getSqlMigrationServiceAuthKeys(
this.migrationStateModel._azureAccount,
this.migrationStateModel._targetSubscription,
this.migrationStateModel._sqlMigrationService.properties.resourceGroup,
this.migrationStateModel._sqlMigrationService.location,
this.migrationStateModel._sqlMigrationService!.name);
account,
subscription,
resourceGroup,
location,
serviceName);
// exit if new call has started
if (callSequence !== this._lastIn) { return; }
const state = migrationService.properties.integrationRuntimeState;
if (state === 'Online') {
await this._dmsStatusInfoBox.updateProperties(<azdata.InfoBoxComponentProperties>{
text: constants.SERVICE_READY(
this.migrationStateModel._sqlMigrationService!.name,
this.migrationStateModel._nodeNames.join(', ')),
text: constants.SERVICE_READY(serviceName, nodeNames.join(', ')),
style: 'success'
});
} else {
await this._dmsStatusInfoBox.updateProperties(<azdata.InfoBoxComponentProperties>{
text: constants.SERVICE_NOT_READY(
this.migrationStateModel._sqlMigrationService!.name),
text: constants.SERVICE_NOT_READY(serviceName),
style: 'error'
});
}
@@ -655,12 +729,26 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
}
]];
// exit if new call has started
if (callSequence !== this._lastIn) { return; }
await this._authKeyTable.setDataValues(data);
this.migrationStateModel._sqlMigrationService = migrationService;
this.migrationStateModel._sqlMigrationServiceSubscription = subscription;
this.migrationStateModel._nodeNames = nodeNames;
}
} catch (e) {
logError(TelemetryViews.IntegrationRuntimePage, 'ErrorLoadingStatus', e);
await this._dmsStatusInfoBox.updateProperties(<azdata.InfoBoxComponentProperties>{
text: constants.SERVICE_ERROR_NOT_READY(serviceName, e.message),
style: 'error'
});
logError(TelemetryViews.IntegrationRuntimePage, 'Error loadStatus', e);
} finally {
this._statusLoadingComponent.loading = false;
if (callSequence === this._lastIn) {
this._statusLoadingComponent.loading = false;
}
}
}
}

View File

@@ -100,8 +100,7 @@ export class SummaryPage extends MigrationWizardPage {
createInformationRow(
this._view,
constants.LOCATION,
await this.migrationStateModel.getLocationDisplayName(
this.migrationStateModel._targetServerInstance.location)),
this.migrationStateModel._location.displayName),
createInformationRow(
this._view,
constants.RESOURCE_GROUP,
@@ -140,16 +139,15 @@ export class SummaryPage extends MigrationWizardPage {
constants.IR_PAGE_TITLE),
createInformationRow(
this._view, constants.SUBSCRIPTION,
this.migrationStateModel._targetSubscription.name),
this.migrationStateModel._sqlMigrationServiceSubscription.name),
createInformationRow(
this._view,
constants.LOCATION,
await this.migrationStateModel.getLocationDisplayName(
this.migrationStateModel._sqlMigrationService?.location!)),
this.migrationStateModel._location.displayName),
createInformationRow(
this._view,
constants.RESOURCE_GROUP,
this.migrationStateModel._sqlMigrationService?.properties?.resourceGroup!),
this.migrationStateModel._sqlMigrationServiceResourceGroup.name),
createInformationRow(
this._view,
constants.IR_PAGE_TITLE,

View File

@@ -709,7 +709,10 @@ export class TargetSelectionPage extends MigrationWizardPage {
if (selectedVm) {
this.migrationStateModel._targetServerInstance = utils.deepClone(selectedVm)! as SqlVMServer;
this.migrationStateModel._vmInstanceView = await getVMInstanceView(this.migrationStateModel._targetServerInstance, this.migrationStateModel._azureAccount, this.migrationStateModel._targetSubscription);
this.migrationStateModel._vmInstanceView = await getVMInstanceView(
this.migrationStateModel._targetServerInstance,
this.migrationStateModel._azureAccount,
this.migrationStateModel._targetSubscription);
this.wizard.message = { text: '' };
// validate power state from VM instance view
@@ -870,45 +873,45 @@ export class TargetSelectionPage extends MigrationWizardPage {
this._azureAccountsDropdown.loading = true;
this.migrationStateModel._azureAccounts = await utils.getAzureAccounts();
this._azureAccountsDropdown.values = await utils.getAzureAccountsDropdownValues(this.migrationStateModel._azureAccounts);
} finally {
this._azureAccountsDropdown.loading = false;
const accountId =
this.migrationStateModel._azureAccount?.displayInfo?.userId ??
this._serviceContext?.azureAccount?.displayInfo?.userId;
this._azureAccountsDropdown.values = await utils.getAzureAccountsDropdownValues(this.migrationStateModel._azureAccounts);
utils.selectDefaultDropdownValue(
this._azureAccountsDropdown,
accountId,
false);
} finally {
this._azureAccountsDropdown.loading = false;
}
}
private async populateTenantsDropdown(): Promise<void> {
try {
this._accountTenantDropdown.loading = true;
if (!utils.isAccountTokenStale(this.migrationStateModel._azureAccount) &&
this.migrationStateModel._azureAccount?.properties?.tenants?.length > 0) {
this.migrationStateModel._accountTenants = utils.getAzureTenants(this.migrationStateModel._azureAccount);
this._accountTenantDropdown.values = utils.getAzureTenantsDropdownValues(this.migrationStateModel._accountTenants);
}
const tenantId =
this.migrationStateModel._azureTenant?.id ??
this._serviceContext?.tenant?.id;
if (!utils.isAccountTokenStale(this.migrationStateModel._azureAccount) &&
this.migrationStateModel._azureAccount?.properties?.tenants?.length > 0) {
this.migrationStateModel._accountTenants = utils.getAzureTenants(this.migrationStateModel._azureAccount);
this._accountTenantDropdown.values = utils.getAzureTenantsDropdownValues(this.migrationStateModel._accountTenants);
}
utils.selectDefaultDropdownValue(
this._accountTenantDropdown,
tenantId,
true);
await this._azureAccountsDropdown.validate();
} finally {
this._accountTenantDropdown.loading = false;
await this._accountTenantFlexContainer.updateCssStyles(
this.migrationStateModel._azureAccount?.properties?.tenants?.length > 1
? { 'display': 'inline' }
: { 'display': 'none' }
);
await this._azureAccountsDropdown.validate();
} finally {
this._accountTenantDropdown.loading = false;
}
}
@@ -916,19 +919,20 @@ export class TargetSelectionPage extends MigrationWizardPage {
try {
this._azureSubscriptionDropdown.loading = true;
this.migrationStateModel._subscriptions = await utils.getAzureSubscriptions(this.migrationStateModel._azureAccount);
this._azureSubscriptionDropdown.values = await utils.getAzureSubscriptionsDropdownValues(this.migrationStateModel._subscriptions);
} catch (e) {
console.log(e);
} finally {
this._azureSubscriptionDropdown.loading = false;
const subscriptionId =
this.migrationStateModel._targetSubscription?.id ??
this._serviceContext?.subscription?.id;
this._azureSubscriptionDropdown.values = await utils.getAzureSubscriptionsDropdownValues(this.migrationStateModel._subscriptions);
utils.selectDefaultDropdownValue(
this._azureSubscriptionDropdown,
subscriptionId,
false);
} catch (e) {
console.log(e);
} finally {
this._azureSubscriptionDropdown.loading = false;
}
}
@@ -964,19 +968,20 @@ export class TargetSelectionPage extends MigrationWizardPage {
this.migrationStateModel._targetSqlDatabaseServers);
break;
}
this._azureLocationDropdown.values = utils.getAzureLocationsDropdownValues(this.migrationStateModel._locations);
} catch (e) {
console.log(e);
} finally {
this._azureLocationDropdown.loading = false;
const location =
this.migrationStateModel._location?.displayName ??
this._serviceContext?.location?.displayName;
this._azureLocationDropdown.values = utils.getAzureLocationsDropdownValues(this.migrationStateModel._locations);
utils.selectDefaultDropdownValue(
this._azureLocationDropdown,
location,
true);
} catch (e) {
console.log(e);
} finally {
this._azureLocationDropdown.loading = false;
}
}
@@ -1000,24 +1005,29 @@ export class TargetSelectionPage extends MigrationWizardPage {
this.migrationStateModel._location);
break;
}
const resourceGroupId = this.migrationStateModel._resourceGroup?.id;
this._azureResourceGroupDropdown.values = utils.getResourceDropdownValues(
this.migrationStateModel._resourceGroups,
constants.RESOURCE_GROUP_NOT_FOUND);
utils.selectDefaultDropdownValue(
this._azureResourceGroupDropdown,
resourceGroupId,
false);
} catch (e) {
console.log(e);
} finally {
this._azureResourceGroupDropdown.loading = false;
utils.selectDefaultDropdownValue(
this._azureResourceGroupDropdown,
this.migrationStateModel._resourceGroup?.id,
false);
}
}
private async populateResourceInstanceDropdown(): Promise<void> {
try {
this._azureResourceDropdown.loading = true;
const targetName = this.migrationStateModel.migrationTargetServerName;
switch (this.migrationStateModel._targetType) {
case MigrationTargetType.SQLMI:
this._azureResourceDropdown.values = await utils.getManagedInstancesDropdownValues(
@@ -1043,31 +1053,19 @@ export class TargetSelectionPage extends MigrationWizardPage {
constants.NO_SQL_DATABASE_SERVER_FOUND);
break;
}
} finally {
this._azureResourceDropdown.loading = false;
let targetName = '';
switch (this.migrationStateModel._targetType) {
case MigrationTargetType.SQLMI:
targetName = (this.migrationStateModel._targetServerInstance as azureResource.AzureSqlManagedInstance)?.name;
break;
case MigrationTargetType.SQLVM:
targetName = (this.migrationStateModel._targetServerInstance as SqlVMServer)?.name;
break;
case MigrationTargetType.SQLDB:
targetName = (this.migrationStateModel._targetServerInstance as AzureSqlDatabaseServer)?.name;
break;
}
utils.selectDefaultDropdownValue(
this._azureResourceDropdown,
targetName,
true);
} finally {
this._azureResourceDropdown.loading = false;
}
}
private _updateTdeMigrationButtonStatus() {
this.wizard.customButtons[TDE_MIGRATION_BUTTON_INDEX].enabled = this.migrationStateModel.tdeMigrationConfig.shouldAdsMigrateCertificates() &&
this.wizard.customButtons[TDE_MIGRATION_BUTTON_INDEX].enabled =
this.migrationStateModel.tdeMigrationConfig.shouldAdsMigrateCertificates() &&
this.migrationStateModel._targetManagedInstances.length > 0;
}

View File

@@ -272,10 +272,7 @@ export class WizardController {
stateModel: MigrationStateModel,
serviceContextChangedEvent: vscode.EventEmitter<ServiceContextChangeEvent>): Promise<void> {
const resourceGroup = this._getResourceGroupByName(
stateModel._resourceGroups,
stateModel._sqlMigrationService?.properties.resourceGroup);
const resourceGroup = stateModel._sqlMigrationServiceResourceGroup;
const subscription = this._getSubscriptionFromResourceId(
stateModel._subscriptions,
resourceGroup?.id);
@@ -296,13 +293,6 @@ export class WizardController {
serviceContextChangedEvent);
}
private _getResourceGroupByName(
resourceGroups: azureResource.AzureResourceResourceGroup[],
displayName?: string): azureResource.AzureResourceResourceGroup | undefined {
return resourceGroups.find(rg => rg.name === displayName);
}
private _getLocationByValue(
locations: azureResource.AzureLocation[],
name?: string): azureResource.AzureLocation | undefined {