Cheapest Development Environment for Azure Kubernetes Service

I am trying to setup cheapest development environment for Azure Kubernetes journey. I am provisioing this service in East US so all prices are in USD;

az aks create –name myakscluster

This will bring up Standard_DS2_v2 node that cost $106.58 at the time of this writing.

I like to drop it a smaller VM. AKS specification are that every AKS cluster will have at minimum one node pool and node pool require a VM SKU of at least 2 vCPUs and 4GM memory. The cheapest VM at that configuration is Standard_B2s that cost about $30.37.

–node-count 1 –node-vm-size Standard_B2s

AKS uses a Load Balancer and by default the Standard sku @ ~$30/month will be selected. The Basic sku is free, but the Load Balancer sku cannot be changed once the cluster has been created, so we must set it at time of creation.

–load-balancer-sku basic

Disk size defaults to 100GB which for this VM is a Premium SSD p10 @ 19.79/month. Minimum disk size is 30 so we’ll choose the 32GB p4 @ $1.54/month.

The cheapest cluster power shell is;
az aks create -n myakscluster \
–node-count 1 \
–node-vm-size Standard_B2s \
–load-balancer-sku basic \
–node-osdisk-size 32

Hope, this will save some money on compute, storage and networking during development.

Steps to enable MSDTC on Windows Server

These steps can be used on windows Server 2008 r2 and Windows Server 2012 R2

  1. Click Start, click Run, type dcomcnfg and then click OK to open Component Services.
  2. In the console tree, click to expand Component Services, click to expand Computers, click to expand My Computer, click to expand Distributed Transaction Coordinator and then click Local DTC.
  3. Right click Local DTC and click Properties to display the Local DTC Properties dialog box.
  4. Click the Security tab.
  5. Check mark “Network DTC Access” checkbox.
  6. Finally check mark “Allow Inbound” and “Allow Outbound” checkboxes.
  7. Click ApplyOK.
  8. A message will pop up about restarting the service.
  9. Click OK and That’s all.

Reference : https://msdn.microsoft.com/en-us/library/dd327979.aspx

Sometimes the network firewall on the Local Computer or the Server could interrupt your connection so make sure you create rules to “Allow Inbound” and “Allow Outbound” connection for c:\windows\msdtc.exe

How to Read blob file from Microsoft Azure Storage with .NET Core

In order to read a blob file from a Microsoft Azure Blob Storage, you need to know the following:

  • The storage account connection string. This is the long string that looks like this:
    DefaultEndpointsProtocol=https;
    AccountName=someaccounfname;
    AccountKey=AVeryLongCrypticalStringThatContainsALotOfChars==
  • The blob storage container name. This is the name in the list of “Blobs”.
  • The blob file name. This is the name of the blob inside the container. A file name can be in form of a path, as blobs are structured as a file structure inside the container. For ecample: folder/folder/file.extension

You also need this NuGet package:

Windows.Azure.Storage

The code is pretty simple:

using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
 
public string GetBlob(string containerName, string fileName)
{
  string connectionString = $"yourconnectionstring";
 
  // Setup the connection to the storage account
  CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);
   
  // Connect to the blob storage
  CloudBlobClient serviceClient = storageAccount.CreateCloudBlobClient();
  // Connect to the blob container
  CloudBlobContainer container = serviceClient.GetContainerReference($"{containerName}");
  // Connect to the blob file
  CloudBlockBlob blob = container.GetBlockBlobReference($"{fileName}");
  // Get the blob file as text
  string contents = blob.DownloadTextAsync().Result;
   
  return contents;
}

The usage is equally easy:

GetBlob(“containername”, “my/file.json”);

Microservice and Idempotent method

Idempotent method is the one that results in same behavior either in a single or mutiple calls. For example a delete method will delete a resource
and return 204 first time. on subsequent calls it will return 404. return codes has nothting to do with idempotent behavior but the fact is that
behavior of call will always be the same.

+———+——+————+
| Method | Safe | Idempotent |
+———+——+————+
| CONNECT | no | no |
| DELETE | no | yes |
| GET | yes | yes |
| HEAD | yes | yes |
| OPTIONS | yes | yes |
| POST | no | no |
| PUT | no | yes |
| TRACE | yes | yes |
+———+——+————+