Skip to content

Instantly share code, notes, and snippets.

@gbellmann
gbellmann / InsertOrders.cs
Created Apr 13, 2015
Inserting multiple entities into Azure Table Storage as part of a batch operation
View InsertOrders.cs
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Table;
public void InsertOrders(CloudStorageAccount storageAccount)
{
CloudTableClient tableClient = storageAccount.CreateCloudTableClient();
CloudTable table = tableClient.GetTableReference("orders");
TableBatchOperation batchOperation = new TableBatchOperation();
OrderEntity newOrder1 = new OrderEntity("Smith", "20150410");
@gbellmann
gbellmann / sample-app.csproj
Created Jul 19, 2018
Modified .csproj file for when you need to add bundled scripts that are not included in your project file to the MSDeploy package.
View sample-app.csproj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
<PropertyGroup>
<CopyAllFilesToSingleFolderForMSDeployDependsOn>
CustomCollectFiles;
$(CopyAllFilesToSingleFolderForMSDeployDependsOn);
</CopyAllFilesToSingleFolderForMSDeployDependsOn>
@gbellmann
gbellmann / My404Filter.cs
Created Jan 29, 2017
Telemetry processor to ignore certain 404 errors in Application Insights
View My404Filter.cs
using System;
using Microsoft.ApplicationInsights.Channel;
using Microsoft.ApplicationInsights.DataContracts;
using Microsoft.ApplicationInsights.Extensibility;
namespace Samples
{
public class My404Filter : ITelemetryProcessor
{
private ITelemetryProcessor Next { get; set; }
View simpleTest.spec.js
describe("Una suite es una función", function() {
it("y una spec también es una función", function() {
expect(true).toBe(true);
});
it("cada spec testea un caso", function() {
expect(false).not.toBe(true);
});
});
View global.asax.cs
using System.Web;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using Samples.App_Start;
namespace Samples
{
public class MvcApplication : HttpApplication
{
@gbellmann
gbellmann / AppInsightsConfig.cs
Created Jan 29, 2017
Helper class to configure Application Insights and our Telemetry Processor
View AppInsightsConfig.cs
using System.Configuration;
using Microsoft.ApplicationInsights.Extensibility;
namespace Samples.App_Start
{
public static class AppInsightsConfig
{
public static void RegisterAppInsights()
{
TelemetryConfiguration.Active.InstrumentationKey =
@gbellmann
gbellmann / index.js
Created Sep 11, 2016
Sample Node.js Azure Function using a require to import a library
View index.js
// Importamos la librería underscore.js
var _ = require('underscore');
module.exports = function(context) {
// Usamos la librería underscore.js que importamos
var matched_names = _
.where(context.bindings.myInput.names, {first: 'Juan'});
// El resto del código de nuestra función
}
@gbellmann
gbellmann / index.js
Last active Sep 11, 2016
Azure Function written with Node.js using named arguments
View index.js
// O se pueden incluir parámetros adicionales como variables de entrada
module.exports = function(context, miDisparador, miEntrada, miOtraEntrada) {
// la lógica de la función va aquí
};
@gbellmann
gbellmann / index.js
Created Sep 11, 2016
Azure Function written with Node.js using optional arguments
View index.js
// Se debe incluir el context, pero los otros argumentos son opcionales
module.exports = function(context) {
// Las variables de entrada adicionales pueden accederse en la propiedad arguments
if(arguments.length === 2) {
context.log('La función recibió 2 argumentos de entrada');
}
};
@gbellmann
gbellmann / run.csx
Created Sep 11, 2016
Default C# Azure Function code triggered by a timer
View run.csx
using System;
public static void Run(TimerInfo myTimer, TraceWriter log)
{
log.Info($"Función con trigger por timer en C# ejecutada el {DateTime.Now}");
}
You can’t perform that action at this time.