mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Open in azure portal (#10535)
* initial commit to get it working * Change configuration to use package.nls.json * Make the necessary plumbing * Support multi cloud * Move the menu item to the bottom * Fix failing tests * Fix the tests
This commit is contained in:
@@ -24,6 +24,7 @@ export namespace azureResource {
|
||||
export interface AzureResource {
|
||||
name: string;
|
||||
id: string;
|
||||
tenant?: string;
|
||||
}
|
||||
|
||||
export interface AzureResourceSubscription extends AzureResource {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
import { window, QuickPickItem } from 'vscode';
|
||||
import { window, QuickPickItem, env, Uri } from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import { TokenCredentials } from '@azure/ms-rest-js';
|
||||
import * as nls from 'vscode-nls';
|
||||
@@ -237,4 +237,23 @@ export function registerAzureResourceCommands(appContext: AppContext, tree: Azur
|
||||
appContext.apiWrapper.executeCommand('workbench.view.connections');
|
||||
}
|
||||
});
|
||||
|
||||
appContext.apiWrapper.registerCommand('azure.resource.openInAzurePortal', async (node?: TreeNode) => {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
||||
const treeItem: azdata.TreeItem = await node.getTreeItem();
|
||||
if (!treeItem.payload) {
|
||||
return;
|
||||
}
|
||||
let connectionProfile = Object.assign({}, treeItem.payload, { saveProfile: true });
|
||||
|
||||
if (!connectionProfile.azureResourceId) {
|
||||
return;
|
||||
}
|
||||
|
||||
const urlToOpen = `${connectionProfile.azurePortalEndpoint}//${connectionProfile.azureTenantId}/#resource/${connectionProfile.azureResourceId}`;
|
||||
env.openExternal(Uri.parse(urlToOpen));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -50,7 +50,8 @@ export class AzureResourceDatabaseService implements IAzureResourceService<azure
|
||||
id: db.id,
|
||||
serverName: server.name,
|
||||
serverFullName: server.properties.fullyQualifiedDomainName,
|
||||
loginName: server.properties.administratorLogin
|
||||
loginName: server.properties.administratorLogin,
|
||||
tenant: db.tenantId
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,10 @@ export class AzureResourceDatabaseTreeDataProvider extends ResourceTreeDataProvi
|
||||
providerName: 'MSSQL',
|
||||
saveProfile: false,
|
||||
options: {},
|
||||
azureAccount: account.key.accountId
|
||||
azureAccount: account.key.accountId,
|
||||
azureResourceId: database.id,
|
||||
azureTenantId: database.tenant,
|
||||
azurePortalEndpoint: account.properties.providerSettings.settings.portalEndpoint
|
||||
},
|
||||
childProvider: 'MSSQL',
|
||||
type: ExtensionNodeType.Database
|
||||
|
||||
@@ -29,7 +29,8 @@ export class AzureResourceDatabaseServerService extends ResourceServiceBase<DbSe
|
||||
name: resource.name,
|
||||
fullName: resource.properties.fullyQualifiedDomainName,
|
||||
loginName: resource.properties.administratorLogin,
|
||||
defaultDatabaseName: 'master'
|
||||
defaultDatabaseName: 'master',
|
||||
tenant: resource.tenantId
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,10 @@ export class AzureResourceDatabaseServerTreeDataProvider extends ResourceTreeDat
|
||||
providerName: 'MSSQL',
|
||||
saveProfile: false,
|
||||
options: {},
|
||||
azureAccount: account.key.accountId
|
||||
azureAccount: account.key.accountId,
|
||||
azureTenantId: databaseServer.tenant,
|
||||
azureResourceId: databaseServer.id,
|
||||
azurePortalEndpoint: account.properties.providerSettings.settings.portalEndpoint
|
||||
},
|
||||
childProvider: 'MSSQL',
|
||||
type: ExtensionNodeType.Server
|
||||
|
||||
@@ -26,7 +26,8 @@ export class PostgresServerArcService extends ResourceServiceBase<PostgresArcSer
|
||||
name: resource.name,
|
||||
fullName: resource.name,
|
||||
loginName: resource.properties.admin,
|
||||
defaultDatabaseName: 'postgres'
|
||||
defaultDatabaseName: 'postgres',
|
||||
tenant: resource.tenantId
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,10 @@ export class PostgresServerArcTreeDataProvider extends ResourceTreeDataProviderB
|
||||
// Set default for SSL or will get error complaining about it not being set correctly
|
||||
'sslmode': 'require'
|
||||
},
|
||||
azureAccount: account.key.accountId
|
||||
azureAccount: account.key.accountId,
|
||||
azureTenantId: databaseServer.tenant,
|
||||
azureResourceId: databaseServer.id,
|
||||
azurePortalEndpoint: account.properties.providerSettings.settings.portalEndpoint
|
||||
},
|
||||
childProvider: 'PGSQL',
|
||||
type: ExtensionNodeType.Server
|
||||
|
||||
@@ -29,7 +29,8 @@ export class PostgresServerService extends ResourceServiceBase<DbServerGraphData
|
||||
name: resource.name,
|
||||
fullName: resource.properties.fullyQualifiedDomainName,
|
||||
loginName: resource.properties.administratorLogin,
|
||||
defaultDatabaseName: 'postgres'
|
||||
defaultDatabaseName: 'postgres',
|
||||
tenant: resource.tenantId
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,10 @@ export class PostgresServerTreeDataProvider extends ResourceTreeDataProviderBase
|
||||
// Set default for SSL or will get error complaining about it not being set correctly
|
||||
'sslmode': 'require'
|
||||
},
|
||||
azureAccount: account.key.accountId
|
||||
azureAccount: account.key.accountId,
|
||||
azureTenantId: databaseServer.tenant,
|
||||
azureResourceId: databaseServer.id,
|
||||
azurePortalEndpoint: account.properties.providerSettings.settings.portalEndpoint
|
||||
},
|
||||
childProvider: 'PGSQL',
|
||||
type: ExtensionNodeType.Server
|
||||
|
||||
@@ -58,6 +58,7 @@ export abstract class ResourceTreeDataProviderBase<T extends azureResource.Azure
|
||||
}
|
||||
|
||||
export interface GraphData {
|
||||
tenantId: string;
|
||||
id: string;
|
||||
name: string;
|
||||
location: string;
|
||||
|
||||
@@ -27,7 +27,8 @@ export class SqlInstanceResourceService extends ResourceServiceBase<SqlInstanceG
|
||||
name: resource.name,
|
||||
fullName: resource.properties.fullyQualifiedDomainName,
|
||||
loginName: resource.properties.administratorLogin,
|
||||
defaultDatabaseName: 'master'
|
||||
defaultDatabaseName: 'master',
|
||||
tenant: resource.tenantId
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,10 @@ export class SqlInstanceTreeDataProvider extends ResourceTreeDataProviderBase<az
|
||||
providerName: 'MSSQL',
|
||||
saveProfile: false,
|
||||
options: {},
|
||||
azureAccount: account.key.accountId
|
||||
azureAccount: account.key.accountId,
|
||||
azureTenantId: databaseServer.tenant,
|
||||
azureResourceId: databaseServer.id,
|
||||
azurePortalEndpoint: account.properties.providerSettings.settings.portalEndpoint
|
||||
},
|
||||
childProvider: 'MSSQL',
|
||||
type: ExtensionNodeType.Server
|
||||
|
||||
@@ -26,7 +26,8 @@ export class SqlInstanceArcResourceService extends ResourceServiceBase<SqlInstan
|
||||
name: resource.name,
|
||||
fullName: resource.name,
|
||||
loginName: resource.properties.admin,
|
||||
defaultDatabaseName: 'master'
|
||||
defaultDatabaseName: 'master',
|
||||
tenant: resource.tenantId
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,10 @@ export class SqlInstanceArcTreeDataProvider extends ResourceTreeDataProviderBase
|
||||
providerName: 'MSSQL',
|
||||
saveProfile: false,
|
||||
options: {},
|
||||
azureAccount: account.key.accountId
|
||||
azureAccount: account.key.accountId,
|
||||
azureTenantId: databaseServer.tenant,
|
||||
azureResourceId: databaseServer.id,
|
||||
azurePortalEndpoint: account.properties.providerSettings.settings.portalEndpoint
|
||||
},
|
||||
childProvider: 'MSSQL',
|
||||
type: ExtensionNodeType.Server
|
||||
|
||||
Reference in New Issue
Block a user