mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 18:46:43 -05:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2299a76973 | ||
|
|
85bb8e3948 | ||
|
|
71c8849199 | ||
|
|
201e53d091 | ||
|
|
99b40b448a | ||
|
|
b77aa3dc77 |
@@ -81,6 +81,10 @@ export abstract class AzureAuth implements vscode.Disposable {
|
||||
this.resources = this.resources.concat(this.metadata.settings.azureKustoResource);
|
||||
}
|
||||
|
||||
if (this.metadata.settings.powerBiResource) {
|
||||
this.resources = this.resources.concat(this.metadata.settings.powerBiResource);
|
||||
}
|
||||
|
||||
this.scopes = [...this.metadata.settings.scopes];
|
||||
this.scopesString = this.scopes.join(' ');
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ const enum SettingIds {
|
||||
ado = 'ado',
|
||||
ala = 'ala',
|
||||
storage = 'storage',
|
||||
kusto = 'kusto'
|
||||
kusto = 'kusto',
|
||||
powerbi = 'powerbi'
|
||||
}
|
||||
|
||||
const publicAzureSettings: ProviderSettings = {
|
||||
@@ -87,6 +88,11 @@ const publicAzureSettings: ProviderSettings = {
|
||||
endpoint: 'https://kusto.kusto.windows.net',
|
||||
azureResourceId: AzureResource.AzureKusto,
|
||||
},
|
||||
powerBiResource: {
|
||||
id: SettingIds.powerbi,
|
||||
endpoint: 'https://analysis.windows.net/powerbi/api',
|
||||
azureResourceId: AzureResource.PowerBi
|
||||
},
|
||||
redirectUri: 'https://vscode-redirect.azurewebsites.net/',
|
||||
scopes: [
|
||||
'openid', 'email', 'profile', 'offline_access',
|
||||
@@ -147,6 +153,11 @@ const usGovAzureSettings: ProviderSettings = {
|
||||
endpointSuffix: '.core.usgovcloudapi.net',
|
||||
azureResourceId: AzureResource.AzureStorage
|
||||
},
|
||||
powerBiResource: {
|
||||
id: SettingIds.powerbi,
|
||||
endpoint: 'https://analysis.windows.net/powerbi/api',
|
||||
azureResourceId: AzureResource.PowerBi
|
||||
},
|
||||
redirectUri: 'https://vscode-redirect.azurewebsites.net/',
|
||||
scopes: [
|
||||
'openid', 'email', 'profile', 'offline_access',
|
||||
@@ -251,6 +262,11 @@ const germanyAzureSettings: ProviderSettings = {
|
||||
endpointSuffix: '.core.cloudapi.de',
|
||||
azureResourceId: AzureResource.AzureStorage
|
||||
},
|
||||
powerBiResource: {
|
||||
id: SettingIds.powerbi,
|
||||
endpoint: 'https://analysis.windows.net/powerbi/api',
|
||||
azureResourceId: AzureResource.PowerBi
|
||||
},
|
||||
redirectUri: 'https://vscode-redirect.azurewebsites.net/',
|
||||
scopes: [
|
||||
'openid', 'email', 'profile', 'offline_access',
|
||||
@@ -310,6 +326,11 @@ const chinaAzureSettings: ProviderSettings = {
|
||||
endpointSuffix: '.core.chinacloudapi.cn',
|
||||
azureResourceId: AzureResource.AzureStorage
|
||||
},
|
||||
powerBiResource: {
|
||||
id: SettingIds.powerbi,
|
||||
endpoint: 'https://analysis.windows.net/powerbi/api',
|
||||
azureResourceId: AzureResource.PowerBi
|
||||
},
|
||||
redirectUri: 'https://vscode-redirect.azurewebsites.net/',
|
||||
scopes: [
|
||||
'openid', 'email', 'profile', 'offline_access',
|
||||
|
||||
7
extensions/azurecore/src/azurecore.d.ts
vendored
7
extensions/azurecore/src/azurecore.d.ts
vendored
@@ -129,10 +129,15 @@ declare module 'azurecore' {
|
||||
azureLogAnalyticsResource?: Resource;
|
||||
|
||||
/**
|
||||
* Information that describes the Azure Storage resourceI
|
||||
* Information that describes the Azure Storage resource
|
||||
*/
|
||||
azureStorageResource?: Resource;
|
||||
|
||||
/**
|
||||
* Information that describes the Power BI resource
|
||||
*/
|
||||
powerBiResource?: Resource;
|
||||
|
||||
/**
|
||||
* A list of tenant IDs to authenticate against. If defined, then these IDs will be used
|
||||
* instead of querying the tenants endpoint of the armResource
|
||||
|
||||
@@ -23,11 +23,13 @@ export class MockVscodeMssqlIExtension implements vscodeMssql.IExtension {
|
||||
dacFx: vscodeMssql.IDacFxService;
|
||||
schemaCompare: vscodeMssql.ISchemaCompareService;
|
||||
azureAccountService: vscodeMssql.IAzureAccountService;
|
||||
azureResourceService: vscodeMssql.IAzureResourceService;
|
||||
|
||||
constructor() {
|
||||
this.dacFx = TypeMoq.Mock.ofType<vscodeMssql.IDacFxService>().object;
|
||||
this.schemaCompare = TypeMoq.Mock.ofType<vscodeMssql.ISchemaCompareService>().object;
|
||||
this.azureAccountService = TypeMoq.Mock.ofType<vscodeMssql.IAzureAccountService>().object;
|
||||
this.azureResourceService = TypeMoq.Mock.ofType<vscodeMssql.IAzureResourceService>().object;
|
||||
}
|
||||
|
||||
promptForFirewallRule(_: string, __: vscodeMssql.IConnectionInfo): Promise<boolean> {
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"name": "sql-database-projects",
|
||||
"displayName": "SQL Database Projects",
|
||||
"description": "Enables users to develop and publish database schemas for MSSQL Databases",
|
||||
"version": "0.16.1",
|
||||
"version": "0.16.2",
|
||||
"publisher": "Microsoft",
|
||||
"preview": true,
|
||||
"engines": {
|
||||
@@ -456,6 +456,7 @@
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"axios": "^0.27.2",
|
||||
"@microsoft/ads-extension-telemetry": "^1.1.5",
|
||||
"fast-glob": "^3.2.7",
|
||||
"fs-extra": "^5.0.0",
|
||||
@@ -464,7 +465,7 @@
|
||||
"vscode-languageclient": "^5.3.0-next.1",
|
||||
"vscode-nls": "^4.1.2",
|
||||
"which": "^2.0.2",
|
||||
"xml-formatter": "^2.1.0",
|
||||
"xml-formatter": "2.1.0",
|
||||
"xmldom": "^0.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -149,9 +149,22 @@ export const nameMustNotBeEmpty = localize('nameMustNotBeEmpty', "Name must not
|
||||
// Deploy
|
||||
export const SqlServerName = 'SQL server';
|
||||
export const AzureSqlServerName = 'Azure SQL server';
|
||||
export const SqlServerDockerImageName = 'Microsoft SQL Server';
|
||||
export const AzureSqlDbFullDockerImageName = 'Azure SQL Database emulator Full';
|
||||
export const AzureSqlDbLiteDockerImageName = 'Azure SQL Database emulator Lite';
|
||||
export const AzureSqlLogicalServerName = 'Azure SQL logical server';
|
||||
export const selectPublishOption = localize('selectPublishOption', "Select where to publish the project to");
|
||||
export const defaultQuickPickItem = localize('defaultQuickPickItem', "Default - image defined as default in the container registry");
|
||||
export function dockerImagesPlaceHolder(name: string) { return localize('dockerImagesPlaceHolder', 'Use {0} on local arm64/Apple Silicon', name); }
|
||||
export function publishToExistingServer(name: string) { return localize('publishToExistingServer', "Publish to an existing {0}", name); }
|
||||
export function publishToDockerContainer(name: string) { return localize('publishToDockerContainer', "Publish to new {0} local development container", name); }
|
||||
export const publishToAzureEmulator = localize('publishToAzureEmulator', "Publish to new Azure SQL Database emulator");
|
||||
export const publishToNewAzureServer = localize('publishToNewAzureServer', "Publish to new Azure SQL logical server");
|
||||
export const azureServerName = localize('azureServerName', "Azure SQL server name");
|
||||
export const azureSubscription = localize('azureSubscription', "Azure subscription");
|
||||
export const resourceGroup = localize('resourceGroup', "Resource group");
|
||||
export const azureLocation = localize('location', "Location");
|
||||
export const azureAccounts = localize('azureAccounts', "Azure accounts");
|
||||
export function enterPortNumber(name: string) { return localize('enterPortNumber', "Enter {0} port number or press enter to use the default value", name); }
|
||||
export function serverPortNumber(name: string) { return localize('serverPortNumber', "{0} port number", name); }
|
||||
export function serverPassword(name: string) { return localize('serverPassword', "{0} admin password", name); }
|
||||
@@ -160,15 +173,18 @@ export function baseDockerImage(name: string) { return localize('baseDockerImage
|
||||
export const publishTo = localize('publishTo', "Publish Target");
|
||||
export const enterConnectionStringEnvName = localize('enterConnectionStringEnvName', "Enter connection string environment variable name");
|
||||
export const enterConnectionStringTemplate = localize('enterConnectionStringTemplate', "Enter connection string template");
|
||||
export function enterUser(name: string) { return localize('enterUser', "Enter {0} admin user name", name); }
|
||||
export function enterPassword(name: string) { return localize('enterPassword', "Enter {0} admin password", name); }
|
||||
export function confirmPassword(name: string) { return localize('confirmPassword', "Confirm {0} admin password", name); }
|
||||
export function selectBaseImage(name: string) { return localize('selectBaseImage', "Select the base {0} docker image", name); }
|
||||
export function selectImageTag(name: string) { return localize('selectImageTag', "Select the image tag or press enter to use the default value", name); }
|
||||
export function invalidSQLPasswordMessage(name: string) { return localize('invalidSQLPassword', "{0} password doesn't meet the password complexity requirement. For more information see https://docs.microsoft.com/sql/relational-databases/security/password-policy", name); }
|
||||
export function passwordNotMatch(name: string) { return localize('passwordNotMatch', "{0} password doesn't match the confirmation password", name); }
|
||||
export const portMustBeNumber = localize('portMustNotBeNumber', "Port must a be number");
|
||||
export const valueCannotBeEmpty = localize('valueCannotBeEmpty', "Value cannot be empty");
|
||||
export const dockerImageLabelPrefix = 'source=sqldbproject';
|
||||
export const dockerImageNamePrefix = 'sqldbproject';
|
||||
export const dockerImageDefaultTag = 'latest';
|
||||
|
||||
// Publish to Container
|
||||
export const eulaAgreementTemplate = localize({ key: 'eulaAgreementTemplate', comment: ['The placeholders are contents of the line and should not be translated.'] }, "I accept the {0}.");
|
||||
@@ -205,12 +221,16 @@ export const runningDockerMessage = localize('runningDockerMessage', "Running th
|
||||
export function dockerNotRunningError(error: string) { return localize('dockerNotRunningError', "Failed to verify docker. Please make sure docker is installed and running. Error: '{0}'", error || ''); }
|
||||
export const dockerContainerNotRunningErrorMessage = localize('dockerContainerNotRunningErrorMessage', "Docker container is not running");
|
||||
export const dockerContainerFailedToRunErrorMessage = localize('dockerContainerFailedToRunErrorMessage', "Failed to run the docker container");
|
||||
export const connectingToSqlServerMessage = localize('connectingToSqlServerOnDockerMessage', "Connecting to SQL Server");
|
||||
export const connectingToSqlServerMessage = localize('connectingToSqlServerMessage', "Connecting to SQL Server");
|
||||
export const serverCreated = localize('serverCreated', "Server created");
|
||||
export const deployProjectFailedMessage = localize('deployProjectFailedMessage', "Failed to open a connection to the deployed database'");
|
||||
export const containerAlreadyExistForProject = localize('containerAlreadyExistForProject', "Containers already exist for this project. Do you want to delete them before deploying a new one?");
|
||||
export const checkoutOutputMessage = localize('checkoutOutputMessage', "Check output pane for more details");
|
||||
export function creatingAzureSqlServer(name: string): string { return localize('creatingAzureSqlServer', "Creating Azure SQL Server '{0}' ...", name); }
|
||||
export function azureSqlServerCreated(name: string): string { return localize('azureSqlServerCreated', "Azure SQL Server '{0}' created", name); }
|
||||
export function taskFailedError(taskName: string, err: string): string { return localize('taskFailedError.error', "Failed to complete task '{0}'. Error: {1}", taskName, err); }
|
||||
export function publishToContainerFailed(errorMessage: string) { return localize('publishToContainerFailed', "Failed to publish to container. {0}", errorMessage); }
|
||||
export function publishToNewAzureServerFailed(errorMessage: string) { return localize('publishToNewAzureServerFailed', "Failed to publish to new Azure SQL server. {0}", errorMessage); }
|
||||
export function deployAppSettingUpdateFailed(appSetting: string) { return localize('deployAppSettingUpdateFailed', "Failed to update app setting '{0}'", appSetting); }
|
||||
export function deployAppSettingUpdating(appSetting: string) { return localize('deployAppSettingUpdating', "Updating app setting: '{0}'", appSetting); }
|
||||
export function connectionFailedError(error: string) { return localize('connectionFailedError', "Connection failed error: '{0}'", error); }
|
||||
@@ -220,7 +240,7 @@ export function retryWaitMessage(numberOfSeconds: number, name: string) { return
|
||||
export function retryRunMessage(attemptNumber: number, numberOfAttempts: number, name: string) { return localize('retryRunMessage', "Running operation '{2}' Attempt {0} of {1}", attemptNumber, numberOfAttempts, name); }
|
||||
export function retrySucceedMessage(name: string, result: string) { return localize('retrySucceedMessage', "Operation '{0}' completed successfully. Result: {1}", name, result); }
|
||||
export function retryFailedMessage(name: string, result: string, error: string) { return localize('retryFailedMessage', "Operation '{0}' failed. Re-trying... Current Result: {1}. Error: '{2}'", name, result, error); }
|
||||
export function retryMessage(name: string, error: string) { return localize('retryMessage', "Operation '{0}' failed. Re-trying... Error: '{1}'", name, error || ''); }
|
||||
export function retryMessage(name: string, error: string) { return localize('retryMessage', "Operation '{0}' failed. Re-trying... Error: '{1}' ", name, error); }
|
||||
|
||||
// Add Database Reference dialog strings
|
||||
|
||||
@@ -269,6 +289,8 @@ export const WorkspaceFileExtension = '.code-workspace';
|
||||
export const browseEllipsisWithIcon = `$(folder) ${localize('browseEllipsis', "Browse...")}`;
|
||||
export const selectProjectLocation = localize('selectProjectLocation', "Select project location");
|
||||
export const sdkStyleProject = localize('sdkStyleProject', 'SDK-style project (Preview)');
|
||||
export const YesRecommended = localize('yesRecommended', "Yes (Recommended)");
|
||||
export const SdkLearnMorePlaceholder = localize('sdkLearnMorePlaceholder', "Click \"Learn More\" button for more information about SDK-style projects");
|
||||
export const ProjectParentDirectoryNotExistError = (location: string): string => { return localize('dataworkspace.projectParentDirectoryNotExistError', "The selected project location '{0}' does not exist or is not a directory.", location); };
|
||||
export const ProjectDirectoryAlreadyExistError = (projectName: string, location: string): string => { return localize('dataworkspace.projectDirectoryAlreadyExistError', "There is already a directory named '{0}' in the selected location: '{1}'.", projectName, location); };
|
||||
|
||||
@@ -480,6 +502,8 @@ export const integratedAuth = 'Integrated';
|
||||
export const azureMfaAuth = 'AzureMFA';
|
||||
export const sqlAuth = 'SqlAuth';
|
||||
|
||||
export const azureAddAccount = localize('azureAddAccount', "Add an Account...");
|
||||
|
||||
// Tree item types
|
||||
export enum DatabaseProjectItemType {
|
||||
project = 'databaseProject.itemType.project',
|
||||
@@ -548,4 +572,5 @@ export function getTargetPlatformFromVersion(version: string): string {
|
||||
export enum PublishTargetType {
|
||||
existingServer = 'existingServer',
|
||||
docker = 'docker',
|
||||
newAzureServer = 'newAzureServer'
|
||||
}
|
||||
|
||||
51
extensions/sql-database-projects/src/common/httpClient.ts
Normal file
51
extensions/sql-database-projects/src/common/httpClient.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as os from 'os';
|
||||
import axios, { AxiosRequestConfig } from 'axios';
|
||||
|
||||
/**
|
||||
* Class includes method for making http request
|
||||
*/
|
||||
export class HttpClient {
|
||||
private static cache: Map<string, any> = new Map();
|
||||
|
||||
/**
|
||||
* Makes http GET request to the given url. If useCache is set to true, returns the result from cache if exists
|
||||
* @param url url to make http GET request against
|
||||
* @param useCache if true and result is already cached the cached value will be returned
|
||||
* @returns result of http GET request
|
||||
*/
|
||||
public static async getRequest(url: string, useCache = false): Promise<any> {
|
||||
|
||||
if (useCache) {
|
||||
if (HttpClient.cache.has(url)) {
|
||||
return HttpClient.cache.get(url);
|
||||
}
|
||||
}
|
||||
|
||||
const config: AxiosRequestConfig = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
validateStatus: () => true // Never throw
|
||||
};
|
||||
const response = await axios.get(url, config);
|
||||
if (response.status !== 200) {
|
||||
let errorMessage: string[] = [];
|
||||
errorMessage.push(response.status.toString());
|
||||
errorMessage.push(response.statusText);
|
||||
if (response.data?.error) {
|
||||
errorMessage.push(`${response.data?.error?.code} : ${response.data?.error?.message}`);
|
||||
}
|
||||
throw new Error(errorMessage.join(os.EOL));
|
||||
}
|
||||
|
||||
if (useCache) {
|
||||
HttpClient.cache.set(url, response.data);
|
||||
}
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
@@ -38,5 +38,7 @@ export enum TelemetryActions {
|
||||
finishAddSqlBinding = 'finishAddSqlBinding',
|
||||
createProjectFromDatabase = 'createProjectFromDatabase',
|
||||
updateProjectFromDatabase = 'updateProjectFromDatabase',
|
||||
publishToContainer = 'publishToContainer'
|
||||
publishToContainer = 'publishToContainer',
|
||||
publishToNewAzureServer = 'publishToNewAzureServer',
|
||||
generateProjectFromOpenApiSpec = 'generateProjectFromOpenApiSpec'
|
||||
}
|
||||
|
||||
@@ -307,6 +307,18 @@ export async function getVscodeMssqlApi(): Promise<vscodeMssql.IExtension> {
|
||||
return ext.activate();
|
||||
}
|
||||
|
||||
export type AzureResourceServiceFactory = () => Promise<vscodeMssql.IAzureResourceService>;
|
||||
export async function defaultAzureResourceServiceFactory(): Promise<vscodeMssql.IAzureResourceService> {
|
||||
const vscodeMssqlApi = await getVscodeMssqlApi();
|
||||
return vscodeMssqlApi.azureResourceService;
|
||||
}
|
||||
|
||||
export type AzureAccountServiceFactory = () => Promise<vscodeMssql.IAzureAccountService>;
|
||||
export async function defaultAzureAccountServiceFactory(): Promise<vscodeMssql.IAzureAccountService> {
|
||||
const vscodeMssqlApi = await getVscodeMssqlApi();
|
||||
return vscodeMssqlApi.azureAccountService;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns the default deployment options from DacFx, filtered to appropriate options for the given project.
|
||||
*/
|
||||
@@ -441,7 +453,7 @@ export async function retry<T>(
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
outputChannel.appendLine(constants.retryMessage(name, err));
|
||||
outputChannel.appendLine(constants.retryMessage(name, getErrorMessage(err)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -599,3 +611,47 @@ export function getFoldersAlongPath(startFolder: string, endFolder: string): str
|
||||
|
||||
return folders;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns SQL version number from docker image name which is in the beginning of the image name
|
||||
* @param imageName docker image name
|
||||
* @returns SQL server version
|
||||
*/
|
||||
export function findSqlVersionInImageName(imageName: string): number | undefined {
|
||||
|
||||
// Regex to find the version in the beginning of the image name
|
||||
// e.g. 2017-CU16-ubuntu, 2019-latest
|
||||
const regex = new RegExp('^([0-9]+)[-].+$');
|
||||
|
||||
if (regex.test(imageName)) {
|
||||
const finds = regex.exec(imageName);
|
||||
if (finds) {
|
||||
|
||||
// 0 is the full match and 1 is the number with pattern inside the first ()
|
||||
return +finds[1];
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns SQL version number from target platform name
|
||||
* @param targetPlatform target platform
|
||||
* @returns SQL server version
|
||||
*/
|
||||
export function findSqlVersionInTargetPlatform(targetPlatform: string): number | undefined {
|
||||
|
||||
// Regex to find the version in target platform
|
||||
// e.g. SQL Server 2019
|
||||
const regex = new RegExp('([0-9]+)$');
|
||||
|
||||
if (regex.test(targetPlatform)) {
|
||||
const finds = regex.exec(targetPlatform);
|
||||
if (finds) {
|
||||
|
||||
// 0 is the full match and 1 is the number with pattern inside the first ()
|
||||
return +finds[1];
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -38,16 +38,17 @@ import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/t
|
||||
import { IconPathHelper } from '../common/iconHelper';
|
||||
import { DashboardData, PublishData, Status } from '../models/dashboardData/dashboardData';
|
||||
import { getPublishDatabaseSettings, launchPublishTargetOption } from '../dialogs/publishDatabaseQuickpick';
|
||||
import { launchPublishToDockerContainerQuickpick } from '../dialogs/deployDatabaseQuickpick';
|
||||
import { launchCreateAzureServerQuickPick, launchPublishToDockerContainerQuickpick } from '../dialogs/deployDatabaseQuickpick';
|
||||
import { DeployService } from '../models/deploy/deployService';
|
||||
import { GenerateProjectFromOpenApiSpecOptions, SqlTargetPlatform } from 'sqldbproj';
|
||||
import { AutorestHelper } from '../tools/autorestHelper';
|
||||
import { createNewProjectFromDatabaseWithQuickpick } from '../dialogs/createProjectFromDatabaseQuickpick';
|
||||
import { addDatabaseReferenceQuickpick } from '../dialogs/addDatabaseReferenceQuickpick';
|
||||
import { IDeployProfile } from '../models/deploy/deployProfile';
|
||||
import { ILocalDbDeployProfile, ISqlDbDeployProfile } from '../models/deploy/deployProfile';
|
||||
import { EntryType, FileProjectEntry, IDatabaseReferenceProjectEntry, SqlProjectReferenceProjectEntry } from '../models/projectEntry';
|
||||
import { UpdateProjectAction, UpdateProjectDataModel } from '../models/api/updateProject';
|
||||
import { targetPlatformToAssets } from '../projectProvider/projectAssets';
|
||||
import { AzureSqlClient } from '../models/deploy/azureSqlClient';
|
||||
|
||||
const maxTableLength = 10;
|
||||
|
||||
@@ -75,6 +76,7 @@ export class ProjectsController {
|
||||
private buildInfo: DashboardData[] = [];
|
||||
private publishInfo: PublishData[] = [];
|
||||
private deployService: DeployService;
|
||||
private azureSqlClient: AzureSqlClient;
|
||||
private autorestHelper: AutorestHelper;
|
||||
|
||||
projFileWatchers = new Map<string, vscode.FileSystemWatcher>();
|
||||
@@ -82,7 +84,8 @@ export class ProjectsController {
|
||||
constructor(private _outputChannel: vscode.OutputChannel) {
|
||||
this.netCoreTool = new NetCoreTool(this._outputChannel);
|
||||
this.buildHelper = new BuildHelper();
|
||||
this.deployService = new DeployService(this._outputChannel);
|
||||
this.azureSqlClient = new AzureSqlClient();
|
||||
this.deployService = new DeployService(this.azureSqlClient, this._outputChannel);
|
||||
this.autorestHelper = new AutorestHelper(this._outputChannel);
|
||||
}
|
||||
|
||||
@@ -285,21 +288,58 @@ export class ProjectsController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Publishes a project to a new Azure server
|
||||
* @param context a treeItem in a project's hierarchy, to be used to obtain a Project or the Project itself
|
||||
* @param deployProfile deploy profile
|
||||
*/
|
||||
public async publishToNewAzureServer(context: Project | dataworkspace.WorkspaceTreeItem, deployProfile: ISqlDbDeployProfile): Promise<void> {
|
||||
try {
|
||||
TelemetryReporter.sendActionEvent(TelemetryViews.ProjectController, TelemetryActions.publishToNewAzureServer);
|
||||
const project: Project = this.getProjectFromContext(context);
|
||||
if (deployProfile?.deploySettings && deployProfile?.sqlDbSetting) {
|
||||
void utils.showInfoMessageWithOutputChannel(constants.creatingAzureSqlServer(deployProfile?.sqlDbSetting?.serverName), this._outputChannel);
|
||||
const connectionUri = await this.deployService.createNewAzureSqlServer(deployProfile);
|
||||
if (connectionUri) {
|
||||
deployProfile.deploySettings.connectionUri = connectionUri;
|
||||
const publishResult = await this.publishOrScriptProject(project, deployProfile.deploySettings, true);
|
||||
if (publishResult && publishResult.success) {
|
||||
if (deployProfile.sqlDbSetting) {
|
||||
|
||||
// Connecting to the deployed db to add the profile to connection viewlet
|
||||
await this.deployService.getConnection(deployProfile.sqlDbSetting, true, deployProfile.sqlDbSetting.dbName);
|
||||
}
|
||||
void vscode.window.showInformationMessage(constants.publishProjectSucceed);
|
||||
} else {
|
||||
void utils.showErrorMessageWithOutputChannel(constants.publishToNewAzureServerFailed, publishResult?.errorMessage || '', this._outputChannel);
|
||||
}
|
||||
} else {
|
||||
void utils.showErrorMessageWithOutputChannel(constants.publishToNewAzureServerFailed, constants.deployProjectFailedMessage, this._outputChannel);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
void utils.showErrorMessageWithOutputChannel(constants.publishToNewAzureServerFailed, error, this._outputChannel);
|
||||
TelemetryReporter.sendErrorEvent(TelemetryViews.ProjectController, TelemetryActions.publishToNewAzureServer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Publishes a project to docker container
|
||||
* @param context a treeItem in a project's hierarchy, to be used to obtain a Project or the Project itself
|
||||
* @param deployProfile
|
||||
*/
|
||||
public async publishToDockerContainer(context: Project | dataworkspace.WorkspaceTreeItem, deployProfile: IDeployProfile): Promise<void> {
|
||||
public async publishToDockerContainer(context: Project | dataworkspace.WorkspaceTreeItem, deployProfile: ILocalDbDeployProfile): Promise<void> {
|
||||
const project: Project = this.getProjectFromContext(context);
|
||||
try {
|
||||
TelemetryReporter.sendActionEvent(TelemetryViews.ProjectController, TelemetryActions.publishToContainer);
|
||||
TelemetryReporter.createActionEvent(TelemetryViews.ProjectController, TelemetryActions.publishToContainer)
|
||||
.withAdditionalProperties({ dockerBaseImage: deployProfile.localDbSetting!.dockerBaseImage })
|
||||
.send();
|
||||
|
||||
if (deployProfile && deployProfile.deploySettings) {
|
||||
let connectionUri: string | undefined;
|
||||
if (deployProfile.localDbSetting) {
|
||||
void utils.showInfoMessageWithOutputChannel(constants.publishingProjectMessage, this._outputChannel);
|
||||
connectionUri = await this.deployService.deploy(deployProfile, project);
|
||||
connectionUri = await this.deployService.deployToContainer(deployProfile, project);
|
||||
if (connectionUri) {
|
||||
deployProfile.deploySettings.connectionUri = connectionUri;
|
||||
}
|
||||
@@ -321,7 +361,9 @@ export class ProjectsController {
|
||||
}
|
||||
} catch (error) {
|
||||
void utils.showErrorMessageWithOutputChannel(constants.publishToContainerFailed, error, this._outputChannel);
|
||||
TelemetryReporter.sendErrorEvent(TelemetryViews.ProjectController, TelemetryActions.publishToContainer);
|
||||
TelemetryReporter.createErrorEvent(TelemetryViews.ProjectController, TelemetryActions.publishToContainer)
|
||||
.withAdditionalProperties({ dockerBaseImage: deployProfile.localDbSetting!.dockerBaseImage })
|
||||
.send();
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -367,9 +409,19 @@ export class ProjectsController {
|
||||
|
||||
if (publishTarget === constants.PublishTargetType.docker) {
|
||||
const deployProfile = await launchPublishToDockerContainerQuickpick(project);
|
||||
if (deployProfile?.deploySettings) {
|
||||
if (deployProfile?.deploySettings && deployProfile?.localDbSetting) {
|
||||
await this.publishToDockerContainer(project, deployProfile);
|
||||
}
|
||||
} else if (publishTarget === constants.PublishTargetType.newAzureServer) {
|
||||
try {
|
||||
const settings = await launchCreateAzureServerQuickPick(project, this.azureSqlClient);
|
||||
if (settings?.deploySettings && settings?.sqlDbSetting) {
|
||||
await this.publishToNewAzureServer(project, settings);
|
||||
}
|
||||
} catch (error) {
|
||||
void utils.showErrorMessageWithOutputChannel(constants.publishToNewAzureServerFailed, error, this._outputChannel);
|
||||
}
|
||||
|
||||
} else {
|
||||
let settings: IDeploySettings | undefined = await getPublishDatabaseSettings(project);
|
||||
|
||||
|
||||
@@ -133,6 +133,48 @@ export async function createNewProjectFromDatabaseWithQuickpick(connectionInfo?:
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// 5. SDK-style project or not
|
||||
let sdkStyle;
|
||||
const sdkLearnMoreButton: vscode.QuickInputButton = {
|
||||
iconPath: new vscode.ThemeIcon('link-external'),
|
||||
tooltip: constants.learnMore
|
||||
};
|
||||
const quickPick = vscode.window.createQuickPick();
|
||||
quickPick.items = [{ label: constants.YesRecommended }, { label: constants.noString }];
|
||||
quickPick.title = constants.sdkStyleProject;
|
||||
quickPick.ignoreFocusOut = true;
|
||||
const disposables: vscode.Disposable[] = [];
|
||||
|
||||
try {
|
||||
quickPick.buttons = [sdkLearnMoreButton];
|
||||
quickPick.placeholder = constants.SdkLearnMorePlaceholder;
|
||||
|
||||
const sdkStylePromise = new Promise<boolean | undefined>((resolve) => {
|
||||
disposables.push(
|
||||
quickPick.onDidHide(() => {
|
||||
resolve(undefined);
|
||||
}),
|
||||
quickPick.onDidChangeSelection((item) => {
|
||||
resolve(item[0].label === constants.YesRecommended);
|
||||
}));
|
||||
|
||||
disposables.push(quickPick.onDidTriggerButton(async () => {
|
||||
await vscode.env.openExternal(vscode.Uri.parse(constants.sdkLearnMoreUrl!));
|
||||
}));
|
||||
});
|
||||
|
||||
quickPick.show();
|
||||
sdkStyle = await sdkStylePromise;
|
||||
quickPick.hide();
|
||||
} finally {
|
||||
disposables.forEach(d => d.dispose());
|
||||
}
|
||||
|
||||
if (sdkStyle === undefined) {
|
||||
// User cancelled
|
||||
return;
|
||||
}
|
||||
|
||||
return {
|
||||
connectionUri: connectionUri,
|
||||
database: selectedDatabase,
|
||||
@@ -140,6 +182,6 @@ export async function createNewProjectFromDatabaseWithQuickpick(connectionInfo?:
|
||||
filePath: projectLocation,
|
||||
version: '1.0.0.0',
|
||||
extractTarget: mapExtractTargetEnum(folderStructure),
|
||||
sdkStyle: false // todo: add sdkstyle option to quickpick
|
||||
sdkStyle: sdkStyle
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,11 +7,14 @@ import * as vscode from 'vscode';
|
||||
import * as constants from '../common/constants';
|
||||
import * as utils from '../common/utils';
|
||||
import * as uiUtils from './utils';
|
||||
import { AppSettingType, DockerImageInfo, IDeployAppIntegrationProfile, IDeployProfile, ILocalDbSetting } from '../models/deploy/deployProfile';
|
||||
import { AppSettingType, DockerImageInfo, IDeployAppIntegrationProfile, ISqlDbDeployProfile, ILocalDbDeployProfile, ILocalDbSetting } from '../models/deploy/deployProfile';
|
||||
import { Project } from '../models/project';
|
||||
import { getPublishDatabaseSettings } from './publishDatabaseQuickpick';
|
||||
import * as path from 'path';
|
||||
import * as fse from 'fs-extra';
|
||||
import { AzureSqlClient } from '../models/deploy/azureSqlClient';
|
||||
import { IDeploySettings } from '../models/IDeploySettings';
|
||||
import { IAccount } from 'vscode-mssql';
|
||||
|
||||
/**
|
||||
* Create flow for Deploying a database using only VS Code-native APIs such as QuickPick
|
||||
@@ -112,12 +115,168 @@ async function launchEulaQuickPick(imageInfo: DockerImageInfo | undefined): Prom
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function launchCreateAzureServerQuickPick(project: Project, azureSqlClient: AzureSqlClient): Promise<ISqlDbDeployProfile | undefined> {
|
||||
|
||||
const name = uiUtils.getPublishServerName(project.getProjectTargetVersion());
|
||||
const accounts = await azureSqlClient.getAccounts();
|
||||
const accountOptions = accounts.map(x => x.displayInfo?.displayName || '');
|
||||
accountOptions.unshift(constants.azureAddAccount);
|
||||
|
||||
let account: IAccount | undefined;
|
||||
let accountOption = await vscode.window.showQuickPick(
|
||||
accountOptions,
|
||||
{ title: constants.azureAccounts, ignoreFocusOut: true });
|
||||
|
||||
// Return when user hits escape
|
||||
if (!accountOption) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (accountOption === constants.azureAddAccount) {
|
||||
account = await azureSqlClient.getAccount();
|
||||
} else {
|
||||
account = accounts.find(x => x.displayInfo.displayName === accountOption);
|
||||
}
|
||||
|
||||
if (!account) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const sessions = await azureSqlClient.getSessions(account);
|
||||
|
||||
const subscriptionName = await vscode.window.showQuickPick(
|
||||
sessions.map(x => x.subscription.displayName || ''),
|
||||
{ title: constants.azureSubscription, ignoreFocusOut: true });
|
||||
|
||||
// Return when user hits escape
|
||||
if (!subscriptionName) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const session = sessions.find(x => x.subscription.displayName === subscriptionName);
|
||||
|
||||
if (!session?.subscription?.subscriptionId) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const resourceGroups = await azureSqlClient.getResourceGroups(session);
|
||||
const resourceGroupName = await vscode.window.showQuickPick(
|
||||
resourceGroups.map(x => x.name || ''),
|
||||
{ title: constants.resourceGroup, ignoreFocusOut: true });
|
||||
|
||||
// Return when user hits escape
|
||||
if (!resourceGroupName) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const resourceGroup = resourceGroups.find(x => x.name === resourceGroupName);
|
||||
|
||||
// Return resource group is invalid
|
||||
if (!resourceGroup) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let locations = await azureSqlClient.getLocations(session);
|
||||
if (resourceGroup.location) {
|
||||
const defaultLocation = locations.find(x => x.name === resourceGroup.location);
|
||||
if (defaultLocation) {
|
||||
locations = locations.filter(x => x.name !== defaultLocation.name);
|
||||
locations.unshift(defaultLocation);
|
||||
}
|
||||
}
|
||||
|
||||
let locationName = await vscode.window.showQuickPick(
|
||||
locations.map(x => x.name || ''),
|
||||
{ title: constants.azureLocation, ignoreFocusOut: true, placeHolder: resourceGroup?.location });
|
||||
|
||||
// Return when user hits escape
|
||||
if (!locationName) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let serverName: string | undefined = '';
|
||||
serverName = await vscode.window.showInputBox({
|
||||
title: constants.azureServerName,
|
||||
ignoreFocusOut: true,
|
||||
value: serverName,
|
||||
password: false
|
||||
}
|
||||
);
|
||||
|
||||
// Return when user hits escape
|
||||
if (!serverName) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let user: string | undefined = '';
|
||||
user = await vscode.window.showInputBox({
|
||||
title: constants.enterUser(name),
|
||||
ignoreFocusOut: true,
|
||||
value: user,
|
||||
password: false
|
||||
}
|
||||
);
|
||||
|
||||
// Return when user hits escape
|
||||
if (!user) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let password: string | undefined = '';
|
||||
password = await vscode.window.showInputBox({
|
||||
title: constants.enterPassword(name),
|
||||
ignoreFocusOut: true,
|
||||
value: password,
|
||||
validateInput: input => !utils.isValidSQLPassword(input) ? constants.invalidSQLPasswordMessage(name) : undefined,
|
||||
password: true
|
||||
}
|
||||
);
|
||||
|
||||
// Return when user hits escape
|
||||
if (!password) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let confirmPassword: string | undefined = '';
|
||||
confirmPassword = await vscode.window.showInputBox({
|
||||
title: constants.confirmPassword(name),
|
||||
ignoreFocusOut: true,
|
||||
value: confirmPassword,
|
||||
validateInput: input => input !== password ? constants.passwordNotMatch(name) : undefined,
|
||||
password: true
|
||||
}
|
||||
);
|
||||
|
||||
// Return when user hits escape
|
||||
if (!confirmPassword) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let settings: IDeploySettings | undefined = await getPublishDatabaseSettings(project, false);
|
||||
|
||||
return {
|
||||
// TODO add tenant
|
||||
deploySettings: settings, sqlDbSetting: {
|
||||
tenantId: session.tenantId,
|
||||
accountId: session.account.key.id,
|
||||
serverName: serverName,
|
||||
userName: user,
|
||||
password: password,
|
||||
port: 1433,
|
||||
dbName: '',
|
||||
session: session,
|
||||
resourceGroupName: resourceGroup.name || '',
|
||||
location: locationName
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create flow for publishing a database to docker container using only VS Code-native APIs such as QuickPick
|
||||
*/
|
||||
export async function launchPublishToDockerContainerQuickpick(project: Project): Promise<IDeployProfile | undefined> {
|
||||
|
||||
const name = uiUtils.getPublishServerName(project.getProjectTargetVersion());
|
||||
export async function launchPublishToDockerContainerQuickpick(project: Project): Promise<ILocalDbDeployProfile | undefined> {
|
||||
const target = project.getProjectTargetVersion();
|
||||
const name = uiUtils.getPublishServerName(target);
|
||||
let localDbSetting: ILocalDbSetting | undefined;
|
||||
// Deploy to docker selected
|
||||
let portNumber = await vscode.window.showInputBox({
|
||||
@@ -163,10 +322,10 @@ export async function launchPublishToDockerContainerQuickpick(project: Project):
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const baseImages = uiUtils.getDockerBaseImages(project.getProjectTargetVersion());
|
||||
const baseImages = uiUtils.getDockerBaseImages(target);
|
||||
const baseImage = await vscode.window.showQuickPick(
|
||||
baseImages.map(x => x.displayName),
|
||||
{ title: constants.selectBaseImage(name), ignoreFocusOut: true });
|
||||
{ title: constants.selectBaseImage(name), ignoreFocusOut: true, placeHolder: uiUtils.getDockerImagePlaceHolder(target) });
|
||||
|
||||
// Return when user hits escape
|
||||
if (!baseImage) {
|
||||
@@ -174,19 +333,50 @@ export async function launchPublishToDockerContainerQuickpick(project: Project):
|
||||
}
|
||||
|
||||
const imageInfo = baseImages.find(x => x.displayName === baseImage);
|
||||
|
||||
if (!imageInfo) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const eulaAccepted = await launchEulaQuickPick(imageInfo);
|
||||
if (!eulaAccepted) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
let imageTags = await uiUtils.getImageTags(imageInfo, target);
|
||||
let imageTagsItems: vscode.QuickPickItem[] = imageTags.map(tag => { return { label: tag }; });
|
||||
|
||||
if (imageInfo.defaultTag) {
|
||||
// move the default to be the first one in the list
|
||||
const defaultIndex = imageTagsItems.findIndex(i => i.label === imageInfo.defaultTag);
|
||||
if (defaultIndex > -1) {
|
||||
imageTagsItems.splice(defaultIndex, 1);
|
||||
}
|
||||
// add default next to the default value
|
||||
imageTagsItems.unshift({ label: imageInfo.defaultTag, description: constants.defaultQuickPickItem });
|
||||
}
|
||||
const imageTag = await vscode.window.showQuickPick(
|
||||
imageTagsItems,
|
||||
{ title: constants.selectImageTag(name), ignoreFocusOut: true });
|
||||
|
||||
if (!imageTag) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Add the image tag if it's not the latest
|
||||
let imageName = imageInfo.name;
|
||||
if (imageTag && imageTag.label !== constants.dockerImageDefaultTag) {
|
||||
imageName = `${imageName}:${imageTag.label}`;
|
||||
}
|
||||
|
||||
localDbSetting = {
|
||||
serverName: constants.defaultLocalServerName,
|
||||
userName: constants.defaultLocalServerAdminName,
|
||||
dbName: project.projectFileName,
|
||||
password: password,
|
||||
port: +portNumber,
|
||||
dockerBaseImage: imageInfo?.name || '',
|
||||
dockerBaseImageEula: imageInfo?.agreementInfo?.link?.url || ''
|
||||
dockerBaseImage: imageName,
|
||||
dockerBaseImageEula: imageInfo.agreementInfo.link.url
|
||||
};
|
||||
|
||||
let deploySettings = await getPublishDatabaseSettings(project, false);
|
||||
@@ -202,7 +392,6 @@ export async function launchPublishToDockerContainerQuickpick(project: Project):
|
||||
// Get the database name from deploy settings
|
||||
localDbSetting.dbName = deploySettings.databaseName;
|
||||
|
||||
|
||||
return {
|
||||
localDbSetting: localDbSetting,
|
||||
deploySettings: deploySettings,
|
||||
|
||||
@@ -16,7 +16,7 @@ import { IconPathHelper } from '../common/iconHelper';
|
||||
import { cssStyles } from '../common/uiConstants';
|
||||
import { getAgreementDisplayText, getConnectionName, getDockerBaseImages, getPublishServerName } from './utils';
|
||||
import { TelemetryActions, TelemetryReporter, TelemetryViews } from '../common/telemetry';
|
||||
import { IDeployProfile } from '../models/deploy/deployProfile';
|
||||
import { ILocalDbDeployProfile } from '../models/deploy/deployProfile';
|
||||
import { Deferred } from '../common/promise';
|
||||
|
||||
interface DataSourceDropdownValue extends azdataType.CategoryValue {
|
||||
@@ -62,7 +62,7 @@ export class PublishDatabaseDialog {
|
||||
private toDispose: vscode.Disposable[] = [];
|
||||
|
||||
public publish: ((proj: Project, profile: IDeploySettings) => any) | undefined;
|
||||
public publishToContainer: ((proj: Project, profile: IDeployProfile) => any) | undefined;
|
||||
public publishToContainer: ((proj: Project, profile: ILocalDbDeployProfile) => any) | undefined;
|
||||
public generateScript: ((proj: Project, profile: IDeploySettings) => any) | undefined;
|
||||
public readPublishProfile: ((profileUri: vscode.Uri) => any) | undefined;
|
||||
|
||||
@@ -232,7 +232,7 @@ export class PublishDatabaseDialog {
|
||||
const dockerBaseImage = this.getBaseDockerImageName();
|
||||
const baseImages = getDockerBaseImages(this.project.getProjectTargetVersion());
|
||||
const imageInfo = baseImages.find(x => x.name === dockerBaseImage);
|
||||
const settings: IDeployProfile = {
|
||||
const settings: ILocalDbDeployProfile = {
|
||||
localDbSetting: {
|
||||
dbName: this.targetDatabaseName,
|
||||
dockerBaseImage: dockerBaseImage,
|
||||
|
||||
@@ -12,6 +12,7 @@ import { getDefaultPublishDeploymentOptions, getVscodeMssqlApi } from '../common
|
||||
import { IConnectionInfo } from 'vscode-mssql';
|
||||
import { IDeploySettings } from '../models/IDeploySettings';
|
||||
import { getPublishServerName } from './utils';
|
||||
import { SqlTargetPlatform } from 'sqldbproj';
|
||||
|
||||
/**
|
||||
* Create flow for Publishing a database using only VS Code-native APIs such as QuickPick
|
||||
@@ -209,9 +210,18 @@ export async function getPublishDatabaseSettings(project: Project, promptForConn
|
||||
|
||||
export async function launchPublishTargetOption(project: Project): Promise<constants.PublishTargetType | undefined> {
|
||||
// Show options to user for deploy to existing server or docker
|
||||
const name = getPublishServerName(project.getProjectTargetVersion());
|
||||
const target = project.getProjectTargetVersion();
|
||||
const name = getPublishServerName(target);
|
||||
const logicalServerName = target === constants.targetPlatformToVersion.get(SqlTargetPlatform.sqlAzure) ? constants.AzureSqlLogicalServerName : constants.SqlServerName;
|
||||
|
||||
// Options list based on target
|
||||
const options = target === constants.targetPlatformToVersion.get(SqlTargetPlatform.sqlAzure) ?
|
||||
[constants.publishToAzureEmulator, constants.publishToNewAzureServer, constants.publishToExistingServer(logicalServerName)] :
|
||||
[constants.publishToDockerContainer(name), constants.publishToExistingServer(logicalServerName)];
|
||||
|
||||
// Show the options to the user
|
||||
const publishOption = await vscode.window.showQuickPick(
|
||||
[constants.publishToExistingServer(name), constants.publishToDockerContainer(name)],
|
||||
options,
|
||||
{ title: constants.selectPublishOption, ignoreFocusOut: true });
|
||||
|
||||
// Return when user hits escape
|
||||
@@ -219,11 +229,16 @@ export async function launchPublishTargetOption(project: Project): Promise<const
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Map the title to the publish option type
|
||||
switch (publishOption) {
|
||||
case constants.publishToExistingServer(name):
|
||||
return constants.PublishTargetType.existingServer;
|
||||
case constants.publishToDockerContainer(name):
|
||||
return constants.PublishTargetType.docker;
|
||||
case constants.publishToAzureEmulator:
|
||||
return constants.PublishTargetType.docker;
|
||||
case constants.publishToNewAzureServer:
|
||||
return constants.PublishTargetType.newAzureServer;
|
||||
default:
|
||||
return constants.PublishTargetType.existingServer;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
|
||||
import { SqlTargetPlatform } from 'sqldbproj';
|
||||
import * as constants from '../common/constants';
|
||||
import * as utils from '../common/utils';
|
||||
import { HttpClient } from '../common/httpClient';
|
||||
import { AgreementInfo, DockerImageInfo } from '../models/deploy/deployProfile';
|
||||
|
||||
/**
|
||||
@@ -38,58 +40,117 @@ export function getPublishServerName(target: string): string {
|
||||
return target === constants.targetPlatformToVersion.get(SqlTargetPlatform.sqlAzure) ? constants.AzureSqlServerName : constants.SqlServerName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the docker image place holder based on the target version
|
||||
*/
|
||||
export function getDockerImagePlaceHolder(target: string): string {
|
||||
return target === constants.targetPlatformToVersion.get(SqlTargetPlatform.sqlAzure) ?
|
||||
constants.dockerImagesPlaceHolder(constants.AzureSqlDbLiteDockerImageName) :
|
||||
constants.dockerImagesPlaceHolder(SqlTargetPlatform.sqlEdge);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of image tags for given target
|
||||
* @param imageInfo docker image info
|
||||
* @param target project target version
|
||||
* @returns image tags
|
||||
*/
|
||||
export async function getImageTags(imageInfo: DockerImageInfo, target: string): Promise<string[]> {
|
||||
let imageTags: string[] | undefined = [];
|
||||
const versionToImageTags: Map<number, string[]> = new Map<number, string[]>();
|
||||
|
||||
try {
|
||||
const imageTagsFromUrl = await HttpClient.getRequest(imageInfo?.tagsUrl, true);
|
||||
if (imageTagsFromUrl?.tags) {
|
||||
|
||||
// Create a map for version and tags and find the max version in the list
|
||||
let defaultVersion: number = 0;
|
||||
let maxVersionNumber: number = defaultVersion;
|
||||
(imageTagsFromUrl.tags as string[]).forEach(imageTag => {
|
||||
const version = utils.findSqlVersionInImageName(imageTag) || defaultVersion;
|
||||
let tags = versionToImageTags.has(version) ? versionToImageTags.get(version) : [];
|
||||
tags = tags ?? [];
|
||||
tags = tags?.concat(imageTag);
|
||||
versionToImageTags.set(version, tags);
|
||||
maxVersionNumber = version && version > maxVersionNumber ? version : maxVersionNumber;
|
||||
});
|
||||
|
||||
// Find the version maps to the target framework and default to max version in the tags
|
||||
const targetVersion = utils.findSqlVersionInTargetPlatform(constants.getTargetPlatformFromVersion(target)) || maxVersionNumber;
|
||||
|
||||
// Get the image tags with no version of the one that matches project platform
|
||||
versionToImageTags.forEach((tags: string[], version: number) => {
|
||||
if (version === defaultVersion || version >= targetVersion) {
|
||||
imageTags = imageTags?.concat(tags);
|
||||
}
|
||||
});
|
||||
|
||||
imageTags = imageTags ?? [];
|
||||
imageTags = imageTags.sort((a, b) => a.indexOf(constants.dockerImageDefaultTag) > 0 ? -1 : a.localeCompare(b));
|
||||
}
|
||||
} catch (err) {
|
||||
// Ignore the error. If http request fails, we just use the default tag
|
||||
console.debug(`Failed to get docker image tags ${err}`);
|
||||
}
|
||||
|
||||
return imageTags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of base images for given target version
|
||||
* @param target
|
||||
* @returns list of image info
|
||||
*/
|
||||
export function getDockerBaseImages(target: string): DockerImageInfo[] {
|
||||
if (target === constants.targetPlatformToVersion.get(SqlTargetPlatform.sqlAzure)) {
|
||||
return [{
|
||||
name: `${constants.sqlServerDockerRegistry}/${constants.sqlServerDockerRepository}:2019-latest`,
|
||||
displayName: SqlTargetPlatform.sqlServer2019,
|
||||
name: `${constants.sqlServerDockerRegistry}/${constants.sqlServerDockerRepository}`,
|
||||
displayName: constants.AzureSqlDbFullDockerImageName,
|
||||
agreementInfo: {
|
||||
link: {
|
||||
text: constants.eulaAgreementTitle,
|
||||
url: constants.sqlServerEulaLink,
|
||||
}
|
||||
}
|
||||
},
|
||||
tagsUrl: `https://${constants.sqlServerDockerRegistry}/v2/${constants.sqlServerDockerRepository}/tags/list`,
|
||||
defaultTag: constants.dockerImageDefaultTag
|
||||
}, {
|
||||
name: `${constants.sqlServerDockerRegistry}/${constants.azureSqlEdgeDockerRepository}:latest`,
|
||||
displayName: SqlTargetPlatform.sqlEdge,
|
||||
name: `${constants.sqlServerDockerRegistry}/${constants.azureSqlEdgeDockerRepository}`,
|
||||
displayName: constants.AzureSqlDbLiteDockerImageName,
|
||||
agreementInfo: {
|
||||
link: {
|
||||
text: constants.edgeEulaAgreementTitle,
|
||||
url: constants.sqlServerEdgeEulaLink,
|
||||
}
|
||||
}
|
||||
},
|
||||
tagsUrl: `https://${constants.sqlServerDockerRegistry}/v2/${constants.azureSqlEdgeDockerRepository}/tags/list`,
|
||||
defaultTag: constants.dockerImageDefaultTag
|
||||
}];
|
||||
} else {
|
||||
return [
|
||||
{
|
||||
name: `${constants.sqlServerDockerRegistry}/${constants.sqlServerDockerRepository}:2017-latest`,
|
||||
displayName: SqlTargetPlatform.sqlServer2017,
|
||||
name: `${constants.sqlServerDockerRegistry}/${constants.sqlServerDockerRepository}`,
|
||||
displayName: constants.SqlServerDockerImageName,
|
||||
agreementInfo: {
|
||||
link: {
|
||||
text: constants.eulaAgreementTitle,
|
||||
url: constants.sqlServerEulaLink,
|
||||
}
|
||||
}
|
||||
},
|
||||
tagsUrl: `https://${constants.sqlServerDockerRegistry}/v2/${constants.sqlServerDockerRepository}/tags/list`,
|
||||
defaultTag: constants.dockerImageDefaultTag
|
||||
},
|
||||
{
|
||||
name: `${constants.sqlServerDockerRegistry}/${constants.sqlServerDockerRepository}:2019-latest`,
|
||||
displayName: SqlTargetPlatform.sqlServer2019,
|
||||
agreementInfo: {
|
||||
link: {
|
||||
text: constants.eulaAgreementTitle,
|
||||
url: constants.sqlServerEulaLink,
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: `${constants.sqlServerDockerRegistry}/${constants.azureSqlEdgeDockerRepository}:latest`,
|
||||
name: `${constants.sqlServerDockerRegistry}/${constants.azureSqlEdgeDockerRepository}`,
|
||||
displayName: SqlTargetPlatform.sqlEdge,
|
||||
agreementInfo: {
|
||||
link: {
|
||||
text: constants.edgeEulaAgreementTitle,
|
||||
url: constants.sqlServerEdgeEulaLink,
|
||||
}
|
||||
}
|
||||
},
|
||||
tagsUrl: `https://${constants.sqlServerDockerRegistry}/v2/${constants.azureSqlEdgeDockerRepository}/tags/list`,
|
||||
defaultTag: constants.dockerImageDefaultTag
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as utils from '../../common/utils';
|
||||
import { IAccount, IAzureAccountSession, azure } from 'vscode-mssql';
|
||||
|
||||
/**
|
||||
* Client module to call Azure APIs for getting or creating resources
|
||||
*/
|
||||
export class AzureSqlClient {
|
||||
|
||||
constructor(
|
||||
private _azureAccountServiceFactory: utils.AzureAccountServiceFactory = utils.defaultAzureAccountServiceFactory,
|
||||
private _azureResourceServiceFactory: utils.AzureResourceServiceFactory = utils.defaultAzureResourceServiceFactory
|
||||
) { }
|
||||
|
||||
/**
|
||||
* Returns existing Azure accounts
|
||||
*/
|
||||
public async getAccounts(): Promise<IAccount[]> {
|
||||
const azureAccountService = await this._azureAccountServiceFactory();
|
||||
return await azureAccountService.getAccounts();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt user to login to Azure and returns the account
|
||||
* @returns Azure account that user logged in to
|
||||
*/
|
||||
public async getAccount(): Promise<IAccount> {
|
||||
const azureAccountService = await this._azureAccountServiceFactory();
|
||||
return await azureAccountService.addAccount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Azure locations for given subscription
|
||||
*/
|
||||
public async getLocations(session: IAzureAccountSession): Promise<azure.subscription.Location[]> {
|
||||
const azureResourceService = await this._azureResourceServiceFactory();
|
||||
return await azureResourceService.getLocations(session);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Azure sessions with subscription, tenant and token for given account
|
||||
*/
|
||||
public async getSessions(account: IAccount): Promise<IAzureAccountSession[]> {
|
||||
const azureAccountService = await this._azureAccountServiceFactory();
|
||||
return await azureAccountService.getAccountSessions(account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new Azure SQL server for given subscription, resource group and location
|
||||
*/
|
||||
public async createOrUpdateServer(session: IAzureAccountSession, resourceGroupName: string, serverName: string, parameters: azure.sql.Server): Promise<string | undefined> {
|
||||
const azureResourceService = await this._azureResourceServiceFactory();
|
||||
return await azureResourceService.createOrUpdateServer(session, resourceGroupName, serverName, parameters);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns Azure resource groups for given subscription
|
||||
*/
|
||||
public async getResourceGroups(session: IAzureAccountSession): Promise<Array<azure.resources.ResourceGroup> | []> {
|
||||
const azureResourceService = await this._azureResourceServiceFactory();
|
||||
return await azureResourceService.getResourceGroups(session);
|
||||
}
|
||||
}
|
||||
@@ -5,39 +5,59 @@
|
||||
|
||||
import { IDeploySettings } from '../IDeploySettings';
|
||||
import type * as azdataType from 'azdata';
|
||||
import { IAzureAccountSession } from 'vscode-mssql';
|
||||
|
||||
export enum AppSettingType {
|
||||
None,
|
||||
AzureFunction
|
||||
}
|
||||
export interface IDeployProfile {
|
||||
export interface ILocalDbDeployProfile {
|
||||
localDbSetting?: ILocalDbSetting;
|
||||
deploySettings?: IDeploySettings;
|
||||
}
|
||||
|
||||
export interface ISqlDbDeployProfile {
|
||||
sqlDbSetting?: ISqlDbSetting;
|
||||
deploySettings?: IDeploySettings;
|
||||
}
|
||||
|
||||
export interface IDeployAppIntegrationProfile {
|
||||
envVariableName?: string;
|
||||
appSettingFile?: string;
|
||||
appSettingType: AppSettingType;
|
||||
}
|
||||
|
||||
export interface ILocalDbSetting {
|
||||
serverName: string,
|
||||
port: number,
|
||||
userName: string,
|
||||
password: string,
|
||||
dbName: string,
|
||||
export interface ISqlDbSetting extends ISqlConnectionProperties {
|
||||
session: IAzureAccountSession
|
||||
resourceGroupName: string,
|
||||
location: string
|
||||
}
|
||||
|
||||
export interface ILocalDbSetting extends ISqlConnectionProperties {
|
||||
dockerBaseImage: string,
|
||||
dockerBaseImageEula: string,
|
||||
connectionRetryTimeout?: number,
|
||||
profileName?: string
|
||||
}
|
||||
|
||||
export interface ISqlConnectionProperties {
|
||||
tenantId?: string,
|
||||
accountId?: string
|
||||
serverName: string,
|
||||
userName: string,
|
||||
password: string,
|
||||
port: number,
|
||||
dbName: string,
|
||||
profileName?: string,
|
||||
connectionRetryTimeout?: number
|
||||
}
|
||||
|
||||
export interface DockerImageInfo {
|
||||
name: string,
|
||||
displayName: string,
|
||||
agreementInfo: AgreementInfo
|
||||
agreementInfo: AgreementInfo,
|
||||
tagsUrl: string,
|
||||
defaultTag: string
|
||||
}
|
||||
export interface AgreementInfo {
|
||||
link: azdataType.LinkArea;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { AppSettingType, IDeployAppIntegrationProfile, IDeployProfile, ILocalDbSetting } from './deployProfile';
|
||||
import { AppSettingType, IDeployAppIntegrationProfile, ILocalDbDeployProfile, ILocalDbSetting, ISqlConnectionProperties, ISqlDbDeployProfile } from './deployProfile';
|
||||
import * as UUID from 'vscode-languageclient/lib/utils/uuid';
|
||||
import { Project } from '../project';
|
||||
import * as constants from '../../common/constants';
|
||||
@@ -13,6 +13,8 @@ import * as vscode from 'vscode';
|
||||
import { ConnectionResult } from 'azdata';
|
||||
import * as templates from '../../templates/templates';
|
||||
import { ShellExecutionHelper } from '../../tools/shellExecutionHelper';
|
||||
import { AzureSqlClient } from './azureSqlClient';
|
||||
import { IFireWallRuleError } from 'vscode-mssql';
|
||||
|
||||
interface DockerImageSpec {
|
||||
label: string;
|
||||
@@ -21,7 +23,7 @@ interface DockerImageSpec {
|
||||
}
|
||||
export class DeployService {
|
||||
|
||||
constructor(private _outputChannel: vscode.OutputChannel, shellExecutionHelper: ShellExecutionHelper | undefined = undefined) {
|
||||
constructor(private _azureSqlClient = new AzureSqlClient(), private _outputChannel: vscode.OutputChannel, shellExecutionHelper: ShellExecutionHelper | undefined = undefined) {
|
||||
this._shellExecutionHelper = shellExecutionHelper ?? new ShellExecutionHelper(this._outputChannel);
|
||||
}
|
||||
|
||||
@@ -50,7 +52,7 @@ export class DeployService {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public async updateAppSettings(profile: IDeployAppIntegrationProfile, deployProfile: IDeployProfile | undefined): Promise<void> {
|
||||
public async updateAppSettings(profile: IDeployAppIntegrationProfile, deployProfile: ILocalDbDeployProfile | undefined): Promise<void> {
|
||||
// Update app settings
|
||||
//
|
||||
if (!profile.appSettingFile) {
|
||||
@@ -122,7 +124,37 @@ export class DeployService {
|
||||
return { label: imageLabel, tag: imageTag, containerName: dockerName };
|
||||
}
|
||||
|
||||
public async deploy(profile: IDeployProfile, project: Project): Promise<string | undefined> {
|
||||
/**
|
||||
* Creates a new Azure Sql server and tries to connect to the new server. If connection fails because of firewall rule, it prompts user to add firewall rule settings
|
||||
* @param profile Azure Sql server settings
|
||||
* @returns connection url for the new server
|
||||
*/
|
||||
public async createNewAzureSqlServer(profile: ISqlDbDeployProfile | undefined): Promise<string | undefined> {
|
||||
if (!profile?.sqlDbSetting) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
this.logToOutput(constants.creatingAzureSqlServer(profile?.sqlDbSetting?.serverName));
|
||||
|
||||
// Create the server
|
||||
const server = await this._azureSqlClient.createOrUpdateServer(profile.sqlDbSetting.session, profile?.sqlDbSetting.resourceGroupName, profile?.sqlDbSetting.serverName, {
|
||||
location: profile?.sqlDbSetting?.location,
|
||||
administratorLogin: profile?.sqlDbSetting.userName,
|
||||
administratorLoginPassword: profile?.sqlDbSetting.password
|
||||
});
|
||||
if (server) {
|
||||
this._outputChannel.appendLine(constants.serverCreated);
|
||||
profile.sqlDbSetting.serverName = server;
|
||||
|
||||
this.logToOutput(constants.azureSqlServerCreated(profile?.sqlDbSetting?.serverName));
|
||||
|
||||
// Connect to the server
|
||||
return await this.getConnection(profile.sqlDbSetting, false, constants.master);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
public async deployToContainer(profile: ILocalDbDeployProfile, project: Project): Promise<string | undefined> {
|
||||
return await this.executeTask(constants.deployDbTaskName, async () => {
|
||||
if (!profile.localDbSetting) {
|
||||
return undefined;
|
||||
@@ -218,7 +250,7 @@ export class DeployService {
|
||||
}
|
||||
|
||||
// Connects to a database
|
||||
private async connectToDatabase(profile: ILocalDbSetting, saveConnectionAndPassword: boolean, database: string): Promise<ConnectionResult | string | undefined> {
|
||||
private async connectToDatabase(profile: ISqlConnectionProperties, saveConnectionAndPassword: boolean, database: string): Promise<ConnectionResult | string | undefined> {
|
||||
const getAzdataApi = await utils.getAzdataApi();
|
||||
const vscodeMssqlApi = getAzdataApi ? undefined : await utils.getVscodeMssqlApi();
|
||||
if (getAzdataApi) {
|
||||
@@ -248,7 +280,7 @@ export class DeployService {
|
||||
encrypt: false,
|
||||
connectTimeout: 30,
|
||||
applicationName: 'SQL Database Project',
|
||||
accountId: undefined,
|
||||
accountId: profile.accountId,
|
||||
azureAccountToken: undefined,
|
||||
applicationIntent: undefined,
|
||||
attachDbFilename: undefined,
|
||||
@@ -272,9 +304,19 @@ export class DeployService {
|
||||
workstationId: undefined,
|
||||
profileName: profile.profileName,
|
||||
expiresOn: undefined,
|
||||
tenantId: undefined
|
||||
tenantId: profile.tenantId
|
||||
};
|
||||
let connectionUrl = await vscodeMssqlApi.connect(connectionProfile, saveConnectionAndPassword);
|
||||
let connectionUrl = '';
|
||||
try {
|
||||
connectionUrl = await vscodeMssqlApi.connect(connectionProfile, saveConnectionAndPassword);
|
||||
} catch (err) {
|
||||
const firewallRuleError = <IFireWallRuleError>err;
|
||||
if (firewallRuleError?.connectionUri) {
|
||||
await vscodeMssqlApi.promptForFirewallRule(err.connectionUri, connectionProfile);
|
||||
} else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
return connectionUrl;
|
||||
} else {
|
||||
return undefined;
|
||||
@@ -307,7 +349,7 @@ export class DeployService {
|
||||
return connectionResult ? connectionResult.connectionId : <string>connection;
|
||||
}
|
||||
|
||||
public async getConnection(profile: ILocalDbSetting, saveConnectionAndPassword: boolean, database: string): Promise<string | undefined> {
|
||||
public async getConnection(profile: ISqlConnectionProperties, saveConnectionAndPassword: boolean, database: string): Promise<string | undefined> {
|
||||
const getAzdataApi = await utils.getAzdataApi();
|
||||
let connection = await utils.retry(
|
||||
constants.connectingToSqlServerMessage,
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as should from 'should';
|
||||
import { AzureSqlClient } from '../../models/deploy/azureSqlClient';
|
||||
import { IAccount, IAzureAccountService, IAzureAccountSession, IAzureResourceService, azure } from 'vscode-mssql';
|
||||
|
||||
|
||||
|
||||
export interface TestContext {
|
||||
azureAccountService: IAzureAccountService;
|
||||
azureResourceService: IAzureResourceService;
|
||||
accounts: IAccount[];
|
||||
session: IAzureAccountSession;
|
||||
subscriptions: azure.subscription.Subscription[];
|
||||
locations: azure.subscription.Location[];
|
||||
groups: azure.resources.ResourceGroup[];
|
||||
}
|
||||
|
||||
export function createContext(): TestContext {
|
||||
const accounts = [{
|
||||
key: undefined!,
|
||||
displayInfo: undefined!,
|
||||
properties: {
|
||||
tenants: [{
|
||||
id: '',
|
||||
displayName: ''
|
||||
}]
|
||||
},
|
||||
isStale: false,
|
||||
isSignedIn: true
|
||||
}];
|
||||
const subscriptions: azure.subscription.Subscription[] = [{ subscriptionId: 'id1' }, { subscriptionId: 'id2' }];
|
||||
const locations: azure.subscription.Location[] = [{ id: 'id1' }, { id: 'id2' }];
|
||||
const groups: azure.resources.ResourceGroup[] = [{ id: 'id1', location: 'l1' }, { id: 'id2', location: 'l2' }];
|
||||
const session: IAzureAccountSession = {
|
||||
account: accounts[0],
|
||||
subscription: subscriptions[0],
|
||||
tenantId: 'tenantId',
|
||||
token: {
|
||||
key: '',
|
||||
token: '',
|
||||
tokenType: '',
|
||||
}
|
||||
};
|
||||
return {
|
||||
groups: groups,
|
||||
locations: locations,
|
||||
subscriptions: subscriptions,
|
||||
session: session,
|
||||
accounts: accounts,
|
||||
azureAccountService: {
|
||||
addAccount: () => Promise.resolve(accounts[0]),
|
||||
getAccounts: () => Promise.resolve(accounts),
|
||||
getAccountSecurityToken: () => Promise.resolve({
|
||||
key: '',
|
||||
token: '',
|
||||
tokenType: ''
|
||||
}),
|
||||
getAccountSessions: () => Promise.resolve([session])
|
||||
},
|
||||
azureResourceService: {
|
||||
getLocations: () => Promise.resolve(locations),
|
||||
getResourceGroups: () => Promise.resolve(groups),
|
||||
createOrUpdateServer: () => Promise.resolve('new_server')
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
describe('Azure SQL client', function (): void {
|
||||
|
||||
it('Should return accounts successfully', async function (): Promise<void> {
|
||||
const testContext = createContext();
|
||||
const azureSqlClient = new AzureSqlClient(() => Promise.resolve(testContext.azureAccountService));
|
||||
const accounts = await azureSqlClient.getAccounts();
|
||||
should(accounts.length).equal(testContext.accounts.length);
|
||||
});
|
||||
|
||||
it('Should create and return new account successfully', async function (): Promise<void> {
|
||||
const testContext = createContext();
|
||||
const azureSqlClient = new AzureSqlClient(() => Promise.resolve(testContext.azureAccountService));
|
||||
const account = await azureSqlClient.getAccount();
|
||||
should(account.key).equal(testContext.accounts[0].key);
|
||||
});
|
||||
|
||||
it('Should return subscriptions successfully', async function (): Promise<void> {
|
||||
const testContext = createContext();
|
||||
const azureSqlClient = new AzureSqlClient(() => Promise.resolve(testContext.azureAccountService));
|
||||
const result = await azureSqlClient.getSessions(testContext.accounts[0]);
|
||||
should(result[0].subscription.id).deepEqual(testContext.subscriptions[0].id);
|
||||
});
|
||||
|
||||
it('Should return locations successfully', async function (): Promise<void> {
|
||||
const testContext = createContext();
|
||||
const azureSqlClient = new AzureSqlClient(() => Promise.resolve(testContext.azureAccountService), () => Promise.resolve(testContext.azureResourceService));
|
||||
const result = await azureSqlClient.getLocations(testContext.session);
|
||||
should(result.length).deepEqual(testContext.locations.length);
|
||||
});
|
||||
|
||||
it('Should return resource groups successfully', async function (): Promise<void> {
|
||||
const testContext = createContext();
|
||||
const azureSqlClient = new AzureSqlClient(() => Promise.resolve(testContext.azureAccountService), () => Promise.resolve(testContext.azureResourceService));
|
||||
const result = await azureSqlClient.getResourceGroups(testContext.session);
|
||||
should(result.length).deepEqual(testContext.groups.length);
|
||||
should(result[0].location).deepEqual(testContext.groups[0].location);
|
||||
});
|
||||
});
|
||||
@@ -11,16 +11,18 @@ import { DeployService } from '../../models/deploy/deployService';
|
||||
import { Project } from '../../models/project';
|
||||
import * as vscode from 'vscode';
|
||||
import * as azdata from 'azdata';
|
||||
import { AppSettingType, IDeployProfile } from '../../models/deploy/deployProfile';
|
||||
import { AppSettingType, ILocalDbDeployProfile, ISqlDbDeployProfile } from '../../models/deploy/deployProfile';
|
||||
import * as UUID from 'vscode-languageclient/lib/utils/uuid';
|
||||
import * as fse from 'fs-extra';
|
||||
import * as path from 'path';
|
||||
import * as constants from '../../common/constants';
|
||||
import { ShellExecutionHelper } from '../../tools/shellExecutionHelper';
|
||||
import * as TypeMoq from 'typemoq';
|
||||
import { AzureSqlClient } from '../../models/deploy/azureSqlClient';
|
||||
|
||||
export interface TestContext {
|
||||
outputChannel: vscode.OutputChannel;
|
||||
azureSqlClient: TypeMoq.IMock<AzureSqlClient>;
|
||||
}
|
||||
|
||||
export const mockConnectionResult: azdata.ConnectionResult = {
|
||||
@@ -47,7 +49,8 @@ export function createContext(): TestContext {
|
||||
show: () => { },
|
||||
hide: () => { },
|
||||
dispose: () => { }
|
||||
}
|
||||
},
|
||||
azureSqlClient: TypeMoq.Mock.ofType(AzureSqlClient)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -68,7 +71,7 @@ describe('deploy service', function (): void {
|
||||
|
||||
it('Should deploy a database to docker container successfully', async function (): Promise<void> {
|
||||
const testContext = createContext();
|
||||
const deployProfile: IDeployProfile = {
|
||||
const deployProfile: ILocalDbDeployProfile = {
|
||||
localDbSetting: {
|
||||
dbName: 'test',
|
||||
password: 'PLACEHOLDER',
|
||||
@@ -84,21 +87,21 @@ describe('deploy service', function (): void {
|
||||
const project1 = await Project.openProject(vscode.Uri.file(projFilePath).fsPath);
|
||||
const shellExecutionHelper = TypeMoq.Mock.ofType(ShellExecutionHelper);
|
||||
shellExecutionHelper.setup(x => x.runStreamedCommand(TypeMoq.It.isAny(),
|
||||
undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('id'));
|
||||
const deployService = new DeployService(testContext.outputChannel, shellExecutionHelper.object);
|
||||
undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('id'));
|
||||
const deployService = new DeployService(testContext.azureSqlClient.object, testContext.outputChannel, shellExecutionHelper.object);
|
||||
sandbox.stub(azdata.connection, 'connect').returns(Promise.resolve(mockConnectionResult));
|
||||
sandbox.stub(azdata.connection, 'getUriForConnection').returns(Promise.resolve('connection'));
|
||||
sandbox.stub(vscode.window, 'showWarningMessage').returns(<any>Promise.resolve(constants.yesString));
|
||||
sandbox.stub(azdata.tasks, 'startBackgroundOperation').callThrough();
|
||||
|
||||
let connection = await deployService.deploy(deployProfile, project1);
|
||||
let connection = await deployService.deployToContainer(deployProfile, project1);
|
||||
should(connection).equals('connection');
|
||||
|
||||
});
|
||||
|
||||
it('Should fail the deploy if docker is not running', async function (): Promise<void> {
|
||||
const testContext = createContext();
|
||||
const deployProfile: IDeployProfile = {
|
||||
const deployProfile: ILocalDbDeployProfile = {
|
||||
localDbSetting: {
|
||||
dbName: 'test',
|
||||
password: 'PLACEHOLDER',
|
||||
@@ -114,11 +117,11 @@ describe('deploy service', function (): void {
|
||||
const project1 = await Project.openProject(vscode.Uri.file(projFilePath).fsPath);
|
||||
const shellExecutionHelper = TypeMoq.Mock.ofType(ShellExecutionHelper);
|
||||
shellExecutionHelper.setup(x => x.runStreamedCommand(TypeMoq.It.isAny(),
|
||||
undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.reject('error'));
|
||||
const deployService = new DeployService(testContext.outputChannel, shellExecutionHelper.object);
|
||||
undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.reject('error'));
|
||||
const deployService = new DeployService(testContext.azureSqlClient.object, testContext.outputChannel, shellExecutionHelper.object);
|
||||
sandbox.stub(azdata.tasks, 'startBackgroundOperation').callThrough();
|
||||
|
||||
await should(deployService.deploy(deployProfile, project1)).rejected();
|
||||
await should(deployService.deployToContainer(deployProfile, project1)).rejected();
|
||||
});
|
||||
|
||||
it('Should retry connecting to the server', async function (): Promise<void> {
|
||||
@@ -136,8 +139,8 @@ describe('deploy service', function (): void {
|
||||
|
||||
const shellExecutionHelper = TypeMoq.Mock.ofType(ShellExecutionHelper);
|
||||
shellExecutionHelper.setup(x => x.runStreamedCommand(TypeMoq.It.isAny(),
|
||||
undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('id'));
|
||||
const deployService = new DeployService(testContext.outputChannel, shellExecutionHelper.object);
|
||||
undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('id'));
|
||||
const deployService = new DeployService(testContext.azureSqlClient.object, testContext.outputChannel, shellExecutionHelper.object);
|
||||
let connectionStub = sandbox.stub(azdata.connection, 'connect');
|
||||
connectionStub.onFirstCall().returns(Promise.resolve(mockFailedConnectionResult));
|
||||
connectionStub.onSecondCall().returns(Promise.resolve(mockConnectionResult));
|
||||
@@ -173,7 +176,7 @@ describe('deploy service', function (): void {
|
||||
const filePath = path.join(project1.projectFolderPath, 'local.settings.json');
|
||||
await fse.writeFile(filePath, settingContent);
|
||||
|
||||
const deployProfile: IDeployProfile = {
|
||||
const deployProfile: ILocalDbDeployProfile = {
|
||||
localDbSetting: {
|
||||
dbName: 'test',
|
||||
password: 'PLACEHOLDER',
|
||||
@@ -194,8 +197,8 @@ describe('deploy service', function (): void {
|
||||
|
||||
const shellExecutionHelper = TypeMoq.Mock.ofType(ShellExecutionHelper);
|
||||
shellExecutionHelper.setup(x => x.runStreamedCommand(TypeMoq.It.isAny(),
|
||||
undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('id'));
|
||||
const deployService = new DeployService(testContext.outputChannel, shellExecutionHelper.object);
|
||||
undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('id'));
|
||||
const deployService = new DeployService(testContext.azureSqlClient.object, testContext.outputChannel, shellExecutionHelper.object);
|
||||
|
||||
await deployService.updateAppSettings(appInteg, deployProfile);
|
||||
let newContent = JSON.parse(fse.readFileSync(filePath, 'utf8'));
|
||||
@@ -228,7 +231,7 @@ describe('deploy service', function (): void {
|
||||
const filePath = path.join(project1.projectFolderPath, 'local.settings.json');
|
||||
await fse.writeFile(filePath, settingContent);
|
||||
|
||||
const deployProfile: IDeployProfile = {
|
||||
const deployProfile: ILocalDbDeployProfile = {
|
||||
|
||||
deploySettings: {
|
||||
connectionUri: 'connection',
|
||||
@@ -245,8 +248,8 @@ describe('deploy service', function (): void {
|
||||
};
|
||||
const shellExecutionHelper = TypeMoq.Mock.ofType(ShellExecutionHelper);
|
||||
shellExecutionHelper.setup(x => x.runStreamedCommand(TypeMoq.It.isAny(),
|
||||
undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('id'));
|
||||
const deployService = new DeployService(testContext.outputChannel, shellExecutionHelper.object);
|
||||
undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('id'));
|
||||
const deployService = new DeployService(testContext.azureSqlClient.object, testContext.outputChannel, shellExecutionHelper.object);
|
||||
let connection = new azdata.connection.ConnectionProfile();
|
||||
sandbox.stub(azdata.connection, 'getConnection').returns(Promise.resolve(connection));
|
||||
|
||||
@@ -260,10 +263,10 @@ describe('deploy service', function (): void {
|
||||
const testContext = createContext();
|
||||
const shellExecutionHelper = TypeMoq.Mock.ofType(ShellExecutionHelper);
|
||||
shellExecutionHelper.setup(x => x.runStreamedCommand(TypeMoq.It.isAny(),
|
||||
undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(`id
|
||||
undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve(`id
|
||||
id2
|
||||
id3`));
|
||||
const deployService = new DeployService(testContext.outputChannel, shellExecutionHelper.object);
|
||||
const deployService = new DeployService(testContext.azureSqlClient.object, testContext.outputChannel, shellExecutionHelper.object);
|
||||
const ids = await deployService.getCurrentDockerContainer('label');
|
||||
await deployService.cleanDockerObjects(ids, ['docker stop', 'docker rm']);
|
||||
shellExecutionHelper.verify(x => x.runStreamedCommand(TypeMoq.It.isAny(), undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny()), TypeMoq.Times.exactly(7));
|
||||
@@ -271,7 +274,7 @@ describe('deploy service', function (): void {
|
||||
|
||||
it('Should create docker image info correctly', () => {
|
||||
const testContext = createContext();
|
||||
const deployService = new DeployService(testContext.outputChannel);
|
||||
const deployService = new DeployService(testContext.azureSqlClient.object, testContext.outputChannel);
|
||||
const id = UUID.generateUuid().toLocaleLowerCase();
|
||||
const baseImage = 'baseImage:latest';
|
||||
const tag = baseImage.replace(':', '-').replace(constants.sqlServerDockerRegistry, '').replace(/[^a-zA-Z0-9_,\-]/g, '').toLocaleLowerCase();
|
||||
@@ -311,4 +314,53 @@ describe('deploy service', function (): void {
|
||||
tag: `${constants.dockerImageNamePrefix}-${imageProjectName}-${tag}`
|
||||
});
|
||||
});
|
||||
|
||||
it('Should create a new Azure SQL server successfully', async function (): Promise<void> {
|
||||
const testContext = createContext();
|
||||
const deployProfile: ISqlDbDeployProfile = {
|
||||
sqlDbSetting: {
|
||||
dbName: 'test',
|
||||
password: 'PLACEHOLDER',
|
||||
port: 1433,
|
||||
serverName: 'localhost',
|
||||
userName: 'sa',
|
||||
connectionRetryTimeout: 1,
|
||||
resourceGroupName: 'resourceGroups',
|
||||
session: {
|
||||
subscription: {
|
||||
subscriptionId: 'subscriptionId',
|
||||
},token: {
|
||||
key: '',
|
||||
token: '',
|
||||
tokenType: '',
|
||||
},
|
||||
tenantId: '',
|
||||
account: undefined!
|
||||
},
|
||||
location: 'location'
|
||||
}
|
||||
};
|
||||
const fullyQualifiedDomainName = 'servername';
|
||||
const shellExecutionHelper = TypeMoq.Mock.ofType(ShellExecutionHelper);
|
||||
shellExecutionHelper.setup(x => x.runStreamedCommand(TypeMoq.It.isAny(),
|
||||
undefined, TypeMoq.It.isAny(), TypeMoq.It.isAny())).returns(() => Promise.resolve('id'));
|
||||
const session = deployProfile?.sqlDbSetting?.session;
|
||||
if (deployProfile?.sqlDbSetting?.session && session) {
|
||||
testContext.azureSqlClient.setup(x => x.createOrUpdateServer(
|
||||
session,
|
||||
deployProfile.sqlDbSetting?.resourceGroupName || '',
|
||||
deployProfile.sqlDbSetting?.serverName || '',
|
||||
{
|
||||
location: deployProfile?.sqlDbSetting?.location || '',
|
||||
administratorLogin: deployProfile?.sqlDbSetting?.userName,
|
||||
administratorLoginPassword: deployProfile?.sqlDbSetting?.password
|
||||
})).returns(() => Promise.resolve(fullyQualifiedDomainName));
|
||||
}
|
||||
sandbox.stub(azdata.connection, 'connect').returns(Promise.resolve(mockConnectionResult));
|
||||
sandbox.stub(azdata.connection, 'getUriForConnection').returns(Promise.resolve('connection'));
|
||||
const deployService = new DeployService(testContext.azureSqlClient.object, testContext.outputChannel, shellExecutionHelper.object);
|
||||
let connection = await deployService.createNewAzureSqlServer(deployProfile);
|
||||
should(deployProfile.sqlDbSetting?.serverName).equal(fullyQualifiedDomainName);
|
||||
should(connection).equals('connection');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ import { ProjectsController } from '../../controllers/projectController';
|
||||
import { IDeploySettings } from '../../models/IDeploySettings';
|
||||
import { emptySqlDatabaseProjectTypeId } from '../../common/constants';
|
||||
import { createContext, mockDacFxOptionsResult, TestContext } from '../testContext';
|
||||
import { IDeployProfile } from '../../models/deploy/deployProfile';
|
||||
import { ILocalDbDeployProfile } from '../../models/deploy/deployProfile';
|
||||
|
||||
let testContext: TestContext;
|
||||
describe('Publish Database Dialog', () => {
|
||||
@@ -112,7 +112,7 @@ describe('Publish Database Dialog', () => {
|
||||
|
||||
should(profile).deepEqual(expectedGenScript);
|
||||
|
||||
const expectedContainerPublishProfile: IDeployProfile = {
|
||||
const expectedContainerPublishProfile: ILocalDbDeployProfile = {
|
||||
localDbSetting: {
|
||||
dbName: 'MockDatabaseName',
|
||||
dockerBaseImage: '',
|
||||
@@ -136,7 +136,7 @@ describe('Publish Database Dialog', () => {
|
||||
}
|
||||
};
|
||||
dialog.object.publishToExistingServer = false;
|
||||
let deployProfile: IDeployProfile | undefined;
|
||||
let deployProfile: ILocalDbDeployProfile | undefined;
|
||||
dialog.object.publishToContainer = (_, prof) => { deployProfile = prof; };
|
||||
await dialog.object.publishClick();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import * as should from 'should';
|
||||
import * as path from 'path';
|
||||
import * as os from 'os';
|
||||
import { createDummyFileStructure } from './testUtils';
|
||||
import { exists, trimUri, removeSqlCmdVariableFormatting, formatSqlCmdVariable, isValidSqlCmdVariableName, timeConversion, validateSqlServerPortNumber, isEmptyString, detectCommandInstallation, isValidSQLPassword } from '../common/utils';
|
||||
import { exists, trimUri, removeSqlCmdVariableFormatting, formatSqlCmdVariable, isValidSqlCmdVariableName, timeConversion, validateSqlServerPortNumber, isEmptyString, detectCommandInstallation, isValidSQLPassword, findSqlVersionInImageName, findSqlVersionInTargetPlatform } from '../common/utils';
|
||||
import { Uri } from 'vscode';
|
||||
|
||||
describe('Tests to verify utils functions', function (): void {
|
||||
@@ -123,5 +123,20 @@ describe('Tests to verify utils functions', function (): void {
|
||||
should(isValidSQLPassword('dFdf65$530')).equals(true, 'dF65$530 is valid password');
|
||||
should(isValidSQLPassword('av1fgh533@')).equals(true, 'dF65$530 is valid password');
|
||||
});
|
||||
|
||||
it('findSqlVersionInImageName should return the version correctly', () => {
|
||||
should(findSqlVersionInImageName('2017-CU1-ubuntu')).equals(2017, 'invalid number returned for 2017-CU1-ubuntu');
|
||||
should(findSqlVersionInImageName('2019-latest')).equals(2019, 'invalid number returned for 2019-latest');
|
||||
should(findSqlVersionInImageName('latest')).equals(undefined, 'invalid number returned for latest');
|
||||
should(findSqlVersionInImageName('latest-ubuntu')).equals(undefined, 'invalid number returned for latest-ubuntu');
|
||||
should(findSqlVersionInImageName('2017-CU20-ubuntu-16.04')).equals(2017, 'invalid number returned for 2017-CU20-ubuntu-16.04');
|
||||
});
|
||||
|
||||
it('findSqlVersionInTargetPlatform should return the version correctly', () => {
|
||||
should(findSqlVersionInTargetPlatform('SQL Server 2012')).equals(2012, 'invalid number returned for SQL Server 2012');
|
||||
should(findSqlVersionInTargetPlatform('SQL Server 2019')).equals(2019, 'invalid number returned for SQL Server 2019');
|
||||
should(findSqlVersionInTargetPlatform('Azure SQL Database')).equals(undefined, 'invalid number returned for Azure SQL Database');
|
||||
should(findSqlVersionInTargetPlatform('Azure Synapse Dedicated SQL Pool')).equals(undefined, 'invalid number returned for Azure Synapse Dedicated SQL Pool');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
502
extensions/types/vscode-mssql.d.ts
vendored
502
extensions/types/vscode-mssql.d.ts
vendored
@@ -45,6 +45,11 @@ declare module 'vscode-mssql' {
|
||||
*/
|
||||
readonly azureAccountService: IAzureAccountService;
|
||||
|
||||
/**
|
||||
* Service for accessing Azure Resources functionality
|
||||
*/
|
||||
readonly azureResourceService: IAzureResourceService;
|
||||
|
||||
/**
|
||||
* Prompts the user to select an existing connection or create a new one, and then returns the result
|
||||
* @param ignoreFocusOut Whether the quickpick prompt ignores focus out (default false)
|
||||
@@ -399,6 +404,13 @@ declare module 'vscode-mssql' {
|
||||
isSignedIn?: boolean;
|
||||
}
|
||||
|
||||
export interface IAzureAccountSession {
|
||||
subscription: azure.subscription.Subscription,
|
||||
tenantId: string,
|
||||
account: IAccount,
|
||||
token: Token
|
||||
}
|
||||
|
||||
export interface TokenKey {
|
||||
/**
|
||||
* Account Key - uniquely identifies an account
|
||||
@@ -437,6 +449,38 @@ declare module 'vscode-mssql' {
|
||||
* Returns an access token for given user and tenant
|
||||
*/
|
||||
getAccountSecurityToken(account: IAccount, tenantId: string | undefined): Promise<Token>;
|
||||
|
||||
/**
|
||||
* Returns Azure subscriptions with tenant and token for each given account
|
||||
*/
|
||||
getAccountSessions(account: IAccount): Promise<IAzureAccountSession[]>;
|
||||
}
|
||||
|
||||
export interface IAzureResourceService {
|
||||
|
||||
/**
|
||||
* Returns Azure resource groups for given subscription
|
||||
* @param session Azure session
|
||||
* @returns List of resource groups
|
||||
*/
|
||||
getResourceGroups(session: IAzureAccountSession): Promise<azure.resources.ResourceGroup[]>;
|
||||
|
||||
/**
|
||||
* Creates or updates a Azure SQL server for given subscription, resource group and location
|
||||
* @param session Azure session
|
||||
* @param resourceGroupName resource group name
|
||||
* @param serverName SQL server name
|
||||
* @param parameters parameters for the SQL server
|
||||
* @returns name of the SQL server
|
||||
*/
|
||||
createOrUpdateServer(session: IAzureAccountSession, resourceGroupName: string, serverName: string, parameters: azure.sql.Server): Promise<string | undefined>;
|
||||
|
||||
/**
|
||||
* Returns Azure locations for given session
|
||||
* @param session Azure session
|
||||
* @returns List of locations
|
||||
*/
|
||||
getLocations(session: IAzureAccountSession): Promise<azure.subscription.Location[]>;
|
||||
}
|
||||
|
||||
export const enum TaskExecutionMode {
|
||||
@@ -725,4 +769,462 @@ declare module 'vscode-mssql' {
|
||||
|
||||
options: { [name: string]: any };
|
||||
}
|
||||
|
||||
/**
|
||||
* Namespace for Azure APIs
|
||||
*/
|
||||
export namespace azure {
|
||||
|
||||
/**
|
||||
* Namespace for Azure Subscriptions. Types from @azure/arm-subscriptions module
|
||||
*/
|
||||
export namespace subscription {
|
||||
/** Location information. */
|
||||
interface Location {
|
||||
/**
|
||||
* The fully qualified ID of the location. For example, /subscriptions/00000000-0000-0000-0000-000000000000/locations/westus.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly id?: string;
|
||||
/**
|
||||
* The subscription ID.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly subscriptionId?: string;
|
||||
/**
|
||||
* The location name.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly name?: string;
|
||||
/**
|
||||
* The display name of the location.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly displayName?: string;
|
||||
/**
|
||||
* The latitude of the location.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly latitude?: string;
|
||||
/**
|
||||
* The longitude of the location.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly longitude?: string;
|
||||
}
|
||||
|
||||
/** Subscription information. */
|
||||
export interface Subscription {
|
||||
/**
|
||||
* The fully qualified ID for the subscription. For example, /subscriptions/00000000-0000-0000-0000-000000000000.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly id?: string;
|
||||
/**
|
||||
* The subscription ID.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly subscriptionId?: string;
|
||||
/**
|
||||
* The subscription display name.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly displayName?: string;
|
||||
/**
|
||||
* The subscription state. Possible values are Enabled, Warned, PastDue, Disabled, and Deleted.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly state?: SubscriptionState;
|
||||
/** The subscription policies. */
|
||||
subscriptionPolicies?: SubscriptionPolicies;
|
||||
/** The authorization source of the request. Valid values are one or more combinations of Legacy, RoleBased, Bypassed, Direct and Management. For example, 'Legacy, RoleBased'. */
|
||||
authorizationSource?: string;
|
||||
}
|
||||
|
||||
/** Defines values for SubscriptionState. */
|
||||
export type SubscriptionState = 'Enabled' | 'Warned' | 'PastDue' | 'Disabled' | 'Deleted';
|
||||
|
||||
|
||||
/** Subscription policies. */
|
||||
export interface SubscriptionPolicies {
|
||||
/**
|
||||
* The subscription location placement ID. The ID indicates which regions are visible for a subscription. For example, a subscription with a location placement Id of Public_2014-09-01 has access to Azure public regions.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly locationPlacementId?: string;
|
||||
/**
|
||||
* The subscription quota ID.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly quotaId?: string;
|
||||
/**
|
||||
* The subscription spending limit.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly spendingLimit?: SpendingLimit;
|
||||
}
|
||||
|
||||
/** Defines values for SpendingLimit. */
|
||||
export type SpendingLimit = 'On' | 'Off' | 'CurrentPeriodOff';
|
||||
}
|
||||
|
||||
/**
|
||||
* Namespace for Azure resources. Types from @azure/arm-resources module
|
||||
*/
|
||||
export namespace resources {
|
||||
export interface ResourceGroup {
|
||||
/**
|
||||
* The ID of the resource group.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly id?: string;
|
||||
/**
|
||||
* The name of the resource group.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly name?: string;
|
||||
/**
|
||||
* The type of the resource group.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly type?: string;
|
||||
/** The resource group properties. */
|
||||
properties?: ResourceGroupProperties;
|
||||
/** The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. */
|
||||
location: string;
|
||||
/** The ID of the resource that manages this resource group. */
|
||||
managedBy?: string;
|
||||
/** The tags attached to the resource group. */
|
||||
tags?: {
|
||||
[propertyName: string]: string;
|
||||
};
|
||||
}
|
||||
|
||||
/** The resource group properties. */
|
||||
export interface ResourceGroupProperties {
|
||||
/**
|
||||
* The provisioning state.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly provisioningState?: string;
|
||||
}
|
||||
|
||||
export interface ResourceGroup {
|
||||
/**
|
||||
* The ID of the resource group.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly id?: string;
|
||||
/**
|
||||
* The name of the resource group.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly name?: string;
|
||||
/**
|
||||
* The type of the resource group.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly type?: string;
|
||||
/** The resource group properties. */
|
||||
properties?: ResourceGroupProperties;
|
||||
/** The location of the resource group. It cannot be changed after the resource group has been created. It must be one of the supported Azure locations. */
|
||||
location: string;
|
||||
/** The ID of the resource that manages this resource group. */
|
||||
managedBy?: string;
|
||||
/** The tags attached to the resource group. */
|
||||
tags?: {
|
||||
[propertyName: string]: string;
|
||||
};
|
||||
}
|
||||
|
||||
/** The resource group properties. */
|
||||
export interface ResourceGroupProperties {
|
||||
/**
|
||||
* The provisioning state.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly provisioningState?: string;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Namespace for Azure SQL APIs. Types from @azure/arm-sql module
|
||||
*/
|
||||
export namespace sql {
|
||||
|
||||
/** ARM resource. */
|
||||
export interface Resource {
|
||||
/**
|
||||
* Resource ID.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly id?: string;
|
||||
/**
|
||||
* Resource name.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly name?: string;
|
||||
/**
|
||||
* Resource type.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly type?: string;
|
||||
}
|
||||
|
||||
/** Azure Active Directory identity configuration for a resource. */
|
||||
export interface UserIdentity {
|
||||
/**
|
||||
* The Azure Active Directory principal id.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly principalId?: string;
|
||||
/**
|
||||
* The Azure Active Directory client id.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly clientId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines values for IdentityType. \
|
||||
* {@link KnownIdentityType} can be used interchangeably with IdentityType,
|
||||
* this enum contains the known values that the service supports.
|
||||
* ### Known values supported by the service
|
||||
* **None** \
|
||||
* **SystemAssigned** \
|
||||
* **UserAssigned** \
|
||||
* **SystemAssigned,UserAssigned**
|
||||
*/
|
||||
export type IdentityType = string;
|
||||
|
||||
/** Azure Active Directory identity configuration for a resource. */
|
||||
export interface ResourceIdentity {
|
||||
/** The resource ids of the user assigned identities to use */
|
||||
userAssignedIdentities?: {
|
||||
[propertyName: string]: UserIdentity;
|
||||
};
|
||||
/**
|
||||
* The Azure Active Directory principal id.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly principalId?: string;
|
||||
/** The identity type. Set this to 'SystemAssigned' in order to automatically create and assign an Azure Active Directory principal for the resource. */
|
||||
type?: IdentityType;
|
||||
/**
|
||||
* The Azure Active Directory tenant id.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly tenantId?: string;
|
||||
}
|
||||
|
||||
/** ARM tracked top level resource. */
|
||||
export type TrackedResource = Resource & {
|
||||
/** Resource location. */
|
||||
location: string;
|
||||
/** Resource tags. */
|
||||
tags?: {
|
||||
[propertyName: string]: string;
|
||||
};
|
||||
};
|
||||
|
||||
/** An Azure SQL Database server. */
|
||||
export type Server = TrackedResource & {
|
||||
/** The Azure Active Directory identity of the server. */
|
||||
identity?: ResourceIdentity;
|
||||
/**
|
||||
* Kind of sql server. This is metadata used for the Azure portal experience.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly kind?: string;
|
||||
/** Administrator username for the server. Once created it cannot be changed. */
|
||||
administratorLogin?: string;
|
||||
/** The administrator login password (required for server creation). */
|
||||
administratorLoginPassword?: string;
|
||||
/** The version of the server. */
|
||||
version?: string;
|
||||
/**
|
||||
* The state of the server.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly state?: string;
|
||||
/**
|
||||
* The fully qualified domain name of the server.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly fullyQualifiedDomainName?: string;
|
||||
/**
|
||||
* List of private endpoint connections on a server
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly privateEndpointConnections?: ServerPrivateEndpointConnection[];
|
||||
/** Minimal TLS version. Allowed values: '1.0', '1.1', '1.2' */
|
||||
minimalTlsVersion?: string;
|
||||
/** Whether or not public endpoint access is allowed for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled' */
|
||||
publicNetworkAccess?: ServerNetworkAccessFlag;
|
||||
/**
|
||||
* Whether or not existing server has a workspace created and if it allows connection from workspace
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly workspaceFeature?: ServerWorkspaceFeature;
|
||||
/** The resource id of a user assigned identity to be used by default. */
|
||||
primaryUserAssignedIdentityId?: string;
|
||||
/** The Client id used for cross tenant CMK scenario */
|
||||
federatedClientId?: string;
|
||||
/** A CMK URI of the key to use for encryption. */
|
||||
keyId?: string;
|
||||
/** The Azure Active Directory identity of the server. */
|
||||
administrators?: ServerExternalAdministrator;
|
||||
/** Whether or not to restrict outbound network access for this server. Value is optional but if passed in, must be 'Enabled' or 'Disabled' */
|
||||
restrictOutboundNetworkAccess?: ServerNetworkAccessFlag;
|
||||
};
|
||||
|
||||
/** A private endpoint connection under a server */
|
||||
export interface ServerPrivateEndpointConnection {
|
||||
/**
|
||||
* Resource ID.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly id?: string;
|
||||
/**
|
||||
* Private endpoint connection properties
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly properties?: PrivateEndpointConnectionProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines values for ServerNetworkAccessFlag. \
|
||||
* {@link KnownServerNetworkAccessFlag} can be used interchangeably with ServerNetworkAccessFlag,
|
||||
* this enum contains the known values that the service supports.
|
||||
* ### Known values supported by the service
|
||||
* **Enabled** \
|
||||
* **Disabled**
|
||||
*/
|
||||
export type ServerNetworkAccessFlag = string;
|
||||
|
||||
/**
|
||||
* Defines values for ServerWorkspaceFeature. \
|
||||
* {@link KnownServerWorkspaceFeature} can be used interchangeably with ServerWorkspaceFeature,
|
||||
* this enum contains the known values that the service supports.
|
||||
* ### Known values supported by the service
|
||||
* **Connected** \
|
||||
* **Disconnected**
|
||||
*/
|
||||
export type ServerWorkspaceFeature = string;
|
||||
|
||||
/** Properties of a active directory administrator. */
|
||||
export interface ServerExternalAdministrator {
|
||||
/** Type of the sever administrator. */
|
||||
administratorType?: AdministratorType;
|
||||
/** Principal Type of the sever administrator. */
|
||||
principalType?: PrincipalType;
|
||||
/** Login name of the server administrator. */
|
||||
login?: string;
|
||||
/** SID (object ID) of the server administrator. */
|
||||
sid?: string;
|
||||
/** Tenant ID of the administrator. */
|
||||
tenantId?: string;
|
||||
/** Azure Active Directory only Authentication enabled. */
|
||||
azureADOnlyAuthentication?: boolean;
|
||||
}
|
||||
|
||||
|
||||
/** Properties of a private endpoint connection. */
|
||||
export interface PrivateEndpointConnectionProperties {
|
||||
/** Private endpoint which the connection belongs to. */
|
||||
privateEndpoint?: PrivateEndpointProperty;
|
||||
/** Connection state of the private endpoint connection. */
|
||||
privateLinkServiceConnectionState?: PrivateLinkServiceConnectionStateProperty;
|
||||
/**
|
||||
* State of the private endpoint connection.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly provisioningState?: PrivateEndpointProvisioningState;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines values for AdministratorType. \
|
||||
* {@link KnownAdministratorType} can be used interchangeably with AdministratorType,
|
||||
* this enum contains the known values that the service supports.
|
||||
* ### Known values supported by the service
|
||||
* **ActiveDirectory**
|
||||
*/
|
||||
export type AdministratorType = string;
|
||||
|
||||
/**
|
||||
* Defines values for PrincipalType. \
|
||||
* {@link KnownPrincipalType} can be used interchangeably with PrincipalType,
|
||||
* this enum contains the known values that the service supports.
|
||||
* ### Known values supported by the service
|
||||
* **User** \
|
||||
* **Group** \
|
||||
* **Application**
|
||||
*/
|
||||
export type PrincipalType = string;
|
||||
|
||||
export interface PrivateEndpointProperty {
|
||||
/** Resource id of the private endpoint. */
|
||||
id?: string;
|
||||
}
|
||||
|
||||
export interface PrivateLinkServiceConnectionStateProperty {
|
||||
/** The private link service connection status. */
|
||||
status: PrivateLinkServiceConnectionStateStatus;
|
||||
/** The private link service connection description. */
|
||||
description: string;
|
||||
/**
|
||||
* The actions required for private link service connection.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
readonly actionsRequired?: PrivateLinkServiceConnectionStateActionsRequire;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines values for PrivateEndpointProvisioningState. \
|
||||
* {@link KnownPrivateEndpointProvisioningState} can be used interchangeably with PrivateEndpointProvisioningState,
|
||||
* this enum contains the known values that the service supports.
|
||||
* ### Known values supported by the service
|
||||
* **Approving** \
|
||||
* **Ready** \
|
||||
* **Dropping** \
|
||||
* **Failed** \
|
||||
* **Rejecting**
|
||||
*/
|
||||
export type PrivateEndpointProvisioningState = string;
|
||||
|
||||
/**
|
||||
* Defines values for PrivateLinkServiceConnectionStateStatus. \
|
||||
* {@link KnownPrivateLinkServiceConnectionStateStatus} can be used interchangeably with PrivateLinkServiceConnectionStateStatus,
|
||||
* this enum contains the known values that the service supports.
|
||||
* ### Known values supported by the service
|
||||
* **Approved** \
|
||||
* **Pending** \
|
||||
* **Rejected** \
|
||||
* **Disconnected**
|
||||
*/
|
||||
export type PrivateLinkServiceConnectionStateStatus = string;
|
||||
|
||||
/**
|
||||
* Defines values for PrivateLinkServiceConnectionStateActionsRequire. \
|
||||
* {@link KnownPrivateLinkServiceConnectionStateActionsRequire} can be used interchangeably with PrivateLinkServiceConnectionStateActionsRequire,
|
||||
* this enum contains the known values that the service supports.
|
||||
* ### Known values supported by the service
|
||||
* **None**
|
||||
*/
|
||||
export type PrivateLinkServiceConnectionStateActionsRequire = string;
|
||||
|
||||
export interface PrivateLinkServiceConnectionStateProperty {
|
||||
/** The private link service connection status. */
|
||||
status: PrivateLinkServiceConnectionStateStatus;
|
||||
/** The private link service connection description. */
|
||||
description: string;
|
||||
/**
|
||||
* The actions required for private link service connection.
|
||||
* NOTE: This property will not be serialized. It can only be populated by the server.
|
||||
*/
|
||||
|
||||
readonly actionsRequired?: PrivateLinkServiceConnectionStateActionsRequire;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "azuredatastudio",
|
||||
"version": "1.36.1",
|
||||
"version": "1.36.2",
|
||||
"distro": "8f4d839fbcb98eaa7aa3fd8bf9f84ab9bae899d9",
|
||||
"author": {
|
||||
"name": "Microsoft Corporation"
|
||||
@@ -75,7 +75,7 @@
|
||||
"angular2-grid": "2.0.6",
|
||||
"ansi_up": "^5.1.0",
|
||||
"applicationinsights": "1.0.8",
|
||||
"azdataGraph": "github:Microsoft/azdataGraph#0.0.20",
|
||||
"azdataGraph": "github:Microsoft/azdataGraph#0.0.21",
|
||||
"chart.js": "^2.9.4",
|
||||
"chokidar": "3.5.2",
|
||||
"graceful-fs": "4.2.6",
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
"applicationinsights": "1.0.8",
|
||||
"angular2-grid": "2.0.6",
|
||||
"ansi_up": "^5.1.0",
|
||||
"azdataGraph": "github:Microsoft/azdataGraph#0.0.20",
|
||||
"azdataGraph": "github:Microsoft/azdataGraph#0.0.21",
|
||||
"chart.js": "^2.9.4",
|
||||
"chokidar": "3.5.2",
|
||||
"cookie": "^0.4.0",
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
"@vscode/vscode-languagedetection": "1.0.18",
|
||||
"angular2-grid": "2.0.6",
|
||||
"ansi_up": "^5.1.0",
|
||||
"azdataGraph": "github:Microsoft/azdataGraph#0.0.20",
|
||||
"azdataGraph": "github:Microsoft/azdataGraph#0.0.21",
|
||||
"chart.js": "^2.9.4",
|
||||
"gridstack": "^3.1.3",
|
||||
"kburtram-query-plan": "2.6.1",
|
||||
|
||||
@@ -150,9 +150,9 @@ array-uniq@^1.0.2:
|
||||
resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6"
|
||||
integrity sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=
|
||||
|
||||
"azdataGraph@github:Microsoft/azdataGraph#0.0.20":
|
||||
version "0.0.20"
|
||||
resolved "https://codeload.github.com/Microsoft/azdataGraph/tar.gz/d685f37f72f0b22c42d15fbb725b3a5a5b3d71ae"
|
||||
"azdataGraph@github:Microsoft/azdataGraph#0.0.21":
|
||||
version "0.0.21"
|
||||
resolved "https://codeload.github.com/Microsoft/azdataGraph/tar.gz/59f38fc96ab8beadb5ed2b6986ae3f39d662d040"
|
||||
|
||||
chalk@^2.3.0, chalk@^2.4.1:
|
||||
version "2.4.2"
|
||||
|
||||
@@ -198,9 +198,9 @@ array-uniq@^1.0.2:
|
||||
resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6"
|
||||
integrity sha1-r2rId6Jcx/dOBYiUdThY39sk/bY=
|
||||
|
||||
"azdataGraph@github:Microsoft/azdataGraph#0.0.20":
|
||||
version "0.0.20"
|
||||
resolved "https://codeload.github.com/Microsoft/azdataGraph/tar.gz/d685f37f72f0b22c42d15fbb725b3a5a5b3d71ae"
|
||||
"azdataGraph@github:Microsoft/azdataGraph#0.0.21":
|
||||
version "0.0.21"
|
||||
resolved "https://codeload.github.com/Microsoft/azdataGraph/tar.gz/59f38fc96ab8beadb5ed2b6986ae3f39d662d040"
|
||||
|
||||
binary-extensions@^2.0.0:
|
||||
version "2.0.0"
|
||||
|
||||
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 {
|
||||
|
||||
@@ -111,7 +111,7 @@ export class AzdataGraphView {
|
||||
* Zooms in to the diagram.
|
||||
*/
|
||||
public zoomIn(): void {
|
||||
this._diagram.graph.zoomIn();
|
||||
this._diagram.zoomIn();
|
||||
}
|
||||
|
||||
|
||||
@@ -119,16 +119,14 @@ export class AzdataGraphView {
|
||||
* Zooms out of the diagram
|
||||
*/
|
||||
public zoomOut(): void {
|
||||
this._diagram.graph.zoomOut();
|
||||
this._diagram.zoomOut();
|
||||
}
|
||||
|
||||
/**
|
||||
* Fits the diagram into the parent container size.
|
||||
*/
|
||||
public zoomToFit(): void {
|
||||
this._diagram.graph.fit();
|
||||
this._diagram.graph.view.rendering = true;
|
||||
this._diagram.graph.view.refresh();
|
||||
this._diagram.zoomToFit();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +144,7 @@ export class AzdataGraphView {
|
||||
if (level < 1) {
|
||||
throw new Error(localize('invalidExecutionPlanZoomError', "Zoom level cannot be 0 or negative"));
|
||||
}
|
||||
this._diagram.graph.view.setScale(level / 100);
|
||||
this._diagram.zoomTo(level);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,19 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 25.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 16 16" style="enable-background:new 0 0 16 16;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#F6F6F6;fill-opacity:0;}
|
||||
.st1{fill:#F6F6F6;}
|
||||
.st2{fill:#DCB67A;}
|
||||
.st3{fill:#424242;}
|
||||
</style>
|
||||
<path id="canvas" class="st0" d="M16,16H0V0h16V16z"/>
|
||||
<circle class="st1" cx="8" cy="8" r="8"/>
|
||||
<circle class="st2" cx="8" cy="8" r="7"/>
|
||||
<g id="iconBg">
|
||||
<path class="st3" d="M3,5.5C3,4.7,3.7,4,4.5,4c0.7,0,1.2,0.4,1.4,1h5.2l-0.9-0.9l0.7-0.7L13,5.5l-2.1,2.1l-0.7-0.7L11.1,6H5.9
|
||||
C5.7,6.6,5.2,7,4.5,7C3.7,7,3,6.3,3,5.5z M10.2,9.1l0.9,0.9H5.9C5.7,9.4,5.2,9,4.5,9C3.7,9,3,9.7,3,10.5S3.7,12,4.5,12
|
||||
c0.7,0,1.2-0.4,1.4-1h5.2l-0.9,0.9l0.7,0.7l2.1-2.1l-2.1-2.1C10.9,8.4,10.2,9.1,10.2,9.1z"/>
|
||||
</g>
|
||||
<svg id="fd8a72cd-0f76-430d-b563-1cfd12e162a7" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path id="f8e19413-ab25-4f75-80be-8af00a2b851f" data-name="canvas" d="M16,16H0V0H16Z" fill="#f6f6f6" fill-opacity="0"/>
|
||||
<circle cx="8" cy="8" r="8" fill="#f6f6f6"/>
|
||||
<circle cx="8" cy="8" r="7" fill="#dcb67a"/>
|
||||
<g id="aeca0109-615d-41d0-81c7-d18f9815e720" data-name="iconBg">
|
||||
<path d="M13,10.5A1.538,1.538,0,0,1,11.5,12a1.412,1.412,0,0,1-1.4-1H4.9l.9.9-.7.7L3,10.5,5.1,8.4l.7.7-.9.9h5.2a1.412,1.412,0,0,1,1.4-1A1.538,1.538,0,0,1,13,10.5ZM5.8,6.9,4.9,6h5.2a1.412,1.412,0,0,0,1.4,1A1.538,1.538,0,0,0,13,5.5,1.538,1.538,0,0,0,11.5,4a1.412,1.412,0,0,0-1.4,1H4.9l.9-.9-.7-.7L3,5.5,5.1,7.6Z" fill="#424242"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
||||
|
Before Width: | Height: | Size: 976 B After Width: | Height: | Size: 774 B |
@@ -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.
|
||||
|
||||
@@ -1831,9 +1831,9 @@ aws4@^1.8.0:
|
||||
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.8.0.tgz#f0e003d9ca9e7f59c7a508945d7b2ef9a04a542f"
|
||||
integrity sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ==
|
||||
|
||||
"azdataGraph@github:Microsoft/azdataGraph#0.0.20":
|
||||
version "0.0.20"
|
||||
resolved "https://codeload.github.com/Microsoft/azdataGraph/tar.gz/d685f37f72f0b22c42d15fbb725b3a5a5b3d71ae"
|
||||
"azdataGraph@github:Microsoft/azdataGraph#0.0.21":
|
||||
version "0.0.21"
|
||||
resolved "https://codeload.github.com/Microsoft/azdataGraph/tar.gz/59f38fc96ab8beadb5ed2b6986ae3f39d662d040"
|
||||
|
||||
azure-storage@^2.10.2:
|
||||
version "2.10.2"
|
||||
|
||||
Reference in New Issue
Block a user