Skip to content

Instantly share code, notes, and snippets.

client.trackMetric(
{
name: "custom metric:POC app-2609-100",
value: 7.5,
properties: {
testValueA: 1,
testValueB: `Apple`
}
});
appInsights.setup(config.applicationInsightsKey);
appInsights.start();
// set dimensions so reports can distinquish the origin of the logger.
appInsights.defaultClient.commonProperties = {
customProperty1: config.Id,
customProperty2: config.Name
};
client = new appInsights.TelemetryClient(config.applicationInsightsKey);
const appInsights = require("applicationinsights")
let client = appInsights.defaultClient;
// this config part should be set in ENVIRONMENT VARIABLES
let config = {
Id: "xxxxxxxx-xxxx-xxxx-xxxx-26728f1bb4e9",
Name: "Server-Q12",
applicationInsightsKey: "xxxxxxxx-xxxx-xxxx-xxxx-d7a116b10831"
}
let client = appInsights.defaultClient;
client.trackEvent({name: "my custom event", properties: {customProperty: "custom property value"}});
client.trackException({exception: new Error("handled exceptions can be logged with this method")});
client.trackMetric({name: "custom metric", value: 3});
client.trackTrace({message: "trace message"});
client.trackDependency({target:"http://dbname", name:"select customers proc", data:"SELECT * FROM Customers", duration:231, resultCode:0, success: true, dependencyTypeName: "ZSQL"});
client.trackRequest({name:"GET /customers", url:"http://myserver/customers", duration:309, resultCode:200, success:true});
var file_url = 'https://downloadurl.com/files/my_zip_file.zip';
var AdmZip = require('adm-zip'); //Reference: https://www.npmjs.com/package/adm-zip
var https = require('https');
var fs = require('fs')
https.get(file_url, function (res) {
var data = [], dataLen = 0;
res.on('data', function (chunk) {
Add-Type -outputtype consoleapplication -outputassembly helloworld.exe 'public class helloworld{public static void Main(){System.Console.WriteLine("hello world");}}'
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Extensions.Logging;
using System;
using System.Diagnostics;
using System.Threading.Tasks;
namespace execFuncApp
const debug = ""; //Import your Logger here or use Console just in case.
const nodegit = require("nodegit");
const fs = require('fs');
const path = require("path");
const fse = require("fs-extra");
const dir = `./backup/`
const repoFolder = `${dir}.git`;
var privateKey, publicKey, passphrase, twoWaySync, url, credentialsCallback, signature_name, signature_email;
var config = {
"options": {
"privateKey": "<pathToPrivateKey>/MyKeyFile",
"publicKey": "<pathToPublicKey>/MyKeyFile.pub",
"passphrase": "Y0ur.P@5$p#rAse.G0e5.H3rE!",
"twoWaySync": true,
"sshUrl": "<get_this_sshUrl_from_git>",
"signature_name": "Someone's Name",
"signature_email": "SomeoneWho@isMakingThisCommit.dev"
async function CloneRepo() {
var cloneOptions = {
fetchOpts: { callbacks: credentialsCallback }
};
nodegit.Clone(url, dir, cloneOptions).then(function (repo) {
debug.verbose("Cloned " + path.basename(url) + " to " + repo.workdir());
}).catch(function (err) {
debug.verbose(err);
});
}