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:
Amir Omidi
2020-05-29 19:59:29 -07:00
committed by GitHub
parent b2e0291a95
commit 7d31239e64
28 changed files with 146 additions and 31 deletions

View File

@@ -24,6 +24,7 @@ export namespace azureResource {
export interface AzureResource {
name: string;
id: string;
tenant?: string;
}
export interface AzureResourceSubscription extends AzureResource {

View File

@@ -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));
});
}

View File

@@ -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
});
}
}

View File

@@ -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

View File

@@ -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
};
}
}

View File

@@ -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

View File

@@ -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
};
}
}

View File

@@ -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

View File

@@ -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
};
}
}

View File

@@ -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

View File

@@ -58,6 +58,7 @@ export abstract class ResourceTreeDataProviderBase<T extends azureResource.Azure
}
export interface GraphData {
tenantId: string;
id: string;
name: string;
location: string;

View File

@@ -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
};
}
}

View File

@@ -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

View File

@@ -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
};
}
}

View File

@@ -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