Thursday, March 25, 2021

Enabling Preview Features in Visual Studio 2019

By default, Visual Studio doesn’t enable preview feature selection in Visual Studio 2019. Say you have .Net 5.0 installed on your machine and you are creating a new Console Application.

 After creating the application, you will notice that, although .Net 5.0 is installed, application still picks up the .Net Core 3.1 as a default framework. In fact, application didn’t ask for framework selection too.

So, how can we select the framework while creating an application itself. For doing this, we need to enable Preview Features in Visual Studio by going to Options menu as shown below:

Video of this feature can be found here.

Hope you enjoyed learning this cool tip.

Monday, March 22, 2021

Get Notified via Azure Event Grid whenever Azure Blob is updated

In this article, we will learn how to get notification whenever something is changed in Azure Storage. Let’s say, we want our application to get notified whenever any new file is uploaded to the blob or say any file is deleted from the blob. How can we do that?

Before directly jumping into the solution, let’s have all the major pieces listed here which will contribute towards this.

Azure Storage: We need an Azure storage wherein we will be uploading our blog objects, i.e. image files.

Azure Event Grid: Next we need is Azure Event Grid. It is a routing service provided by Microsoft and the best part about this service is, it has built-in support for events coming from storage blobs and resource groups. So, we need to create a subscription which will tell what event and which specific topic we are interested in.

Endpoint: Lastly, we need an endpoint, which will receive notifications. So, it could be Function App, Logic App, or any custom application which is hosted somewhere and is accessible over HTTP.

With this much brief theoretical knowledge, we are good to proceed for implementation.

Complete article can be found here.

Video tutorial can be found here.

Saturday, March 20, 2021

Bring Azure Blob Objects Back to Life

Nowadays, there are many applications which are utilizing Azure Blob Storage for reading and writing objects. Looking at that, it’s quite common that these objects may get deleted accidentally due to user’s negligence or application's behavior. 

So, my today’s writeup is around this topic wherein we will see, how can we bring back our deleted blob objects back to life.

Lifecycle of blob storage is managed by a very well-known concept called Versioning. Versioning deals with the state - when any object was created, when was it modified or when was it deleted. If this topic impresses you, you can read complete blog post here or you can view it on my YouTube channel.

Thursday, March 18, 2021

Azure App Registration and Microsoft Graph API

As part of Sip and Learn series, this time I covered a very interesting topic – App registration for Microsoft Graph API in AAD. Here you will get to know how to do application registration using Azure portal and what all permissions need to be given to call particular type of API. If this topic is of use to you, do view this episode on my channel.

Thursday, March 11, 2021

Using Postman to interact with Microsoft Graph API

I have added another episode to my technical series named Sip and Learn on YouTube. It covers the topic, how one can play with Postman for Microsoft Graph API. I also mentioned about how one can generate bearer token and what all header fields are necessary to make an API call. You can watch complete episode over here.

Monday, March 8, 2021

Top Level Statement

Last week, I started my technical series on YouTube Channel with the name Sip and Learn. As part of this series, I'm planning to share some of the interesting short technical tips and concepts which are very easy to grab in just few minutes. Here, I speak about Top Level Statements feature of C# 9.0 as part of my first episode. You can go through this session here.

Monday, March 1, 2021

Simplifying use of Static

Hope everyone must have come across static keyword while doing development, specifically using C#. Static modifier is used to declare static member, which means it belong to the type itself. Well, as part of this article, I’m not going to discuss more about static, but if you are interested in knowing more about it, here is the good reference. 

  1. public class Logger  
  2. {  
  3.      public static int GetLogLevel(string logType)  
  4.     {  
  5.          …  
  6.     }  
  7. } 

Above is a sample code snippet wherein, we have a class called Logger and it has a static method called GetLogLevel.

Now in order to call this GetLogLevel(…) method, first we have to add the required namespace, where this Logger class has been defined. Something like this,

  1. using Planner.Utilities;  

Well, nothing new as of now. Next, let’s have a look at, how to make a call to this static method.

  1. int logLevel = Logger.GetLogLevel(fileLog);  

Till here, nothing that bad, but we do have a room to improve our code by making it more readable and cleaner. Let’s re-write our code in below two steps:

Step 1: Using static keyword along with namespace

  1. using static Planner.Utilities.Logger;  

Step 2: Remove class name while calling static method

As we have already referred our class along with namespace, we need not to write that again. Hence, we can directly call our static method as shown below:

  1. int logLevel =GetLogLevel(fileLog);  

What do you think about this approach? Isn’t it cool?

Thursday, February 25, 2021

Speaker at C# Corner MVP Ft Show

Yesterday I got a privilege to be a speaker on C# Corner MVP Show. It was a great show and a wonderful interaction with host Stephan Simon on my topic ‘Handling Notifications using Microsoft Graph’. Recording is available over here.

Thursday, February 18, 2021

Troubleshooting Bad Gateway errors for Ngrok

Ngrok is one of the well-known tool for local tunneling solution. I have used it many times being the easiest tool for any developer.

This time once again, I thought to use Ngrok for my current application, which uses Graph API to get notifications from Microsoft Teams channel. As always, I launched the Ngrok with required port as shown below:

  1. ngrok http 44332  

and it got connected as shown below:

Till now everything is alright. But now when I ran my application with Ngrok’s forwarding address, I end up getting an error - 400 Bad Request.

And here is what I read more about this:

Seems like some applications can’t deal with the default behavior of Ngrok and need an explicit mention of header information, which means there is another way to handle such scenario:

  1. ngrok http http://localhost:44332 -host-header="localhost:44332"

After connecting Ngrok with above command, everything went very smooth and as expected.

Hope this tip would be useful for you too.

Friday, December 11, 2020

Azure Data Explorer - Approaches For Data Aggregation In Kusto

In my previous posts I tried to transcribe the things that were not too obvious for me when I initially started working on Kusto Query Language. Continuing with the same thought, this time I’m going to share a few of the approaches that can be taken to aggregate the data. 

Let’s consider the below input data:

  1. let demoData = datatable(Environment: string, Version:int, BugCount:int)  
  2. [  
  3. "dev",1, 1,  
  4. "test",1, 1,  
  5. "prod",1, 1,  
  6. "dev",2, 2,  
  7. "test",2, 0,  
  8. "dev",3, 2,  
  9. "test",3, 0,  
  10. "prod",2,2,  
  11. ];


Get the average number of bugs falling under each category. 

Expected Output


There are several approaches to achieve this. 

Approach 1 - Using Partition Operator 

Partition operator first partitions the input data with defined criteria and then combines all the results.

  1. demoData| partition by Environment (summarize ceiling(avg(BugCount)) by Environment);  
Approach 2 - Using Join Operator 

Join merges the two tables based on the specified key.

  • demoData| join kind=leftouter (  
  • demoData | summarize ceiling(avg(BugCount)) by Environment) on Environment  
  • | project Environment, avg_BugCount  
  • | distinct Environment,avg_BugCount;  
    Approach 3 - Using Lookup Operator 

    Lookup operator extends the column of the second table and looks up the values in the first one.

    1. let Averages = demoData  
    2. | summarize ceiling(avg(BugCount)) by Environment;  
    3. demoData | lookup (Averages) on Environment  
    4. | project Environment, avg_BugCount  
    5. | distinct Environment,avg_BugCount  

    I hope you enjoyed aggregating data. 

    Happy Kustoing!