generate azure docker certificates

generate CA, server and client keys

First generate CA private and public keys:
openssl genrsa -aes256 -out ca-key.pem 2048
openssl req -new -x509 -days 365 -key ca-key.pem -sha256 -out ca.pem
pwd 123qweASD

Now that we have a CA, you can create a server key and certificate signing request (CSR). Make sure that “Common Name” (i.e., server FQDN or YOUR name) matches the hostname you will use to connect to Docker:
openssl genrsa -out server-key.pem 2048
openssl req -subj “/CN=$HOST” -new -key server-key.pem -out server.csr

Next, we’re going to sign the public key with our CA:
openssl x509 -req -days 365 -in server.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out server-cert.pem

For client authentication, create a client key and certificate signing request:
openssl genrsa -out key.pem 2048
openssl req -subj ‘/CN=client’ -new -key key.pem -out client.csr

To make the key suitable for client authentication, create an extensions config file:
echo extendedKeyUsage = clientAuth > extfile.cnf

Now sign the public key:
openssl x509 -req -days 365 -in client.csr -CA ca.pem -CAkey ca-key.pem -CAcreateserial -out cert.pem -extfile extfile.cnf

After generating cert.pem and server-cert.pem you can safely remove the two certificate signing requests:
rm -v client.csr server.csr

encode base64 for azure

~/.docker$ l
ca-key.pem ca.pem cert.pem key.pem server-cert.pem server-key.pem
~/.docker$ base64 ca.pem > ca64.pem
~/.docker$ base64 server-cert.pem > server-cert64.pem
~/.docker$ base64 server-key.pem > server-key64.pem
~/.docker$ l
ca64.pem ca.pem key.pem server-cert.pem server-key.pem
ca-key.pem cert.pem server-cert64.pem server-key64.pem

add in azure docker extension using the base 64 certificates

Leave a comment

Filed under Technical Links

css rotate table column headers

Leave a comment

Filed under Technical Links

enable azure cors

private void ConfigureCors(CloudStorageAccount storageAccount)
  var blobClient = storageAccount.CreateCloudBlobClient();

  var serviceProperties = blobClient.GetServiceProperties();

  var cors = new CorsRule();

  //cors.AllowedOrigins.Add(""); // more restrictive may be preferable
  cors.AllowedMethods = CorsHttpMethods.Get;
  cors.MaxAgeInSeconds = 3600;



Leave a comment

Filed under Technical Links

webapi oauth token authentication

Leave a comment

Filed under Technical Links


Leave a comment

Filed under Technical Links

Performance Counters

public static extern void QueryPerformanceCounter(ref long ticks);

// [...]

PerformanceCounterSample test = new PerformanceCounterSample();
Random rand = new Random();
long startTime = 0;
long endTime = 0;

for (int i=0; i<1000; i++)
    // measure starting time
    QueryPerformanceCounter(ref startTime);


    // measure ending time
    QueryPerformanceCounter(ref endTime);

    // do some processing
    test.DoSomeProcessing(endTime - startTime);


using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace perfcounter
 public class MyPerfCounter
 private PerformanceCounter _averageDuration;
 private PerformanceCounter _averageDurationBase;
 private PerformanceCounter _totalOperations;
 private PerformanceCounter _operationsPerSecond;

 public static extern void QueryPerformanceCounter(ref long ticks);

 public MyPerfCounter(string category)
 if (!PerformanceCounterCategory.Exists(category))
 var counters = new CounterCreationDataCollection();

 // 1. counter for counting totals: PerformanceCounterType.NumberOfItems32
 CounterCreationData totalOps = new CounterCreationData();
 totalOps.CounterName = "# operations executed";
 totalOps.CounterHelp = "Total number of operations executed";
 totalOps.CounterType = PerformanceCounterType.NumberOfItems32;

 // 2. counter for counting operations per second:
 // PerformanceCounterType.RateOfCountsPerSecond32
 CounterCreationData opsPerSecond = new CounterCreationData();
 opsPerSecond.CounterName = "# operations / sec";
 opsPerSecond.CounterHelp = "Number of operations executed per second";
 opsPerSecond.CounterType = PerformanceCounterType.RateOfCountsPerSecond32;

 // 3. counter for counting average time per operation:
 // PerformanceCounterType.AverageTimer32
 CounterCreationData avgDuration = new CounterCreationData();
 avgDuration.CounterName = "average time per operation";
 avgDuration.CounterHelp = "Average duration per operation execution";
 avgDuration.CounterType = PerformanceCounterType.AverageTimer32;

 // 4. base counter for counting average time
 // per operation: PerformanceCounterType.AverageBase
 CounterCreationData avgDurationBase = new CounterCreationData();
 avgDurationBase.CounterName = "average time per operation base";
 avgDurationBase.CounterHelp = "Average duration per operation execution base";
 avgDurationBase.CounterType = PerformanceCounterType.AverageBase;

 // create new category with the counters above
 System.Diagnostics.PerformanceCounterCategory.Create(category, "Sample category for Codeproject", PerformanceCounterCategoryType.SingleInstance, counters);
 //PerformanceCounterCategory.Create("MyCategory","Sample category for Codeproject", counters);

 _totalOperations = new PerformanceCounter();
 _totalOperations.CategoryName = category;
 _totalOperations.CounterName = "# operations executed";
 _totalOperations.MachineName = ".";
 _totalOperations.ReadOnly = false;

 _operationsPerSecond = new PerformanceCounter();
 _operationsPerSecond.CategoryName = category;
 _operationsPerSecond.CounterName = "# operations / sec";
 _operationsPerSecond.MachineName = ".";
 _operationsPerSecond.ReadOnly = false;

 _averageDuration = new PerformanceCounter();
 _averageDuration.CategoryName = category;
 _averageDuration.CounterName = "average time per operation";
 _averageDuration.MachineName = ".";
 _averageDuration.ReadOnly = false;

 _averageDurationBase = new PerformanceCounter();
 _averageDurationBase.CategoryName = category;
 _averageDurationBase.CounterName = "average time per operation base";
 _averageDurationBase.MachineName = ".";
 _averageDurationBase.ReadOnly = false; 

 private long GetTicks()
 long ticks = 0;
 QueryPerformanceCounter(ref ticks);
 return ticks;

 public TimeSpan MonitorAction(Action method)
 var start = GetTicks();
 var end = GetTicks();
 var ticks = end - start;
 var time = new TimeSpan(ticks);
 return time;


 public void Increment()

 public void OperationsPerSecondIncrement()


Leave a comment

Filed under Technical Links

vnext in docker

Leave a comment

Filed under Technical Links