mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Tenant selction bug (#23349)
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
"name": "sql-migration",
|
"name": "sql-migration",
|
||||||
"displayName": "%displayName%",
|
"displayName": "%displayName%",
|
||||||
"description": "%description%",
|
"description": "%description%",
|
||||||
"version": "1.4.5",
|
"version": "1.4.6",
|
||||||
"publisher": "Microsoft",
|
"publisher": "Microsoft",
|
||||||
"preview": false,
|
"preview": false,
|
||||||
"license": "https://raw.githubusercontent.com/Microsoft/azuredatastudio/main/LICENSE.txt",
|
"license": "https://raw.githubusercontent.com/Microsoft/azuredatastudio/main/LICENSE.txt",
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
"aiKey": "29a207bb14f84905966a8f22524cb730-25407f35-11b6-4d4e-8114-ab9e843cb52f-7380",
|
"aiKey": "29a207bb14f84905966a8f22524cb730-25407f35-11b6-4d4e-8114-ab9e843cb52f-7380",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "*",
|
"vscode": "*",
|
||||||
"azdata": ">=1.41.0"
|
"azdata": ">=1.44.1"
|
||||||
},
|
},
|
||||||
"activationEvents": [
|
"activationEvents": [
|
||||||
"onDashboardOpen",
|
"onDashboardOpen",
|
||||||
|
|||||||
@@ -468,7 +468,7 @@ export function getAzureTenants(account?: Account): Tenant[] {
|
|||||||
return account?.properties.tenants || [];
|
return account?.properties.tenants || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAzureSubscriptions(account?: Account): Promise<azureResource.AzureResourceSubscription[]> {
|
export async function getAzureSubscriptions(account?: Account, tenantId?: string): Promise<azureResource.AzureResourceSubscription[]> {
|
||||||
let subscriptions: azureResource.AzureResourceSubscription[] = [];
|
let subscriptions: azureResource.AzureResourceSubscription[] = [];
|
||||||
try {
|
try {
|
||||||
subscriptions = account && !isAccountTokenStale(account)
|
subscriptions = account && !isAccountTokenStale(account)
|
||||||
@@ -477,8 +477,9 @@ export async function getAzureSubscriptions(account?: Account): Promise<azureRes
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
logError(TelemetryViews.Utils, 'utils.getAzureSubscriptions', e);
|
logError(TelemetryViews.Utils, 'utils.getAzureSubscriptions', e);
|
||||||
}
|
}
|
||||||
subscriptions.sort((a, b) => a.name.localeCompare(b.name));
|
const filtered = subscriptions.filter(subscription => subscription.tenant === tenantId);
|
||||||
return subscriptions;
|
filtered.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
|
return filtered;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function getAzureSubscriptionsDropdownValues(subscriptions: azureResource.AzureResourceSubscription[]): Promise<CategoryValue[]> {
|
export async function getAzureSubscriptionsDropdownValues(subscriptions: azureResource.AzureResourceSubscription[]): Promise<CategoryValue[]> {
|
||||||
@@ -1167,3 +1168,8 @@ export function createRegistrationInstructions(view: ModelView, testConnectionBu
|
|||||||
flexFlow: 'column'
|
flexFlow: 'column'
|
||||||
}).component();
|
}).component();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function clearDropDown(dropDown: DropDownComponent): void {
|
||||||
|
dropDown.values = [];
|
||||||
|
dropDown.value = undefined;
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||||
*--------------------------------------------------------------------------------------------*/
|
*--------------------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
import { AzureAccount } from 'azurecore';
|
|
||||||
import * as nls from 'vscode-nls';
|
import * as nls from 'vscode-nls';
|
||||||
import { EOL } from 'os';
|
import { EOL } from 'os';
|
||||||
import { MigrationSourceAuthenticationType } from '../models/stateMachine';
|
import { MigrationSourceAuthenticationType } from '../models/stateMachine';
|
||||||
@@ -506,21 +505,6 @@ export function accountLinkedMessage(count: number): string {
|
|||||||
return count === 1 ? localize('sql.migration.wizard.account.count.single.message', '{0} account linked', count) : localize('sql.migration.wizard.account.count.multiple.message', '{0} accounts linked', count);
|
return count === 1 ? localize('sql.migration.wizard.account.count.single.message', '{0} account linked', count) : localize('sql.migration.wizard.account.count.multiple.message', '{0} accounts linked', count);
|
||||||
}
|
}
|
||||||
export const AZURE_TENANT = localize('sql.migration.azure.tenant', "Azure AD tenant");
|
export const AZURE_TENANT = localize('sql.migration.azure.tenant', "Azure AD tenant");
|
||||||
export function ACCOUNT_STALE_ERROR(account: AzureAccount) {
|
|
||||||
return localize(
|
|
||||||
'azure.accounts.accountStaleError',
|
|
||||||
"The access token for selected account '{0}' and tenant '{1}' is no longer valid. Select 'Link account' and refresh the account, or select a different account.",
|
|
||||||
`${account?.displayInfo?.displayName} (${account?.displayInfo?.userId})`,
|
|
||||||
`${account?.properties?.tenants[0]?.displayName} (${account?.properties?.tenants[0]?.userId})`);
|
|
||||||
}
|
|
||||||
export function ACCOUNT_ACCESS_ERROR(account: AzureAccount, error: Error) {
|
|
||||||
return localize(
|
|
||||||
'azure.accounts.accountAccessError',
|
|
||||||
"An error occurred while accessing the selected account '{0}' and tenant '{1}'. Select 'Link account' and refresh the account, or select a different account. Error '{2}'",
|
|
||||||
`${account?.displayInfo?.displayName} (${account?.displayInfo?.userId})`,
|
|
||||||
`${account?.properties?.tenants[0]?.displayName} (${account?.properties?.tenants[0]?.userId})`,
|
|
||||||
error.message);
|
|
||||||
}
|
|
||||||
export function MI_NOT_READY_ERROR(miName: string, state: string): string {
|
export function MI_NOT_READY_ERROR(miName: string, state: string): string {
|
||||||
return localize('sql.migration.mi.not.ready', "The managed instance '{0}' is unavailable for migration because it is currently in the '{1}' state. To continue, select an available managed instance.", miName, state);
|
return localize('sql.migration.mi.not.ready', "The managed instance '{0}' is unavailable for migration because it is currently in the '{1}' state. To continue, select an available managed instance.", miName, state);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export class RestartMigrationDialog {
|
|||||||
|
|
||||||
// TargetSelection
|
// TargetSelection
|
||||||
azureAccount: serviceContext.azureAccount!,
|
azureAccount: serviceContext.azureAccount!,
|
||||||
azureTenant: serviceContext.azureAccount!.properties.tenants[0]!,
|
azureTenant: serviceContext.tenant!,
|
||||||
subscription: serviceContext.subscription!,
|
subscription: serviceContext.subscription!,
|
||||||
location: location,
|
location: location,
|
||||||
resourceGroup: {
|
resourceGroup: {
|
||||||
|
|||||||
@@ -143,11 +143,12 @@ export class SelectMigrationServiceDialog {
|
|||||||
this._azureAccountsDropdown.onValueChanged(async (value) => {
|
this._azureAccountsDropdown.onValueChanged(async (value) => {
|
||||||
if (value && value !== 'undefined') {
|
if (value && value !== 'undefined') {
|
||||||
const selectedAccount = this._azureAccounts.find(account => account.displayInfo.displayName === value);
|
const selectedAccount = this._azureAccounts.find(account => account.displayInfo.displayName === value);
|
||||||
this._serviceContext.azureAccount = (selectedAccount)
|
this._serviceContext.azureAccount = selectedAccount
|
||||||
? utils.deepClone(selectedAccount)
|
? utils.deepClone(selectedAccount)
|
||||||
: undefined!;
|
: undefined!;
|
||||||
await this._populateTentantsDropdown();
|
|
||||||
}
|
}
|
||||||
|
utils.clearDropDown(this._accountTenantDropdown);
|
||||||
|
await this._populateTentantsDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const linkAccountButton = this._view.modelBuilder.hyperlink()
|
const linkAccountButton = this._view.modelBuilder.hyperlink()
|
||||||
@@ -190,12 +191,12 @@ export class SelectMigrationServiceDialog {
|
|||||||
this._accountTenantDropdown.onValueChanged(async value => {
|
this._accountTenantDropdown.onValueChanged(async value => {
|
||||||
if (value && value !== 'undefined') {
|
if (value && value !== 'undefined') {
|
||||||
const selectedTenant = this._accountTenants.find(tenant => tenant.displayName === value);
|
const selectedTenant = this._accountTenants.find(tenant => tenant.displayName === value);
|
||||||
if (selectedTenant) {
|
this._serviceContext.tenant = selectedTenant
|
||||||
this._serviceContext.tenant = utils.deepClone(selectedTenant);
|
? utils.deepClone(selectedTenant)
|
||||||
this._serviceContext.azureAccount!.properties.tenants = [selectedTenant];
|
: undefined!;
|
||||||
}
|
|
||||||
await this._populateSubscriptionDropdown();
|
|
||||||
}
|
}
|
||||||
|
utils.clearDropDown(this._azureSubscriptionDropdown);
|
||||||
|
await this._populateSubscriptionDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._accountTenantFlexContainer = this._view.modelBuilder.flexContainer()
|
this._accountTenantFlexContainer = this._view.modelBuilder.flexContainer()
|
||||||
@@ -231,11 +232,12 @@ export class SelectMigrationServiceDialog {
|
|||||||
this._azureSubscriptionDropdown.onValueChanged(async (value) => {
|
this._azureSubscriptionDropdown.onValueChanged(async (value) => {
|
||||||
if (value && value !== 'undefined') {
|
if (value && value !== 'undefined') {
|
||||||
const selectedSubscription = this._subscriptions.find(subscription => `${subscription.name} - ${subscription.id}` === value);
|
const selectedSubscription = this._subscriptions.find(subscription => `${subscription.name} - ${subscription.id}` === value);
|
||||||
this._serviceContext.subscription = (selectedSubscription)
|
this._serviceContext.subscription = selectedSubscription
|
||||||
? utils.deepClone(selectedSubscription)
|
? utils.deepClone(selectedSubscription)
|
||||||
: undefined!;
|
: undefined!;
|
||||||
await this._populateLocationDropdown();
|
|
||||||
}
|
}
|
||||||
|
utils.clearDropDown(this._azureLocationDropdown);
|
||||||
|
await this._populateLocationDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const azureLocationLabel = this._view.modelBuilder.text()
|
const azureLocationLabel = this._view.modelBuilder.text()
|
||||||
@@ -259,12 +261,12 @@ export class SelectMigrationServiceDialog {
|
|||||||
this._azureLocationDropdown.onValueChanged(async (value) => {
|
this._azureLocationDropdown.onValueChanged(async (value) => {
|
||||||
if (value && value !== 'undefined') {
|
if (value && value !== 'undefined') {
|
||||||
const selectedLocation = this._locations.find(location => location.displayName === value);
|
const selectedLocation = this._locations.find(location => location.displayName === value);
|
||||||
this._serviceContext.location = (selectedLocation)
|
this._serviceContext.location = selectedLocation
|
||||||
? utils.deepClone(selectedLocation)
|
? utils.deepClone(selectedLocation)
|
||||||
: undefined!;
|
: undefined!;
|
||||||
await this._populateResourceGroupDropdown();
|
|
||||||
this._populateMigrationServiceDropdown();
|
|
||||||
}
|
}
|
||||||
|
utils.clearDropDown(this._azureResourceGroupDropdown);
|
||||||
|
await this._populateResourceGroupDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const azureResourceGroupLabel = this._view.modelBuilder.text()
|
const azureResourceGroupLabel = this._view.modelBuilder.text()
|
||||||
@@ -288,11 +290,12 @@ export class SelectMigrationServiceDialog {
|
|||||||
this._azureResourceGroupDropdown.onValueChanged(async (value) => {
|
this._azureResourceGroupDropdown.onValueChanged(async (value) => {
|
||||||
if (value && value !== 'undefined') {
|
if (value && value !== 'undefined') {
|
||||||
const selectedResourceGroup = this._resourceGroups.find(rg => rg.name === value);
|
const selectedResourceGroup = this._resourceGroups.find(rg => rg.name === value);
|
||||||
this._serviceContext.resourceGroup = (selectedResourceGroup)
|
this._serviceContext.resourceGroup = selectedResourceGroup
|
||||||
? utils.deepClone(selectedResourceGroup)
|
? utils.deepClone(selectedResourceGroup)
|
||||||
: undefined!;
|
: undefined!;
|
||||||
this._populateMigrationServiceDropdown();
|
|
||||||
}
|
}
|
||||||
|
utils.clearDropDown(this._azureServiceDropdown);
|
||||||
|
this._populateMigrationServiceDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._azureServiceDropdownLabel = this._view.modelBuilder.text()
|
this._azureServiceDropdownLabel = this._view.modelBuilder.text()
|
||||||
@@ -316,11 +319,11 @@ export class SelectMigrationServiceDialog {
|
|||||||
this._azureServiceDropdown.onValueChanged(async (value) => {
|
this._azureServiceDropdown.onValueChanged(async (value) => {
|
||||||
if (value && value !== 'undefined') {
|
if (value && value !== 'undefined') {
|
||||||
const selectedDms = this._sqlMigrationServices.find(dms => dms.name === value);
|
const selectedDms = this._sqlMigrationServices.find(dms => dms.name === value);
|
||||||
this._serviceContext.migrationService = (selectedDms)
|
this._serviceContext.migrationService = selectedDms
|
||||||
? utils.deepClone(selectedDms)
|
? utils.deepClone(selectedDms)
|
||||||
: undefined!;
|
: undefined!;
|
||||||
await this._updateButtonState();
|
|
||||||
}
|
}
|
||||||
|
await this._updateButtonState();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
this._disposables.push(
|
this._disposables.push(
|
||||||
@@ -390,6 +393,7 @@ export class SelectMigrationServiceDialog {
|
|||||||
error.message);
|
error.message);
|
||||||
} finally {
|
} finally {
|
||||||
this._accountTenantDropdown.loading = false;
|
this._accountTenantDropdown.loading = false;
|
||||||
|
utils.clearDropDown(this._azureSubscriptionDropdown);
|
||||||
await this._populateSubscriptionDropdown();
|
await this._populateSubscriptionDropdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -397,7 +401,9 @@ export class SelectMigrationServiceDialog {
|
|||||||
private async _populateSubscriptionDropdown(): Promise<void> {
|
private async _populateSubscriptionDropdown(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
this._azureSubscriptionDropdown.loading = true;
|
this._azureSubscriptionDropdown.loading = true;
|
||||||
this._subscriptions = await utils.getAzureSubscriptions(this._serviceContext.azureAccount);
|
this._subscriptions = await utils.getAzureSubscriptions(
|
||||||
|
this._serviceContext.azureAccount,
|
||||||
|
this._serviceContext.tenant?.id);
|
||||||
this._azureSubscriptionDropdown.values = await utils.getAzureSubscriptionsDropdownValues(this._subscriptions);
|
this._azureSubscriptionDropdown.values = await utils.getAzureSubscriptionsDropdownValues(this._subscriptions);
|
||||||
if (this._azureSubscriptionDropdown.values.length > 0) {
|
if (this._azureSubscriptionDropdown.values.length > 0) {
|
||||||
utils.selectDefaultDropdownValue(
|
utils.selectDefaultDropdownValue(
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ export class TdeMigrationDialog {
|
|||||||
this._updateProgressText();
|
this._updateProgressText();
|
||||||
|
|
||||||
//Get access token
|
//Get access token
|
||||||
const accessToken = await azdata.accounts.getAccountSecurityToken(this._model._azureAccount, this._model._azureAccount.properties.tenants[0].id, azdata.AzureResource.ResourceManagement);
|
const accessToken = await azdata.accounts.getAccountSecurityToken(this._model._azureAccount, this._model._azureTenant.id, azdata.AzureResource.ResourceManagement);
|
||||||
|
|
||||||
const operationResult = await this._model.startTdeMigration(accessToken!.token, this._updateTableResultRow.bind(this));
|
const operationResult = await this._model.startTdeMigration(accessToken!.token, this._updateTableResultRow.bind(this));
|
||||||
|
|
||||||
|
|||||||
@@ -1142,7 +1142,7 @@ export class MigrationStateModel implements Model, vscode.Disposable {
|
|||||||
TelemetryAction.StartMigration,
|
TelemetryAction.StartMigration,
|
||||||
{
|
{
|
||||||
'sessionId': this._sessionId,
|
'sessionId': this._sessionId,
|
||||||
'tenantId': this._azureAccount.properties.tenants[0].id,
|
'tenantId': this._azureTenant?.id,
|
||||||
'subscriptionId': this._sqlMigrationServiceSubscription?.id,
|
'subscriptionId': this._sqlMigrationServiceSubscription?.id,
|
||||||
'resourceGroup': this._sqlMigrationServiceResourceGroup?.name,
|
'resourceGroup': this._sqlMigrationServiceResourceGroup?.name,
|
||||||
'location': this._location.name,
|
'location': this._location.name,
|
||||||
|
|||||||
@@ -98,7 +98,8 @@ export function sendSqlMigrationActionEvent(telemetryView: TelemetryViews, telem
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getTelemetryProps(migrationStateModel: MigrationStateModel): TelemetryEventProperties {
|
export function getTelemetryProps(migrationStateModel: MigrationStateModel): TelemetryEventProperties {
|
||||||
const tenantId = migrationStateModel._azureAccount?.properties?.tenants?.length > 0
|
const tenantId = migrationStateModel._azureTenant?.id ??
|
||||||
|
migrationStateModel._azureAccount?.properties?.tenants?.length > 0
|
||||||
? migrationStateModel._azureAccount?.properties?.tenants[0]?.id
|
? migrationStateModel._azureAccount?.properties?.tenants[0]?.id
|
||||||
: '';
|
: '';
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -327,6 +327,8 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
|
|||||||
} else {
|
} else {
|
||||||
this.migrationStateModel._sqlMigrationServiceSubscription = undefined!;
|
this.migrationStateModel._sqlMigrationServiceSubscription = undefined!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
utils.clearDropDown(this._resourceGroupDropdown);
|
||||||
await this.loadResourceGroupDropdown();
|
await this.loadResourceGroupDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -370,6 +372,7 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
|
|||||||
else {
|
else {
|
||||||
this.migrationStateModel._sqlMigrationServiceResourceGroup = undefined!;
|
this.migrationStateModel._sqlMigrationServiceResourceGroup = undefined!;
|
||||||
}
|
}
|
||||||
|
utils.clearDropDown(this._dmsDropdown);
|
||||||
this.loadDmsDropdown();
|
this.loadDmsDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -523,7 +526,8 @@ export class IntergrationRuntimePage extends MigrationWizardPage {
|
|||||||
try {
|
try {
|
||||||
this._subscriptionDropdown.loading = true;
|
this._subscriptionDropdown.loading = true;
|
||||||
this.migrationStateModel._subscriptions = await utils.getAzureSubscriptions(
|
this.migrationStateModel._subscriptions = await utils.getAzureSubscriptions(
|
||||||
this.migrationStateModel._azureAccount);
|
this.migrationStateModel._azureAccount,
|
||||||
|
this.migrationStateModel._azureTenant?.id);
|
||||||
|
|
||||||
const sub = this.migrationStateModel._sqlMigrationServiceSubscription
|
const sub = this.migrationStateModel._sqlMigrationServiceSubscription
|
||||||
?? this.migrationStateModel._targetSubscription;
|
?? this.migrationStateModel._targetSubscription;
|
||||||
|
|||||||
@@ -374,10 +374,11 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage {
|
|||||||
this._azureAccountsDropdown.onValueChanged(async (value) => {
|
this._azureAccountsDropdown.onValueChanged(async (value) => {
|
||||||
if (value && value !== 'undefined') {
|
if (value && value !== 'undefined') {
|
||||||
const selectedAccount = this.migrationStateModel._azureAccounts.find(account => account.displayInfo.displayName === value);
|
const selectedAccount = this.migrationStateModel._azureAccounts.find(account => account.displayInfo.displayName === value);
|
||||||
this.migrationStateModel._azureAccount = (selectedAccount)
|
this.migrationStateModel._azureAccount = selectedAccount
|
||||||
? utils.deepClone(selectedAccount)!
|
? utils.deepClone(selectedAccount)!
|
||||||
: undefined!;
|
: undefined!;
|
||||||
}
|
}
|
||||||
|
utils.clearDropDown(this._accountTenantDropdown);
|
||||||
await this.populateTenantsDropdown();
|
await this.populateTenantsDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -425,16 +426,12 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage {
|
|||||||
this._disposables.push(
|
this._disposables.push(
|
||||||
this._accountTenantDropdown.onValueChanged(async (value) => {
|
this._accountTenantDropdown.onValueChanged(async (value) => {
|
||||||
if (value && value !== 'undefined') {
|
if (value && value !== 'undefined') {
|
||||||
/**
|
const selectedTenant = this.migrationStateModel._accountTenants?.find(tenant => tenant.displayName === value);
|
||||||
* Replacing all the tenants in azure account with the tenant user has selected.
|
this.migrationStateModel._azureTenant = selectedTenant
|
||||||
* All azure requests will only run on this tenant from now on
|
? utils.deepClone(selectedTenant)
|
||||||
*/
|
: undefined!;
|
||||||
const selectedTenant = this.migrationStateModel._accountTenants.find(tenant => tenant.displayName === value);
|
|
||||||
if (selectedTenant) {
|
|
||||||
this.migrationStateModel._azureTenant = utils.deepClone(selectedTenant)!;
|
|
||||||
this.migrationStateModel._azureAccount.properties.tenants = [this.migrationStateModel._azureTenant];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
utils.clearDropDown(this._azureSubscriptionDropdown);
|
||||||
await this.populateSubscriptionDropdown();
|
await this.populateSubscriptionDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -470,12 +467,14 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage {
|
|||||||
this._disposables.push(
|
this._disposables.push(
|
||||||
this._azureSubscriptionDropdown.onValueChanged(async (value) => {
|
this._azureSubscriptionDropdown.onValueChanged(async (value) => {
|
||||||
if (value && value !== 'undefined' && value !== constants.NO_SUBSCRIPTIONS_FOUND) {
|
if (value && value !== 'undefined' && value !== constants.NO_SUBSCRIPTIONS_FOUND) {
|
||||||
const selectedSubscription = this.migrationStateModel._subscriptions.find(subscription => `${subscription.name} - ${subscription.id}` === value);
|
const selectedSubscription = this.migrationStateModel._subscriptions?.find(
|
||||||
|
subscription => `${subscription.name} - ${subscription.id}` === value);
|
||||||
this.migrationStateModel._targetSubscription = (selectedSubscription)
|
this.migrationStateModel._targetSubscription = (selectedSubscription)
|
||||||
? utils.deepClone(selectedSubscription)!
|
? utils.deepClone(selectedSubscription)!
|
||||||
: undefined!;
|
: undefined!;
|
||||||
this.migrationStateModel.refreshDatabaseBackupPage = true;
|
|
||||||
}
|
}
|
||||||
|
this.migrationStateModel.refreshDatabaseBackupPage = true;
|
||||||
|
utils.clearDropDown(this._azureLocationDropdown);
|
||||||
await this.populateLocationDropdown();
|
await this.populateLocationDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -506,6 +505,7 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage {
|
|||||||
: undefined!;
|
: undefined!;
|
||||||
}
|
}
|
||||||
this.migrationStateModel.refreshDatabaseBackupPage = true;
|
this.migrationStateModel.refreshDatabaseBackupPage = true;
|
||||||
|
utils.clearDropDown(this._azureResourceGroupDropdown);
|
||||||
await this.populateResourceGroupDropdown();
|
await this.populateResourceGroupDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -733,6 +733,7 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage {
|
|||||||
? utils.deepClone(selectedResourceGroup)!
|
? utils.deepClone(selectedResourceGroup)!
|
||||||
: undefined!;
|
: undefined!;
|
||||||
}
|
}
|
||||||
|
utils.clearDropDown(this._azureResourceDropdown);
|
||||||
await this.populateResourceInstanceDropdown();
|
await this.populateResourceInstanceDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -778,7 +779,7 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage {
|
|||||||
this.wizard.message = { text: '' };
|
this.wizard.message = { text: '' };
|
||||||
|
|
||||||
// validate power state from VM instance view
|
// validate power state from VM instance view
|
||||||
const runningState = 'PowerState/running'.toLowerCase();
|
const runningState = 'powerstate/running';
|
||||||
if (!this.migrationStateModel._vmInstanceView.statuses.some(status => status.code.toLowerCase() === runningState)) {
|
if (!this.migrationStateModel._vmInstanceView.statuses.some(status => status.code.toLowerCase() === runningState)) {
|
||||||
this.wizard.message = {
|
this.wizard.message = {
|
||||||
text: constants.VM_NOT_READY_POWER_STATE_ERROR(this.migrationStateModel._targetServerInstance.name),
|
text: constants.VM_NOT_READY_POWER_STATE_ERROR(this.migrationStateModel._targetServerInstance.name),
|
||||||
@@ -787,7 +788,7 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate IaaS extension mode
|
// validate IaaS extension mode
|
||||||
const fullMode = 'Full'.toLowerCase();
|
const fullMode = 'full';
|
||||||
if (this.migrationStateModel._targetServerInstance.properties.sqlManagement.toLowerCase() !== fullMode) {
|
if (this.migrationStateModel._targetServerInstance.properties.sqlManagement.toLowerCase() !== fullMode) {
|
||||||
this.wizard.message = {
|
this.wizard.message = {
|
||||||
text: constants.VM_NOT_READY_IAAS_EXTENSION_ERROR(this.migrationStateModel._targetServerInstance.name, this.migrationStateModel._targetServerInstance.properties.sqlManagement),
|
text: constants.VM_NOT_READY_IAAS_EXTENSION_ERROR(this.migrationStateModel._targetServerInstance.name, this.migrationStateModel._targetServerInstance.properties.sqlManagement),
|
||||||
@@ -910,7 +911,10 @@ export class LoginMigrationTargetSelectionPage extends MigrationWizardPage {
|
|||||||
private async populateSubscriptionDropdown(): Promise<void> {
|
private async populateSubscriptionDropdown(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
this._azureSubscriptionDropdown.loading = true;
|
this._azureSubscriptionDropdown.loading = true;
|
||||||
this.migrationStateModel._subscriptions = await utils.getAzureSubscriptions(this.migrationStateModel._azureAccount);
|
this.migrationStateModel._subscriptions = await utils.getAzureSubscriptions(
|
||||||
|
this.migrationStateModel._azureAccount,
|
||||||
|
this.migrationStateModel._azureTenant?.id);
|
||||||
|
|
||||||
this._azureSubscriptionDropdown.values = await utils.getAzureSubscriptionsDropdownValues(this.migrationStateModel._subscriptions);
|
this._azureSubscriptionDropdown.values = await utils.getAzureSubscriptionsDropdownValues(this.migrationStateModel._subscriptions);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
|
|||||||
@@ -267,12 +267,12 @@ export class TargetSelectionPage extends MigrationWizardPage {
|
|||||||
this.migrationStateModel._resourceGroup = undefined!;
|
this.migrationStateModel._resourceGroup = undefined!;
|
||||||
this.migrationStateModel._targetServerInstance = undefined!;
|
this.migrationStateModel._targetServerInstance = undefined!;
|
||||||
|
|
||||||
this._clearDropDown(this._azureAccountsDropdown);
|
utils.clearDropDown(this._azureAccountsDropdown);
|
||||||
this._clearDropDown(this._accountTenantDropdown);
|
utils.clearDropDown(this._accountTenantDropdown);
|
||||||
this._clearDropDown(this._azureSubscriptionDropdown);
|
utils.clearDropDown(this._azureSubscriptionDropdown);
|
||||||
this._clearDropDown(this._azureLocationDropdown);
|
utils.clearDropDown(this._azureLocationDropdown);
|
||||||
this._clearDropDown(this._azureResourceGroupDropdown);
|
utils.clearDropDown(this._azureResourceGroupDropdown);
|
||||||
this._clearDropDown(this._azureResourceDropdown);
|
utils.clearDropDown(this._azureResourceDropdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.populateAzureAccountsDropdown();
|
await this.populateAzureAccountsDropdown();
|
||||||
@@ -314,6 +314,7 @@ export class TargetSelectionPage extends MigrationWizardPage {
|
|||||||
? utils.deepClone(selectedAccount)!
|
? utils.deepClone(selectedAccount)!
|
||||||
: undefined!;
|
: undefined!;
|
||||||
}
|
}
|
||||||
|
utils.clearDropDown(this._accountTenantDropdown);
|
||||||
await this.populateTenantsDropdown();
|
await this.populateTenantsDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -361,16 +362,12 @@ export class TargetSelectionPage extends MigrationWizardPage {
|
|||||||
this._disposables.push(
|
this._disposables.push(
|
||||||
this._accountTenantDropdown.onValueChanged(async (value) => {
|
this._accountTenantDropdown.onValueChanged(async (value) => {
|
||||||
if (value && value !== 'undefined') {
|
if (value && value !== 'undefined') {
|
||||||
/**
|
|
||||||
* Replacing all the tenants in azure account with the tenant user has selected.
|
|
||||||
* All azure requests will only run on this tenant from now on
|
|
||||||
*/
|
|
||||||
const selectedTenant = this.migrationStateModel._accountTenants?.find(tenant => tenant.displayName === value);
|
const selectedTenant = this.migrationStateModel._accountTenants?.find(tenant => tenant.displayName === value);
|
||||||
if (selectedTenant) {
|
this.migrationStateModel._azureTenant = selectedTenant
|
||||||
this.migrationStateModel._azureTenant = utils.deepClone(selectedTenant)!;
|
? utils.deepClone(selectedTenant)
|
||||||
this.migrationStateModel._azureAccount.properties.tenants = [this.migrationStateModel._azureTenant];
|
: undefined!;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
utils.clearDropDown(this._azureSubscriptionDropdown);
|
||||||
await this.populateSubscriptionDropdown();
|
await this.populateSubscriptionDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -411,9 +408,9 @@ export class TargetSelectionPage extends MigrationWizardPage {
|
|||||||
this.migrationStateModel._targetSubscription = (selectedSubscription)
|
this.migrationStateModel._targetSubscription = (selectedSubscription)
|
||||||
? utils.deepClone(selectedSubscription)!
|
? utils.deepClone(selectedSubscription)!
|
||||||
: undefined!;
|
: undefined!;
|
||||||
this.migrationStateModel.refreshDatabaseBackupPage = true;
|
|
||||||
}
|
}
|
||||||
this._clearDropDown(this._azureLocationDropdown);
|
this.migrationStateModel.refreshDatabaseBackupPage = true;
|
||||||
|
utils.clearDropDown(this._azureLocationDropdown);
|
||||||
await this.populateLocationDropdown();
|
await this.populateLocationDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -444,7 +441,7 @@ export class TargetSelectionPage extends MigrationWizardPage {
|
|||||||
: undefined!;
|
: undefined!;
|
||||||
}
|
}
|
||||||
this.migrationStateModel.refreshDatabaseBackupPage = true;
|
this.migrationStateModel.refreshDatabaseBackupPage = true;
|
||||||
this._clearDropDown(this._azureResourceGroupDropdown);
|
utils.clearDropDown(this._azureResourceGroupDropdown);
|
||||||
await this.populateResourceGroupDropdown();
|
await this.populateResourceGroupDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -671,7 +668,7 @@ export class TargetSelectionPage extends MigrationWizardPage {
|
|||||||
? utils.deepClone(selectedResourceGroup)!
|
? utils.deepClone(selectedResourceGroup)!
|
||||||
: undefined!;
|
: undefined!;
|
||||||
}
|
}
|
||||||
this._clearDropDown(this._azureResourceDropdown);
|
utils.clearDropDown(this._azureResourceDropdown);
|
||||||
await this.populateResourceInstanceDropdown();
|
await this.populateResourceInstanceDropdown();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@@ -890,20 +887,21 @@ export class TargetSelectionPage extends MigrationWizardPage {
|
|||||||
private async populateTenantsDropdown(): Promise<void> {
|
private async populateTenantsDropdown(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
this._accountTenantDropdown.loading = true;
|
this._accountTenantDropdown.loading = true;
|
||||||
const tenantId =
|
|
||||||
this.migrationStateModel._azureTenant?.id ??
|
|
||||||
this._serviceContext?.tenant?.id;
|
|
||||||
|
|
||||||
if (!utils.isAccountTokenStale(this.migrationStateModel._azureAccount) &&
|
if (!utils.isAccountTokenStale(this.migrationStateModel._azureAccount) &&
|
||||||
this.migrationStateModel._azureAccount?.properties?.tenants?.length > 0) {
|
this.migrationStateModel._azureAccount?.properties?.tenants?.length > 0) {
|
||||||
this.migrationStateModel._accountTenants = utils.getAzureTenants(this.migrationStateModel._azureAccount);
|
this.migrationStateModel._accountTenants = utils.getAzureTenants(
|
||||||
this._accountTenantDropdown.values = utils.getAzureTenantsDropdownValues(this.migrationStateModel._accountTenants);
|
this.migrationStateModel._azureAccount);
|
||||||
}
|
|
||||||
|
|
||||||
utils.selectDefaultDropdownValue(
|
const tenantId = this.migrationStateModel._azureTenant?.id;
|
||||||
this._accountTenantDropdown,
|
|
||||||
tenantId,
|
this._accountTenantDropdown.values = utils.getAzureTenantsDropdownValues(this.migrationStateModel._accountTenants);
|
||||||
true);
|
|
||||||
|
utils.selectDefaultDropdownValue(
|
||||||
|
this._accountTenantDropdown,
|
||||||
|
tenantId,
|
||||||
|
true);
|
||||||
|
}
|
||||||
await this._azureAccountsDropdown.validate();
|
await this._azureAccountsDropdown.validate();
|
||||||
} finally {
|
} finally {
|
||||||
this._accountTenantDropdown.loading = false;
|
this._accountTenantDropdown.loading = false;
|
||||||
@@ -918,7 +916,9 @@ export class TargetSelectionPage extends MigrationWizardPage {
|
|||||||
private async populateSubscriptionDropdown(): Promise<void> {
|
private async populateSubscriptionDropdown(): Promise<void> {
|
||||||
try {
|
try {
|
||||||
this._azureSubscriptionDropdown.loading = true;
|
this._azureSubscriptionDropdown.loading = true;
|
||||||
this.migrationStateModel._subscriptions = await utils.getAzureSubscriptions(this.migrationStateModel._azureAccount);
|
this.migrationStateModel._subscriptions = await utils.getAzureSubscriptions(
|
||||||
|
this.migrationStateModel._azureAccount,
|
||||||
|
this.migrationStateModel._azureTenant?.id);
|
||||||
const subscriptionId =
|
const subscriptionId =
|
||||||
this.migrationStateModel._targetSubscription?.id ??
|
this.migrationStateModel._targetSubscription?.id ??
|
||||||
this._serviceContext?.subscription?.id;
|
this._serviceContext?.subscription?.id;
|
||||||
@@ -1206,9 +1206,4 @@ export class TargetSelectionPage extends MigrationWizardPage {
|
|||||||
targetDatabaseCollation.length > 0 &&
|
targetDatabaseCollation.length > 0 &&
|
||||||
sourceDatabaseCollation.toLocaleLowerCase() === targetDatabaseCollation.toLocaleLowerCase();
|
sourceDatabaseCollation.toLocaleLowerCase() === targetDatabaseCollation.toLocaleLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
private _clearDropDown(dropDown: azdata.DropDownComponent): void {
|
|
||||||
dropDown.values = [];
|
|
||||||
dropDown.value = undefined;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user