generate azure docker certificates

generate CA, server and client keys
https://docs.docker.com/articles/https/

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

https://css-tricks.com/rotated-table-column-headers/

Leave a comment

Filed under Technical Links

enable azure cors

http://www.devtrends.co.uk/blog/hosting-web-fonts-in-azure-blob-storage-using-the-new-cors-support

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

  var serviceProperties = blobClient.GetServiceProperties();

  var cors = new CorsRule();

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

  serviceProperties.Cors.CorsRules.Add(cors);            

  blobClient.SetServiceProperties(serviceProperties);
}

Leave a comment

Filed under Technical Links

webapi oauth token authentication

http://bitoftech.net/2014/06/01/token-based-authentication-asp-net-web-api-2-owin-asp-net-identity/

Leave a comment

Filed under Technical Links

gulp

https://github.com/johnpapa/pluralsight-gulp
https://github.com/johnpapa/gulp-patterns
http://www.johnpapa.net/angular-and-gulp/

Leave a comment

Filed under Technical Links

Performance Counters

http://www.codeproject.com/Articles/8590/An-Introduction-To-Performance-Counters

[DllImport("Kernel32.dll")]
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);

    System.Threading.Thread.Sleep(rand.Next(500));

    // 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;

 [DllImport("Kernel32.dll")]
 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;
 counters.Add(totalOps);

 // 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;
 counters.Add(opsPerSecond);

 // 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;
 counters.Add(avgDuration);

 // 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;
 counters.Add(avgDurationBase);

 // 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();
 method.Invoke();
 var end = GetTicks();
 var ticks = end - start;
 _averageDuration.IncrementBy(ticks);
 _averageDurationBase.Increment();
 var time = new TimeSpan(ticks);
 return time;

 }

 public void Increment()
 {
 _totalOperations.Increment();
 }

 public void OperationsPerSecondIncrement()
 {
 _operationsPerSecond.Increment();
 }

 }
}

Leave a comment

Filed under Technical Links

vnext in docker

http://blogs.msdn.com/b/webdev/archive/2015/01/14/running-asp-net-5-applications-in-linux-containers-with-docker.aspx

http://blogs.msdn.com/b/scicoria/archive/2014/11/23/using-the-docker-client-from-windows-and-getting-aspnet-vnext-running-in-a-docker-container.aspx

Leave a comment

Filed under Technical Links