Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function findTreeItem(query: TreeItemQuery): Promise {
return await callWithTelemetryAndErrorHandling('api.findTreeItem', async (context: IActionContext) => {
context.errorHandling.suppressDisplay = true;
context.errorHandling.rethrow = true;
const connectionString = query.connectionString;
let parsedCS: ParsedConnectionString;
if (/^mongodb[^:]*:\/\//i.test(connectionString)) {
parsedCS = await parseMongoConnectionString(connectionString);
} else {
parsedCS = parseDocDBConnectionString(connectionString);
}
const maxTime = Date.now() + 10 * 1000; // Give up searching subscriptions after 10 seconds and just attach the account
// 1. Get result from cache if possible
let result: DatabaseAccountTreeItem | DatabaseTreeItem | undefined = tryGetTreeItemFromCache(parsedCS);
const state: string | undefined = await siteClient.getState();
if (state && state.toLowerCase() === 'stopped') {
throw new Error(localize('remoteDebugStopped', 'The app must be running, but is currently in state "Stopped". Start the app to continue.'));
}
if (isRemoteDebuggingToBeEnabled !== siteConfig.remoteDebuggingEnabled) {
const confirmButton: vscode.MessageItem = isRemoteDebuggingToBeEnabled ? { title: 'Enable' } : { title: 'Disable' };
// don't have to check input as this handles cancels and learnMore responses
await ext.ui.showWarningMessage(confirmMessage, { modal: true, learnMoreLink }, confirmButton, DialogResponses.cancel);
siteConfig.remoteDebuggingEnabled = isRemoteDebuggingToBeEnabled;
if (progress) {
reportMessage(localize('remoteDebugUpdate', 'Updating site configuration to set remote debugging...'), progress);
}
await callWithTelemetryAndErrorHandling('appService.remoteDebugUpdateConfiguration', async (context: IActionContext) => {
context.errorHandling.suppressDisplay = true;
context.errorHandling.rethrow = true;
await siteClient.updateConfiguration(siteConfig);
});
if (progress) {
reportMessage(localize('remoteDebugUpdateDone', 'Updating site configuration done.'), progress);
}
} else {
// Update not needed
if (noopMessage) {
vscode.window.showWarningMessage(noopMessage);
}
}
}
private logFunctionCounts(deploymentTemplate: DeploymentTemplate): void {
let me = this;
// Don't wait for promise
let dummyPromise = callWithTelemetryAndErrorHandling("tle.stats", async function (this: IActionContext) {
this.suppressErrorDisplay = true;
let properties: {
functionCounts?: string,
unrecognized?: string,
incorrectArgs?: string,
[key: string]: string
} = this.properties;
// Full function counts
//
// Note: Due to the way DeploymentTemplate is implemented (see quotedStringToTleParseResultMap), string expressions which are exactly
// the same (e.g. 'prop1': '[add(1,2)]' and 'prop2': '[add(1,2)]') only get counted once, thus the functions inside them will only get
// counted once.
const functionCounts: Histogram = deploymentTemplate.functionCounts;
const functionsData = {};
for (const functionName of functionCounts.keys) {
async function acquireDotnet(dotnetExePath: string): Promise {
return await callWithTelemetryAndErrorHandling('acquireDotnet', async (actionContext: IActionContext) => {
actionContext.errorHandling.rethrow = true;
dotnetExePath = await dotnetAcquire(dotnetVersion, actionContext.telemetry.properties);
if (!(await fse.pathExists(dotnetExePath)) || !(await fse.stat(dotnetExePath)).isFile) {
throw new Error(`Unexpected path returned for .net core: ${dotnetExePath}`);
}
ext.outputChannel.appendLine(`Using dotnet core from ${dotnetExePath}`);
// Telemetry: dotnet version actually used
try {
// E.g. "c:\Users\\AppData\Roaming\Code - Insiders\User\globalStorage\msazurermtools.azurerm-vscode-tools\.dotnet\2.2.5\dotnet.exe"
let actualVersion = dotnetExePath.match(/dotnet[\\/]([^\\/]+)[\\/]/)[1];
actionContext.telemetry.properties.dotnetVersionInstalled = actualVersion;
} catch (error) {
// ignore (telemetry only)
}
async function ensureDependencies(dotnetExePath: string, serverDllPath: string): Promise {
await callWithTelemetryAndErrorHandling('ensureDotnetDependencies', async (actionContext: IActionContext) => {
actionContext.errorHandling.rethrow = true;
// Attempt to determine by running a .net app whether additional runtime dependencies are missing on the machine (Linux only),
// and if necessary prompt the user whether to install them.
await ensureDotnetDependencies(
dotnetExePath,
[
serverDllPath,
'--help'
],
actionContext.telemetry.properties);
});
}
await runTrigger(tree, node);
});
registerCommand("azureLogicApps.selectSubscriptions", () => {
vscode.commands.executeCommand("azure-account.selectSubscriptions");
});
registerEvent(
"azureLogicApps.logicAppEditor.onDidSaveTextDocument",
vscode.workspace.onDidSaveTextDocument,
async function (this: IActionContext, document: vscode.TextDocument): Promise {
await logicAppEditor.onDidSaveTextDocument(this, context.globalState, document);
});
});
await callWithTelemetryAndErrorHandling("azIntegrationAccounts.activate", async function activateCallback(this: IActionContext): Promise {
this.properties.isActivationEvent = "true";
const integrationAccountProvider = new IntegrationAccountProvider();
const integrationAccountTree = new AzureTreeDataProvider(integrationAccountProvider, "azIntegrationAccounts.loadMore");
context.subscriptions.push(integrationAccountTree);
context.subscriptions.push(vscode.window.registerTreeDataProvider("azureIntegrationAccountsExplorer", integrationAccountTree));
const integrationAccountAgreementEditor = new IntegrationAccountAgreementEditor();
context.subscriptions.push(integrationAccountAgreementEditor);
const integrationAccountMapEditor = new IntegrationAccountMapEditor();
context.subscriptions.push(integrationAccountMapEditor);
const integrationAccountPartnerEditor = new IntegrationAccountPartnerEditor();
context.subscriptions.push(integrationAccountMapEditor);
export async function activateInternal(context: vscode.ExtensionContext, perfStats: { loadStartTime: number, loadEndTime: number }): Promise {
ext.context = context;
ext.reporter = createTelemetryReporter(context);
ext.outputChannel = vscode.window.createOutputChannel("Azure Resource Manager Tools");
ext.ui = new AzureUserInput(context.globalState);
registerUIExtensionVariables(ext);
await callWithTelemetryAndErrorHandling('activate', async function (this: IActionContext): Promise {
this.properties.isActivationEvent = 'true';
this.measurements.mainFileLoad = (perfStats.loadEndTime - perfStats.loadStartTime) / 1000;
context.subscriptions.push(new AzureRMTools(context));
});
}
export async function pickTreeItem(options: PickTreeItemOptions): Promise {
return await callWithTelemetryAndErrorHandling('api.pickTreeItem', async (context: IActionContext) => {
context.errorHandling.suppressDisplay = true;
context.errorHandling.rethrow = true;
let contextValuesToFind;
switch (options.resourceType) {
case 'Database':
contextValuesToFind = options.apiType ? options.apiType.map(getDatabaseContextValue) : databaseContextValues;
break;
case 'DatabaseAccount':
contextValuesToFind = options.apiType ? options.apiType.map(getAccountContextValue) : accountContextValues;
contextValuesToFind = contextValuesToFind.concat(contextValuesToFind.map((val: string) => val + AttachedAccountSuffix));
break;
default:
throw new RangeError(`Unsupported resource type "${options.resourceType}".`);
}
ext.outputChannel = outputChannel;
context.subscriptions.push(outputChannel);
let reporter: TelemetryReporter | undefined;
try {
const { aiKey, name, version } = readJson(context.asAbsolutePath("./package.json"));
reporter = new TelemetryReporter(name, version, aiKey);
ext.reporter = reporter;
context.subscriptions.push(reporter);
} catch (error) {
}
const ui = new AzureUserInput(context.globalState);
ext.ui = ui;
await callWithTelemetryAndErrorHandling("azureLogicApps.activate", async function activateCallback(this: IActionContext): Promise {
this.properties.isActivationEvent = "true";
const logicAppsProvider = new LogicAppsProvider();
const tree = new AzureTreeDataProvider(logicAppsProvider, "azureLogicApps.loadMore");
context.subscriptions.push(tree);
context.subscriptions.push(vscode.window.registerTreeDataProvider("azureLogicAppsExplorer", tree));
const logicAppEditor = new LogicAppEditor();
context.subscriptions.push(logicAppEditor);
registerCommand("azureLogicApps.addBuildDefinitionToProject", async (uri?: vscode.Uri) => {
if (uri) {
const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);
if (workspaceFolder) {
await addBuildDefinitionToProject(workspaceFolder.uri.fsPath);
} else {