Skip to content

Instantly share code, notes, and snippets.

View JanneMattila's full-sized avatar

Janne Mattila JanneMattila

View GitHub Profile
@JanneMattila
JanneMattila / ab.sh
Created May 2, 2019 11:29
Apache HTTP server benchmarking tool in action
j@janne:~$ ab -n 1000 -c 15 https://stockwebappnwusdwyqedabc.azurewebsites.net/Errors/Random
This is ApacheBench, Version 2.3 <$Revision: 1706008 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking stockwebappnwusdwyqedabc.azurewebsites.net (be patient)
Completed 100 requests
Completed 200 requests
Completed 300 requests
Completed 400 requests
@JanneMattila
JanneMattila / deploy.ps1
Created April 26, 2019 12:11
Azure Front Door Service demo application deployment script
Param (
[Parameter(HelpMessage="Deployment target resource group")]
[string] $ResourceGroupName = "frontdoor-local-rg",
[Parameter(HelpMessage="Deployment target resource group location")]
[string] $Location = "North Europe",
[Parameter(HelpMessage="Front Door Name")]
[string] $FrontDoorName = "contosohqlocal",
@JanneMattila
JanneMattila / Deploy output
Created April 26, 2019 11:35
Azure Front Door Service
# .\deploy.ps1
Not executing inside Azure DevOps Release Management.
Make sure you have done "Login-AzAccount" and
"Select-AzSubscription -SubscriptionName name"
so that script continues to work correctly for you.
WARNING: Resource group 'frontdoor-local-rg' doesn't exist and it will be created.
VERBOSE: Performing the operation "Replacing resource group ..." on target "frontdoor-local-rg".
VERBOSE: 2:32:06 PM - Created resource group 'frontdoor-local-rg' in location 'northeurope'
@JanneMattila
JanneMattila / IndexView.ts
Created April 24, 2019 19:51
Azure App Configuration
let canvas = <HTMLCanvasElement>document.getElementById("canvas");
let context = canvas.getContext("2d");
context.clearRect(0, 0, canvas.width, canvas.height);
const lineSpaceWidth = 50;
for (let i = 0; i <= this.canvas.width / lineSpaceWidth; i++) {
const line = i * lineSpaceWidth;
context.beginPath();
context.moveTo(line, 0);
@JanneMattila
JanneMattila / DataController.cs
Last active April 24, 2019 20:12
Azure App Configuration
using System.Collections.Generic;
using FeatureTogglerApp.Features;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
namespace FeatureTogglerApp.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class DataController : ControllerBase
@JanneMattila
JanneMattila / Index.cshtml
Created April 24, 2019 19:39
Azure App Configuration
@page
@using Microsoft.Extensions.Options
@using FeatureTogglerApp.Features
@inject IOptionsSnapshot<FeatureOptions> featureOptions
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
<div class="text-center">
@JanneMattila
JanneMattila / FeatureOptions.cs
Created April 24, 2019 19:36
Azure App Configuration
using System.Collections.Generic;
namespace FeatureTogglerApp.Features
{
public class FeatureOptions : FeatureToggles
{
public string AppName { get; set; }
public Dictionary<string, FeatureToggles> Users { get; set; }
public FeatureOptions()
@JanneMattila
JanneMattila / Program.cs
Created April 24, 2019 19:30
Azure App Configuration
// ...
config.AddAzureAppConfiguration(options =>
{
// Use with connection string:
// options.Connect(connectionString)
// or with managed identity:
options.ConnectWithManagedIdentity(endpoint)
.Use("FeatureToggler:*")
.WatchAndReloadAll("FeatureToggler:UpdateKey", TimeSpan.FromSeconds(5));
});
@JanneMattila
JanneMattila / Startup.cs
Created April 24, 2019 19:29
Azure App Configuration
public void ConfigureServices(IServiceCollection services)
{
services.Configure<FeatureOptions>(Configuration.GetSection("FeatureToggler"));
// ...
@JanneMattila
JanneMattila / DataController.cs
Created April 24, 2019 19:20
Azure App Configuration
using System.Collections.Generic;
using FeatureTogglerApp.Features;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
namespace FeatureTogglerApp.Controllers
{
[Route("api/[controller]")]
[ApiController]
public class DataController : ControllerBase