Using LINQPAD

Hi Friends,

In this section, I’ll introduce you with one of my favorite tools i.e. Linqpad. you can download the same from https://www.linqpad.net/. This is extensive tool for .NET programmers. LINQPAD is The .NET Programmer’s Playground. Here, you can do bunch of stuffs like executing LINQ query against SQL, Azure, XML, any object or against any other database. You can add your SQL connection like shown below.

5th

6th

As you can see in the below screen shot, I have simply pulled the movies from my movie review db.

2nd

Then, If i have to see the relationship between the tables, then i can simply go ahead and click on the highlighted link shown in the table above. Like in this case, when i clicked on “MovieReviews”, it produced the below result.

3rd

Behind the scenes it also generated the actual SQL statement as shown below in the screen shot.

4th

You can also execute SQL statement as shown below in the screen shot. only thing you need to change here is the language from the dropdown.

1st

Thanks for joining me.

Thanks,
Rahul Sahay
Happy Coding

2,602 total views, no views today

WEB API Management -1st Part

Hi Friends,

In this section, we’ll talk about WEB API Management. Now, from the high level, it’s look very much like Managing WEB API. Here, we need to talk about two things.

1) You build a Web API and decide to do business with that means you want to sell that API, already bunch of people doing the same. Like you want to sell services like messaging service, phone call service may be anything. So, you will monetize that.

2) Scenario 2nd is you will be indirectly monetizing the APIs means you will be doing business indirectly. Fine example for the same is; you partner with some business and they get access to your service. Basically, it will help other companies for the integrated experience.

So, once you decided that you are going to experience one of these scenarios. Then, WEB API Management is best for you. Out of the box, it also helps to keep documentation side by side. Consider a scenario if you have given tons of API without documentation; this will be worst scenario to handle. So, from a developer perspective if you are writing any API and you want to put the documentation then and there. Then, WEB API management is again a good choice.

One more scenario which I would like to emphasis here, let’s suppose you want to launch marketing Campaign and you don’t have analytics embedded with API; then you can’t even think of doing that. However, with Website you can do the same exclusively by incorporating google analytics and other stuffs. But, if you are writing any API from scratch then you need to think of key management, access, analytics in the backend and other important things. But, with turnkey service API Management all these things will go away. So, I can have any WEB API hosted anywhere on any service provider; but Azure WEB API Management will sit in front of that. So, as you see below in the screen shot, developers develop/write APIs that calls their APIs via Azure proxy. And this is where all magic happens, like analytics and other much needed behavior for WEB API done here.

2nd

Now, from Azure portal you can create WEB API management as shown below in the screen shot.

3rd

4th

6th

7th

8th

Once, the API management, portal created, you can go ahead and click on Manage link. This will open new dashboard for API Management as shown below in the screen shot.

9th

Now, here you can do all sort of things like adding new API or importing an existing API and set bunch of rules here on the same and then monitor the same on timely basis.

32nd

Then, you can add operations to it like shown below with documentation to that.

12th

13th

Once, it got added successfully, then you it will bring you back to the orignal screen as shown below with API added.

14th

Next thing i need to do is to add the same in the products. Now, this is the place where you can change the behavior or apply policies. Here, you will add your APIs to the product. Below is the screen shots for the same.

15th

16th

17th

18th

19th

20th

Now, once i added the API to the products page. I need to publish the same as well.

22nd

Once done, then i will click on developer portal link; then this will open developer’s dashboard for the same. So, as i said there are two things publisher and Developers. We have published our API 1st and now its available for developer’s portal.

23rd

Now, when you click on APIs link, it will list your newly added API.

24th

Now, below you can see variety of options to call the API means from different backend. One point to note here; in order to make a request you need to have a valid subscription id else this will result 401 error message as shown below

26th

However, you can achieve the same from the azure window itself.27th

28th

Now, this is the actual api http://moviereview.rahulsahay.com/api/movies which is getting fetched via Azure WEB API proxy.

30th

Once this is done. you can now check it’s analytics in the API Management window as shown in the below screen shot.

31th

with this i would like to wrap this session here. We’ll delve more in the coming session on the same. Till then stay tuned and Happy Coding.

Thanks,
Rahul Sahay
Happy Coding

3,969 total views, no views today

Building Azure Mobile Service App – 1st Part

Hi Friends,

In this segment we’ll talk about creating mobile service in the cloud and then using the same in our App. During the course we’ll use bunch of different kinds of technologies. We’ll talk about these technologies individually once we progress along the path. So, without wasting time 1st let’s go ahead and create Mobile service in Azure. As you can see I’m in the Azure portal

8th

where in currently i am not having any mobile service created. I’ll go ahead and create this link as shown below and create new mobile service.

9th

10th

11th

12th

Now, let’s go ahead and explore the service. So, here a framework has been installed on the IIS server hosted on windows azure which connects to the backend server. This provided REST based endpoints which means by using this REST endpoint we can perform some operation. As you can see below in the screen shot, our service is created and with manage keys option i can go ahead and off-course and associate key with this service.

13th

14th

Now, let’s have a look at the dashboard for the service. This is essentially a very usual dashboard we have used earlier with Azure.

15th

we’ll be exploring more this dashboard later. But, for now let’s look at the DB section which is also created with this service.

16th

17th

Now, let’s look at the dashboard of the db server. Here, you can get all the performance related parameters and also connection string for connecting to the database.

18th

Now, let’s open SQL Server management studio and connect to the database what we created in Azure. However, while connecting to the azure portal via SSMS; firewall may obstruct connection to happen as shown below.

21th

In order to fix the same, you can go back to the azure portal click on manage server and include your IP in the trusted IP List.

22nd

Once that is done, you can go ahead and login via SSMS as shown below

20th

As you can see below in the screen shot, currently no table is created here.

23rd

you can also login online SSL management portal.

24th

25th

Now, let’s go to mobile service dashboard and click on windows project as shown below and then download the starter app.

26th

With this i would like to wrap this session. In the next session, we’ll explore the app which we have downloaded from Azure and will do some really cool stuff with that. Till then stay tuned and Happy Coding.

Thanks,
Rahul Sahay
Happy Coding

1,533 total views, 1 views today

ASP.NET 5 Part – 3


Hi Friends,

In today’s discussion, we’ll delve further to some more interesting features on ASP.NET 5. So, lets begin the show. Now, Let’s talk about the different CLR Types available with this project. So, when i talk about different CLRs; There are actually 2 versions of CLRs. 1st one is the usual one which has the full blown version of CLR which we have been using since it’s inception. Another one is the minimized version or also known as cloud optimized version of CLR. Now, let’s go ahead and check project settings.

37th

As you can see in the above screen shot; my default setting is against full blown CLR which is running on the X86 machine. Now, if you see the drop down shown below. you will notice that i also have the option for cloud optimized version.

38th

Now, let’s change the environment to cloud version and then run the app and inspect the output of the greet controller which we created in previous section. It should print my name there.

39th

Now, let’s go ahead and debug this controller. So, now when i refresh the page it will hit the breakpoint as shown below.

40th

Here, when I go in the modules section as shown below in the screen shot. It will list the complete flow. So, here you can see from where all the binaries loading. Basically modules are nothing but have one to one mapping with assemblies.But, you can also have multiple module per assembly. Now, this module window is showing me what all modules are loaded in the application.

41th

43rd

Now, one point to note here that all these modules are coming from one location that is from user’s location as highlighted above. Let’s jump to this location for a minute and inspect the same.

44th

Now, when I go inside there; i can see that there is nuget package file or NUPKG file which is around 14 MB.

45th

This is complete Core CLR. Can you imagine. Now, what i can do is i can simply take this file and copy to different system my .NET Core version is ready. This bin directory here is the extracted version of this nuget package as shown in the below screen shot.

46th

Also, when you go to the runtime folder and go to full blown CLR folder as shown below.

47th

You will notice that size of the NUPKG file is very less compared to Core CLR version. Confused?

48th

In case of full blown CLR, all components get loaded from GAC (Global Assembly Cache) not from here. But, it doesn’t mean that there is no centralized repository for Core CLR. So, if you go to below location; you will find packages folder.

49th

So, now this will be the centralized repository for your Core CLR.

50th

So, whenever, we install any dependencies it will sit here in this packages folder. So, ASP.NET 5 completely embraces nuget package. We manage dependencies via nuget package. We can have CLR stored through nuget package. Hence, these packages folder are referred as Global Package Cache.

Now, project.json is not only used to have the nuget dependencies only. we can have different project dependencies also listed here within the same solution. For example, let’s go ahead and add class library project to the solution folder. Make sure you install Vnext version of class library which means this class library project can have all the flexibilities of dynamic compilation what we have been using so far.

51th

Once you added the project. Your solution will look like shown below. So, even the new project gets added under the src folder.

52nd

You will also notice that this new class library project also added new project.json file which also lists the dependencies accordingly for running Class library project.

53rd

Now, if i have to use this project in my web project; then i just need to include this newly created project in the dependencies section of project.json file of web project as shown below.

54th

55th

Now, when you don’t provide the version name against the package or project it will pull the latest one. Let’s go ahead and create some method in the class library project to return some meaningful thing.

56th

Let’s use the same in Greet controller.

58th

59th

With this i will wrap this session. In the next section we’ll delve further into new features of ASP.NET 5. Till then stay tuned and Happy Coding.

Thanks,
Rahul Sahay
Happy Coding

1,645 total views, 1 views today

Publishing your ASP.NET App to Linux in 5 minutes with Docker


Hi Friends,

In this section, i will demonstrate how to publish your ASP.NET APP on Linux VM using Docker extension of Visual Studio 2015. So, before we begin, we must need VS 2015 RC candidate installed on our machine. Then, we do need Docker extension for visual studio installed on our machine. You can install the same from Extension and Updates as shown below in the screen shot.

1st

Then, I need to create new ASP.NET 5 website as shown below in the screen shot.

1st

2nd

3rd

Once, site got created successfully; then simply rt-click on the website and say Publish as shown below.

2nd

Then, It will provide the below options.

3rd

Now, if you don’t have any subscription, then you need to create one and provide the details in the next screen. For privacy reason, my details are hidden.

4th

5th

Then, it will give the below confirmation message.

6th

When you say ok here, it will build the app and prepare for hosting. You can check the status of the same in the output window when Azure is provisioning things for you. This process will take some time.

7th

Once, its completed. It will show the confirmation message as shown below.

8th

Now, I will come to and say publish, this time it will come in connections tab with below VM credentials.

9th

Then you can click on validate Connection for confirming every thing is correct. once verified, then you can go ahead and click next and publish the app.

10th

11th

while building the app, you can check the status in the output window.

12th

13th

14th

Once done. It will launch the same in the browser. Also, it launched in my new Project Spartan browser as i’m running on windows 10 machine.

15th

Thanks for Joining me.

Rahul Sahay
Happy Coding

4,335 total views, no views today

ASP.NET 5 Part – 2


Hi Friends,

In this section, we’ll delve further in the new ASP.NET 5 project. When you take a closer look at the ASP.NET 5 project, you will see that there are many things which are carry forwarded like Model, View, Controller, clean separation of concerns and may more. But, there are also some significant changes around ASP.NET 5. Now, the root of the website is no longer the root of the project. By default, root will be WWWroot folder. The idea behind this to maintain the clean separation between the files at the web-server retrieved and sent to the client and the files which contains the logic and configuration. Static files like JS, CSS, HTMLs can live in WWWroot folder.

15th

Now, lets suppose when i run the app and tried to see the image which i have placed in My Imgaes folder, then it will give me 404 error.

16th

On the other hand, if i go ahead and add the same folder in WWWroot folder and try to navigate the same then it will produce me the result.

18th

17th

so, the point is all static files are served by root folder and logical stuffs served by project space as we initially saw, when i added controller in the controller’s folder and it took effect. One more thing you might have observed that there is no web.config file now in the solution. Also now there is no Global.asax file; however the same is replaced by startup.cs file. But, we’ll see this later. 1st let’s see project.json file. This file now manages many aspects of website.

19th

First thing which you will notice here that root folder is set to WWWroot here. So, this is the place which is telling website that this is the root folder. So begin the show from here. This you can change as well or rename if you like to. Now, this configuration file is in JSON format. This is also telling the ASP.NET runtime what dependencies project is going to need. In this new ASP.NET 5 system there is a new way to manage dependencies. No need to reference assemblies and store the lists of referenced assemblies in the project file. Instead we refer to nuget packages as dependencies and these dependencies are listed in our project.json file. Now, there are couple of reasons for this change. One reason is to simplify the dependency management. Another good reason for this is that ASP.NET is moving away from VS dependency. So, in future i can use any text editor to build the ASP.NET App.

Now, these dependencies can be both the ways. One way which we used already shown below in the screen shot.

20th

21th

Now, the UI of this also changed. Initially we used to have Modal window. Now, this is more like complete screen giving wider visibility. I can also see the installed templates like

22nd

Also, i still have the flexibility of different nuget source.

23rd

2nd Option is via project.json file. Let’s suppose i am planning to install some custom package. Then i can do like shown below as well

24th

However, whatever package you install; you can find its references under “References“. Below, in the screen shot you can see that there are two versions of runtime here. 1st one is the core version and 2nd one is the cloud optimized version.

25th

Now, let’s collapse the same and drill into it.

26th

Now, here dependency management system will keep your assemblies in nice tree structure. So, it nicely tells which package are dependent on which package.

27th

Now, as far as Framework and runtime is concerned as you can see below in the screen shot; i have both frameworks listed here.

28th

So, whenever i am building the solution i am building against both of these frameworks. By building against both i am actually ensuring that it will work well against both the frameworks. This also means whenever i am switching platform my code won’t break there.

But, let’s go ahead and break something here. You remember in the last segment i created one new controller with a notepad. Now, let’s modify the same and refresh the app.

29th

so, as you can see that it says that GetCallingAssembly() which is part of System.Reflection is not supported in the cloud optimized version. But, let’s suppose i overlooked this error and refresh the app.So, it actually produced me desired result.

31th

But, when i explicitly build the project and checked the output window, then it gave me below error message.

32nd

so, building with error but application is working fine with full blown CLR. Now, if you have decided that you don’t want CORE CLR version. so, you can just comment the Core CLR section in the project.json file as shown below in the screen shot.

33th

Now, as soon as i commented the above section, below references got refreshed automatically.

34th

Now, when i build the app then it will build fine.

35th

But, suppose you want the other way means you would like to keep the cloud optimized version also and build should also succeed. For this scenario i need to refer the conditional build as shown below.

36th

With this i would like to wrap this 2nd session ASP.NET 5 New Features. We will delve further in the coming series. Till then stay tuned ad Happy Coding.

Thanks,
Rahul Sahay
Happy Coding

1,755 total views, 1 views today

ASP.NET 5 – 1st Part

Hi Friends,

In this section, we’ll see that major changes on ASP.NET 5. The very 1st change is on the lines of Project system. Projects are now based on File System. So, all you need to do is add something to a project say new source code file is just to place the file in the right directory. So, you can edit the source code file, save the file and build just happens dynamically. Thanks to new Roslyn compiler which compiles the source code in memory which allows for faster build and faster refresh.

The project structure itself changed from previous versions. Also one point to note while building application, we’ll be having two different options of choosing runtime. 1st is the full blown runtime as 4.5.1 or greater than that or 2nd option we can have cloud optimized runtime also called core CLR. Here, all the pieces like JIT Compiler, Garbage Collector are packaged and designed keeping high throughput and low memory consumption in mind. And now the application can have this cloud optimized environment embedded with the application which makes it easier to have true side by side version and by embedded it means you can deploy the .net framework by copying the nuget package. So, the idea behind this cloud version of .NET runtime is; it should be platform independent which means it can also run on MAC and LINUX machine.

Another great fact about the new changes in ASP.NET 5 is the unification. So, now

MVC 6 = ASP.NET MVC + WEB API

In MVC 6, WEB API is merged with MVC. This means we will now have one set of controller class, one set of attributes, model binders etc. Also, it no longer relies on the namespace system.web which means it is easy to self host and run the core CLR. Now, with these changes in place it doesn’t mean that your existing projects won’t work in VS 2015; It will work as smooth as it was in earlier versions. Now, lets go ahead and start the demo. I already have RC version of VS 2015 installed on my 2ndry machine. Lets go ahead and create new project

1st

now, the below window is very much familiar to previous version. Here, i am interested in the new templates introduced. Hence, i am going to create a new project with ASP.NET 5 Website. This project will give me all the required components to run an app as shown below in the screen shot.

2nd

so, below shown window will be the new window for ASP.NET 5 project.

3rd

And when i run the same, it will produce me the below output. Very traditional MVC APP.

4th

5th

6th

One point to also note that now folder organization in the file system and solution explorer is same as you can see in the below screen shots.

7th

8th

This also means whatever changes i do in the file system under src folder it will take effect in VS. Let’s create myImages folder in the file system with one image there. As soon as i added the image in the file system, it gets automatically synced with Solution Explorer.

9th

10th

Now, lets create one controller say GreetController but from the notepad; this is just to prove the point that we don’t need to build the app to take the code changes effect.

13th

Now, after saving the same when i refresh the browser, then it will return me new controller’s output. so, this is called dynamic compilation.

14th

Thanks for joining me for the 1st Edition of ASP.NET 5. We’ll delve further in coming topics. Till then stay tuned and Happy Coding.

Thanks,
Rahul Sahay
Happy Coding

2,292 total views, no views today

How to enable Spartan Browser in Windows 10?

Hi Friends,

I just installed Windows 10 on my 2ndry machine. And to my surprise when I installed the same; I was expecting new Microsoft Browser by default; unfortunately this was not there. But, when I delved around Spartan documentation; I found the trick to enable the same.

Steps to enable Spartan(Microsoft Edge) on Windows 10 preview.

    Type this “about:flags” in IE browser. This will open the following set of commands in the browser.
    1st

    Then, select “Enabled” under “Enable Experimental Web Platform Features,” and restart the browser.

    After doing above settings, you need to restart the PC to sync the settings. Once you restart, you will notice project Spartan logo on start screen which you can apply to taskbar as well as shown below.

    2nd

    3rd

    Here comes project Spartan. Awesome experience doing hands on with Windows 10. Specially Project Spartan.

    4th

    Thanks for joining me.

    Thanks,
    Rahul Sahay
    Happy Coding

    1,528 total views, no views today