Nov 222019


In our development process e believe a lot in microservices and the CICD philosophy. To achieve that we have introduced feature toggles to control the features that are already delivered to the customers. So when the feature is stable enough we enable the feature on the next update and the new features is usable in the product.

With the passage of time and maturity in the product we moved to tenant based solution. The biggest challenge that we faced in that was to toggle functionality based on customer. We had our toggles loaded in the start up of the application. After the start up the objects were registered based on the toggle and the application was started. Now in case of single Tenant installation that was not a problem as we could easily restart the customer to load the latest token. With a multi tenant installation it’s a bit hard to do that as we have to restart all the tenants in order to load the tenants.

So in this post I am going to address this problem and also discuss the solution that we implement. So our old system had the following architecture.

There are my reference classes

So I have a two services service class On and service class Off. The service class On will be called if the toggle is set to ON the service class Off should be called if the toggle is set to OFF

Here is where I am using the toggle and the service so the following steps are performed in this class

  1. Load the toggle
  2. Initialize the service collection
  3. Register based on toggle
  4. Initialize the service
  5. Access the Serve method
  6. Ask user if he wants to continue and if yes continue to step 5

Now when I run this code I will see the following output

Now in this output even if I change the content of the toggles.txt the new toggles will not be effected until I restart the application.

So our solution was to handle it with some changes in the way we load and register the application. so instead of loading the toggle in the beginning we added that part in out interceptor. Before I got into details let me talk a bit about the interceptor.

In the old solution we had toggle information loaded before we access the object. So we already know what type of object it was. In the new solution we will write an interceptor that will be called every time we initialize that service object. Which will give us the opportunity to figure out the toggle before assigning the type of the object lets see the code for better understanding.

So the most important thing to note here is on line 17,18 and 19. We register both the On and off service and then we register the service interface using the Register Capability Components. The register combability is added via extension method to the service collection.  

Every time we access the “Serve” method this capability interceptor is called and the toggle is loaded to see load the type of the object. This type if based on the provided toggles. So the toggles are accessed and the type is determined before the method invocation. Lets run the program again to see the output.

As mentioned above the toggles are updated with stopping the application and the latest change was impacted. This is how we solved the multi feature multi-tenant dynamic invocation problem. I know that this could be done in million ways and we could also optimize the code to be more efficient. This code example is just to highlight the problem and a potential solution.

The code is available at

 Posted by at 10:34 am
Nov 222019

Step 1: Register an app in active directory app registration

You need to do a new application registration

Once that application is registered you need the application Id which is also called the client id. The other thing that you need to configure the permission.

In permission you need to give access to log analytics data as user that should be given

Step2: then we should have a secret id from the azure

That you can get from the key configure that in the app that you just register and make a new key you need o save that

Once you have that lets switch to log analytics

Step3: you need to the workspace id from the log analytics

Step4: to access control

Add a new role assignment

Role: Contributor

Select: the app that you created


Now you have set the framework and the two way communication between the app and log analytics. Now comes the code part so we need the following code

Lets walkthrough the code a bit.

So the first thing that we do in GetMetricBeat is to get the access token. Before we move forward we can see how that is made. So to get the token we are contracting the URL. To access the long analytics the URL is  ‘’tenantID. Once that is constructed we need to create the client credential for the app that that we have created by providing the clientappID and clientAppSecret to acquire the access token.

After that we are constructing a very basic log analytics query which is in Json format.

To access the log we have to create a HTTP request to ‘{workspaceId}/query’ by providing the workspace if. The http client must be given the access token for a valid request. Once we post the request a json will be returned as a return string value that we can parse for our result.

 Posted by at 10:28 am
Nov 112019

Today I want to talk about the place where we spend almost eight hours every day or at least from Monday to Friday. There is off course there are some people who work from home but for most of the guys who are doing full time jobs they are normally at their workplace. While staying at work we are mostly working but every now and then we communicate with people around us. Every day we do work discussions, tell jokes, ask for upcoming or previous plans and communicate in many ways.

With all of this constant commination between the work colleagues we make a social or work relation with those people at work even though we are not related or living with our colleagues.

Happiness is working with great people

I am working in Teleopti Sweden (A Calabrio Company) as a Cloud Developer. We have a pretty good amount of people who are in office apart from those who are either travelling for work or working from home. But in the summer the number of people at office decreases substantially due to summer vacations. I am one of the few who are working in those long silent and relaxed sunny summers when most of the office is on vacation. Its not many people around and I would say it’s the best time working at the office. Not many people are around and the one that are around you get the chance to communicate with them. The work environment is less stressful and more quiet. You get more focus on work and self-evaluation. Though both self-evaluation and work are a constant thing that we are doing all the time but during those working days one could take a step back to have more focus.

We are a Team

We are not a team just because we are physically located at one place and working together. We are team because we communicate, we trust, we share jokes, have fun activities and we respect each other. It like having another family at your workplace. We do have a lot of work-related discussions and augments on different things and in the we agree on the common grounds. This is almost like those childhood fight-arguments with our siblings and the next day start without any grudges. This off course gives you the chance to develop that comfort zone which helps you excel.

The Fika policy

‘Fika’ is Swedish is defined as a coffee break. I think this is another healthy tradition that we have at the Swedish work environment. Fika are informal coffee breaks near the kitchen are or the common area. Where you could have work chat to personal chat to mingle more. You normally discuss your weekend, plans for weekend or things in general

With all these things combined I think routine that you have at work in invaluable. It gives you the confidence at drive to work with your team and the people around the office.

 Posted by at 10:08 am
Oct 142018

If you have created a table in Microsoft SQL and along with a table you have a column with a default value, then the name of the constraint will be generate by the SQL framework unless given. This will be will have some random GUID which will keep it hard to know when you want to drop a column. There could be certain sitations where you want to directly delete the column and there are situations where the column should be dropped without having the knowldge of constaint name.

You can acheive that by using the following sql





 Posted by at 10:49 pm
Oct 022018

If you are not familiar with the blockchain key concepts i would suggest this previous article.

Blockchain is a technology that enables us to move resources on the provided decentralize database. Now those resources could be anything that provides us value. Its is transparent among the parties or nodes that are involved which makes it more trusted system.

Concept of Blockchain:

The concept of blockchain was introduced in 1991 by a group of scientists who proposed  to timestamp documents digitally in order to validate them. Once a document was timestamp a hash of the complete document was calculated. This hash was used to validate the document. Any tiny change in the document will change the hash and it will invalidate the document. But unfortunately it was not practiced that much until 2009 by Satoshe Nakamoto.  He created the crypto currency Bitcoin using blockchain technology.  

concept of bc

Now that a very important point here about a very general and common misconception  between Bitcoin and blockchain that they’re one of the same things but they’re not.  Bitcoin is a digital currency where as blockchain is a technology used by the bitcoin. 


Case study:

In this case study we’re going to discuss a very basic example of money transfer.  The Scenario is where we  want to transfer money from one point to another. Lets say A is in Sweden and wants to transfer 5 dollars to B in Pakistan. As there is no direct line so A will have to use a third party service. The 5 dollars will be transferred via the third party who will transfer the money to B in  Pakistan. Lets say the third party charge some fee and the transfer is done in 2 days.  Now during those two days you don’t have any transparency on what the third part is doing with your money or is the money transferred or not.

case study 1


So we have three general problems here that we want to discuss the fee, the time that the third party took and transparency of the third party process. Now lets address these problem in more detail by consider another example. 


Long transaction time:

So we have three person A, B and C.  In the very beginning we say that A has 10 dollars. We are going to maintain this in a record which will be our open ledger.. The very first block of the blockchain is called the genesis block.  B has 7 dollars and C has 5 dollars.  Lets say A wants to transfer 7 dollars to B. The address of A B and C are basically the public keys on which the money is transferred. This will be added as a transaction to the ledger and the transaction is performed. B want to transfer 5 dollars to C which will also be added to the ledger and so will our last transaction which is C transfer 5 dollars to A. Now if you see this open ledger is actually the transfer which is done instantly. This open ledger here is called the blockchain  So we have fixed the problem with the long transaction time by instantly maintaining the record in an open ledger but our solution is still like the third party where our ledger is hosted an one place which could be a single point of failure.



To address this problem we will distribute the ledger to each node that is involved in the network.  So now we have a distributed block chain. By doing that we eliminated the problem of trust less ledger in fact now its more visible to all the parties and they can validate the ledger at any time. As we have solved the problem by distributing blockchain. we have now another problem of synchronizing the ledger so that is updated on each node on the network. The problem here is that A can say that C transferred 10 dollars to A and add it to its block chain so how will the other nodes know that it was an invalid transaction. 

To understand this part of the system where we will have to look at another example. Lets say this is our network and this the block chain for that network. Lets say A wants to transfer 2 dollars to C. When the transaction occurs a block in created but not yet validated. The difference between creation and validation of block is that anyone can create a block but it has to be validated before it could enter to all the blockchain.  When the block is created it will distributed to these special nodes in the network that will perform validation. These special nodes are called miner. Miner are just ordinary nodes except that have provided high computation speed to compute the validation of the block. Once they validate a block they are rewarded with a small amount. 


For our block we have to calculate the hash of the block which some could say is a really quick operation so why this high computational power is needed. Usually there are some blockchain rules that are enforced on the block validation that the hash of the block should start with 5 zero. This is called the difficulty of the block. I will discuss these topics in detail in my later videos. Lets get back to our block so once our intended block is published to the nodes all the miners will pick up the block and start computing the hash the block. Let say B was able to generate the hash before D so B will add the key that it used to generate the hash, add it to its local block chain and broadcast it to the network.  When A receives the block it will validate the hash by using the same key in the block and once validated A will add the block to its block chain and wait for the next block. 


The reward system for the miners is very complex and very important part of the block because it contributes to your currency. I hope you all understand the concept. We touched these concept which I will explain in more detail in my later lectures. 

 Posted by at 2:15 pm
Jul 122017

Though the concept is really simple but there is always an edge confusion between the two. Lets discuss them one by one using example. To understand the concept of Abstract lets consider one of this easy case domain problem. Lets discuss the characteristics of an animal. An animal can have 4 legs if its a horse and two legs if its a Kangaroo (ok you can argue that the arms are legs as well but lets assume that its only two legs and two arms). When i define a object of such characteristics i cant really say directly that an animal has 4 legs. I mean in real life it could have 4 but not when its a Kangaroo. Let me define the two processes separately

If we have a domain case where we say that we cannot haven’t an object of Animal class because we don’t know if it would have 4 or 6 legs. but we could have Horse or Kangaroo objects. Then we define the animal class abstract. What it will do it one it could restrict the type animal to be instantiated and secondly it would force all the child classes to implement the base class abstract method.

If we have a domain case where we have a Passenger class which could travel with ticket. But if its European passenger then we need to check the passport only and if its Non European passenger then we need to check the Passport and visa. To implement that check the example below where the base class(Passenger) method is overridden by the child class based on their nature






 Posted by at 4:38 pm
Jul 032016

In this post i am going to explain how to create a DB using #. So lets get down with the code

This class is the control class through which we are going to call the helper methods. I have started coding directly as it is easier to understand it via running code. If you dont understand it or have problems running it just say the word and will try to add to Git so its easily accessible to download.


This class is the helper class being used. We will use this class to execute the script.

This is the script file that is used to create the script. The script is well commented so that you can see the details of the application


 Posted by at 8:02 am
Jun 202016
Many people have this confusion of understing URL but most people thinks its too late. When i move to web development i had no idea of internals as i just assumed that things magically worked out. I think its better to learn the basics to get more grip on terms and infrastructure for better understanding.
 So lets see a URL
So lets see the differnet part of this URL.
http:// is the URL scheme. Meanning how we will access the web page. Next is the host name. You can also have IP address here but its really hard for people and business to remember the IP address of a web page so there is a user friendly name. In this case the is the host name. When you make this request the DNS (Domain name server) will resolve (get information related to that domain ) the domain name and route you to the address of that domain.
80 This is the port number. You might be thinking that this information is not really added in all the URLs that you usualy have so whaty do you need it here. This is the default port on which the server is listning to all the http requests. If you dont specify it the browser will internally add it. If you have any other port you can specify that externally and the browser will work accordingly.
 local/street/food this is the path. indicating where you want to go on the web site. In this case i want to go to local directory and street and the the page food.
 #/carrot The last bit is the fragment Its not always that it could be the name of the resource that we want to access or some html or any other page. In this case it means that on food page go to the carrot part of the page (which could be by the end of the page) so when you open the page you will be automatically redirected to the end of the page.
 Posted by at 3:47 pm
Jun 182016


I got a recent question in which how to use if within switch. I would not prefer it but here is the code

 Posted by at 9:02 am