mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-19 01:25:36 -05:00
Fix connection issue with wrong resource endpoint (#19387)
* Fix connection bug accessing PBI resource * Address CR feedback * Fix null check
This commit is contained in:
6
src/sql/azdata.d.ts
vendored
6
src/sql/azdata.d.ts
vendored
@@ -2354,7 +2354,11 @@ declare module 'azdata' {
|
||||
/**
|
||||
* Kusto
|
||||
*/
|
||||
AzureKusto = 10
|
||||
AzureKusto = 10,
|
||||
/**
|
||||
* Power BI
|
||||
*/
|
||||
PowerBi = 11
|
||||
}
|
||||
|
||||
export interface DidChangeAccountsParams {
|
||||
|
||||
@@ -443,7 +443,8 @@ export enum AzureResource {
|
||||
MsGraph = 7,
|
||||
AzureLogAnalytics = 8,
|
||||
AzureStorage = 9,
|
||||
AzureKusto = 10
|
||||
AzureKusto = 10,
|
||||
PowerBi = 11
|
||||
}
|
||||
|
||||
export class TreeItem extends vsExtTypes.TreeItem {
|
||||
|
||||
@@ -809,15 +809,45 @@ export class ConnectionManagementService extends Disposable implements IConnecti
|
||||
* @param connection The connection to fill in or update
|
||||
*/
|
||||
private getAzureResourceForConnection(connection: interfaces.IConnectionProfile): azdata.AzureResource {
|
||||
// check if this is a PowerBI connection which is determined based on connection domain address
|
||||
if (this.isPowerBiConnection(connection)) {
|
||||
return AzureResource.PowerBi;
|
||||
}
|
||||
|
||||
// default to SQL if there are no provides or registered resources
|
||||
let provider = this._providers.get(connection.providerName);
|
||||
if (!provider || !provider.properties || !provider.properties.azureResource) {
|
||||
this._logService.warn('Connection providers incorrectly registered. Defaulting to SQL Azure resource,');
|
||||
return AzureResource.Sql;
|
||||
}
|
||||
|
||||
// lookup the Azure resource based on the provider azureResource properties
|
||||
let result = ConnectionManagementService._azureResources.find(r => AzureResource[r] === provider.properties.azureResource);
|
||||
return result ? result : AzureResource.Sql;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if a connection is to PowerBI based on the servers domain name.
|
||||
* PowerBi servers will be in one of the hard-coded domains listed in this method, based on the
|
||||
* Azure cloud being used. This method can be removed once the connection/AAD service is updated
|
||||
* to parse the server endpoint using TDS prior to connecting. But that will need to be part of a
|
||||
* larger refactoring of the connection & auth functionality.
|
||||
* @param connection The connection profile that is to be checked.
|
||||
*/
|
||||
private isPowerBiConnection(connection: interfaces.IConnectionProfile): boolean {
|
||||
if (!connection || !connection.serverName || connection.serverName.length === 0) {
|
||||
return false;
|
||||
}
|
||||
let powerBiDomains = [
|
||||
'pbidedicated.windows.net',
|
||||
'pbidedicated.cloudapi.de',
|
||||
'pbidedicated.usgovcloudapi.net',
|
||||
'pbidedicated.chinacloudapi.cn'
|
||||
];
|
||||
let serverName = connection.serverName.toLowerCase();
|
||||
return !!powerBiDomains.find(d => serverName.indexOf(d) >= 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills in the account token if it's needed for this connection and doesn't already have one
|
||||
* and clears it if it isn't.
|
||||
|
||||
Reference in New Issue
Block a user