Code Mahek
  • Blog
  • About
  • Contact
  • Random Clicks
  • Resume
  • Ava Chat Bot

Fragrance
​of Programming

Integrate ASP.NET Owin and Angular CLI project

5/13/2018

Comments

 
In this post I will show you how to integrate an OWIN project with Angular CLI project.
Below are the pre-requisites:
  • Node.js
  • Angular CLI
  • Visual Studio 2017
First lets create an empty ASP.NET WebAPI project
Picture
After the project is successfully created, add new "cs" file and name it as Startup.cs and delete "Global.asax" file.
Add the below NuGet packages and it's dependencies into your project:
  • Microsoft.AspNet.WebApi.Owin
  • Microsoft.Owin.StaticFiles
  • Microsoft.Owin.Host.SystemWeb
Now in the project add new "App" folder and let it be empty, it will be the output folder of the Angular CLI project
Now in the Startup.cs file, please add the below code.

    
Now modify the web.config  as shown below
Picture
We are done with the Owin project, so now let's create the Angular CLI project.
I am creating the Angular project inside directory "AngularProject" and overall structure of Owin and Angular is as shown below
Picture
Now open powershell and browse to parent directory of AngularProject i.e. in my case its "c:\git". Now execute the below command
Picture
Once the Angular CLI project is created successfully, open ".angular-cli.json" and modify the outdir file location to the App folder which we created in the owin project.
Picture
Now build the angular project using "ng build -ec" and you will notice that all the build files are copied into App folder.
Now run the Owin project which we created and you will see the index.html of Angular project got rendered using owin.

​Hope you enjoyed reading!!!!
Comments

Exploring Azure Functions

5/10/2017

Comments

 
Picture
Azure functions is the idea of events and code, developers will provide the Azure with a function or code and you till what event should trigger that function.
  • Scheduler: You are actually telling Azure function to run the particular code at a particular time or maybe. So in this case scheduler is the event which triggers the Azure function. This can used at many places, suppose at the end of the trading day you need clear all the database or want to run the batch.
  • Process when a new data comes in the storage. This might be particularly helpful when a particular message or data received then we need to send the email.
  • Lastly, its web hook, whenever someone calls a specific URL, then you want your function to run and example might be whenever user comments on the issue created by GitHub then I need to run the azure function, or need to handle the webhook callback from the payment provider whenever anything is sold online from the e-commerce website.
All the above discussed scenario can be easily achieved using IaaS i.e. Infrastructure as a service i.e Create my own virtual machine and deploy everything from windows service to web server as per my requirement. But in that case all the responsibility is with the developer to handle patching and maintaining, scaling etc. So it will be really great if all that work is actually done by Microsoft himself and developer concentrates on just coding!!!
Azure Cloud Services: Developer can also use web roles or Worker roles. Web roles are used for hosting websites and web APIs, and Worker roles are designed for your background tasks, like processing queues and other batch work. So in cloud services all the environment related work is taken care by Microsoft and this model looks perfect for developers
​Why do we need Azure Functions?
  • Azure functions provides us with the simplified programming model. All developer needs to do is write the code that responds to the event, whether it’s an HTTP request or Queue message
  • No boilerplate of how the event is connected or raised, all that is handled by the framework, so it’s very light weight.
  • Focus on business requirements
  • New pricing model: With cloud services and IaaS user need to have at least one server and user need to pay for that server even though if use is minimal. So now with Azure Functions, developer pays only when its code is running. So suppose you are listening to the queue and no message arrives than you pay nothing.
  • Azure function will automatically scale the servers running your functions to meet the demand, so if there are no demands there might be no servers actively running the code but when needed framework will quickly spin the when required.
Benefits:
  • Rapid and simple development
    • Code within the portal
    • Eliminate the boilerplate
  • Developer will get all the power of Azure Web Apps since Azure Function is developed on top of this framework: CI, Kudu, Easy Auth, Certs etc
  • Highly cost effective pricing and it makes overall very cheap.
  • And the best is we don’t have to maintain any servers. So effectively in big organisation we don’t need to have any Environment team for setting up the server and maintaining it.
What is Serverless?
Server less doesn’t means there are no server involved, of course servers are involved but it’s abstract from the users/developers. But we delegate all the management of the server to Azure instead of us doing it. So we can purely focus on business requirement.
All the big enterprise application relies on the third party platform or backend. For example, for database we might use Azure DocumentDb and for authentication we might use some other third party platform. And with growing number of third party platform service, we might need to write our own custom backend code as per our requirement and that’s were Azure Functions comes to help us. So you can just tell the Azure function which events you need to respond to and you can write your own custom code. So with this comes a new term “Function as a Service (FaaS)”.

Comments
<<Previous

    RSS Feed

    Categories

    All
    Azure
    C#
    Cloud
    CodeProject
    CSharp
    DotNet Core
    Jetbrains
    .NET
    Rider
    Source Generators
    SQL
    Tech News
    Ubuntu
    Visual Studio 2015
    Visual Studio 2019
    Windows
    Windows 10

    Archives

    May 2020
    February 2019
    January 2019
    December 2018
    May 2018
    December 2017
    November 2017
    October 2017
    September 2017
    July 2017
    May 2017
    April 2017
    May 2015
    April 2015
    March 2015

    View my profile on LinkedIn

Location

Contact Us

    Subscribe Today!

Submit
  • Blog
  • About
  • Contact
  • Random Clicks
  • Resume
  • Ava Chat Bot