diff --git a/extensions/sql-migration/package.json b/extensions/sql-migration/package.json index 6b180e4ad6..4f7ce9ede6 100644 --- a/extensions/sql-migration/package.json +++ b/extensions/sql-migration/package.json @@ -10,7 +10,7 @@ "aiKey": "AIF-37eefaf0-8022-4671-a3fb-64752724682e", "engines": { "vscode": "*", - "azdata": ">=1.29.0" + "azdata": ">=1.33.0" }, "activationEvents": [ "onDashboardOpen", diff --git a/extensions/sql-migration/src/api/azure.ts b/extensions/sql-migration/src/api/azure.ts index 9d98a8eebb..30ce4ab993 100644 --- a/extensions/sql-migration/src/api/azure.ts +++ b/extensions/sql-migration/src/api/azure.ts @@ -51,7 +51,7 @@ export type AzureProduct = azureResource.AzureGraphResource; export async function getResourceGroups(account: azdata.Account, subscription: Subscription): Promise { const api = await getAzureCoreAPI(); - const result = await api.getResourceGroups(account, subscription, false); + const result = await api.getResourceGroups(account, subscription, true); sortResourceArrayByName(result.resourceGroups); return result.resourceGroups; } diff --git a/extensions/sql-migration/src/constants/strings.ts b/extensions/sql-migration/src/constants/strings.ts index d2d8343509..47f48d64e6 100644 --- a/extensions/sql-migration/src/constants/strings.ts +++ b/extensions/sql-migration/src/constants/strings.ts @@ -92,10 +92,19 @@ export function accountLinkedMessage(count: number): string { } 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}' is no longer valid. Select 'Link account' and refresh the account, or select a different account.", `${account.displayInfo.displayName} (${account.displayInfo.userId})`); + 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}'. Select 'Link account' and refresh the account, or select a different account. Error '{1}'", `${account.displayInfo.displayName} (${account.displayInfo.userId})`, error.message); + 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); } // database backup page diff --git a/extensions/sql-migration/src/wizard/accountsSelectionPage.ts b/extensions/sql-migration/src/wizard/accountsSelectionPage.ts index e1d98d7c24..95266caf8b 100644 --- a/extensions/sql-migration/src/wizard/accountsSelectionPage.ts +++ b/extensions/sql-migration/src/wizard/accountsSelectionPage.ts @@ -82,6 +82,7 @@ export class AccountsSelectionPage extends MigrationWizardPage { } if (this.migrationStateModel._azureAccount?.isStale) { this.wizard.message = { + level: azdata.window.MessageLevel.Error, text: constants.ACCOUNT_STALE_ERROR(this.migrationStateModel._azureAccount) }; return false; @@ -193,8 +194,6 @@ export class AccountsSelectionPage extends MigrationWizardPage { this.migrationStateModel._targetSubscription = undefined!; this.migrationStateModel._databaseBackup.subscription = undefined!; } - const selectedAzureAccount = this.migrationStateModel.getAccount(selectedIndex); - this.migrationStateModel._azureAccount = deepClone(selectedAzureAccount); })); @@ -233,16 +232,24 @@ export class AccountsSelectionPage extends MigrationWizardPage { public async onPageEnter(pageChangeInfo: azdata.window.WizardPageChangeInfo): Promise { this.wizard.registerNavigationValidator(async pageChangeInfo => { try { - if (!this.migrationStateModel._azureAccount?.isStale) { + this.wizard.message = { text: '', }; + + if (this.migrationStateModel._azureAccount && !this.migrationStateModel._azureAccount?.isStale) { const subscriptions = await getSubscriptions(this.migrationStateModel._azureAccount); if (subscriptions?.length > 0) { return true; } } - this.wizard.message = { text: constants.ACCOUNT_STALE_ERROR(this.migrationStateModel._azureAccount) }; + this.wizard.message = { + level: azdata.window.MessageLevel.Error, + text: constants.ACCOUNT_STALE_ERROR(this.migrationStateModel._azureAccount), + }; } catch (error) { - this.wizard.message = { text: constants.ACCOUNT_ACCESS_ERROR(this.migrationStateModel._azureAccount, error) }; + this.wizard.message = { + level: azdata.window.MessageLevel.Error, + text: constants.ACCOUNT_ACCESS_ERROR(this.migrationStateModel._azureAccount, error), + }; } return false;