diff --git a/src/sql/workbench/services/connection/browser/connectionController.ts b/src/sql/workbench/services/connection/browser/connectionController.ts index 5162c9dae8..669e353afd 100644 --- a/src/sql/workbench/services/connection/browser/connectionController.ts +++ b/src/sql/workbench/services/connection/browser/connectionController.ts @@ -51,7 +51,8 @@ export class ConnectionController implements IConnectionComponentController { onFetchDatabases: (serverName: string, authenticationType: string, userName?: string, password?: string) => this.onFetchDatabases( serverName, authenticationType, userName, password).then(result => { return result; - }) + }), + onAzureTenantSelection: (azureTenantId?: string) => this.onAzureTenantSelection(azureTenantId), }, providerName); this._providerName = providerName; } @@ -104,6 +105,20 @@ export class ConnectionController implements IConnectionComponentController { } } + protected onAzureTenantSelection(azureTenantId?: string): void { + if (this._model.options.azureAccountToken !== undefined) { + this._model.options.azureAccountToken = undefined; + } + + if (this._model.azureTenantId !== azureTenantId) { + this._model.azureTenantId = azureTenantId; + } + + if (this._model.options.azureTenantId !== azureTenantId) { + this._model.azureTenantId = azureTenantId; + } + } + protected handleOnAdvancedProperties(): void { if (!this._advancedController) { this._advancedController = this._instantiationService.createInstance(AdvancedPropertiesController, () => this._connectionWidget.focusOnAdvancedButton()); diff --git a/src/sql/workbench/services/connection/browser/connectionDialogService.ts b/src/sql/workbench/services/connection/browser/connectionDialogService.ts index ee9ce2b489..540477a66e 100644 --- a/src/sql/workbench/services/connection/browser/connectionDialogService.ts +++ b/src/sql/workbench/services/connection/browser/connectionDialogService.ts @@ -43,6 +43,7 @@ export interface IConnectionComponentCallbacks { onAdvancedProperties?: () => void; onSetAzureTimeOut?: () => void; onFetchDatabases?: (serverName: string, authenticationType: string, userName?: string, password?: string) => Promise; + onAzureTenantSelection?: (azureTenantId?: string) => void; } export interface IConnectionComponentController { diff --git a/src/sql/workbench/services/connection/browser/connectionWidget.ts b/src/sql/workbench/services/connection/browser/connectionWidget.ts index 615b839433..a4c1c06e2f 100644 --- a/src/sql/workbench/services/connection/browser/connectionWidget.ts +++ b/src/sql/workbench/services/connection/browser/connectionWidget.ts @@ -587,6 +587,7 @@ export class ConnectionWidget extends lifecycle.Disposable { let tenant = account.properties.tenants[tenantIndex]; if (tenant) { this._azureTenantId = tenant.id; + this._callbacks.onAzureTenantSelection(tenant.id); } } }