Monday, February 20, 2012

WCF Web API to ASP.NET Web API

WCF Rest Starter Kit --> WCF REST (WebHttpBinding) --> WCF Web API  --> ASP.NET Web API (WCF to ASP.NET Migration!)

Hope many of you have noticed the ASP.NET MVC4 Beta announcement. In that the key thing to note is ASP.NET Web API. ASP.NET MVC 4 now includes ASP.NET Web API (single integrated web API framework), a framework for building and consuming HTTP services that can reach a broad range of clients including browsers, phones, and tablets.

Everything including technology has a start and an end. Including technology, it necessities evolution to survive. This evolution of Web API track from WCF to ASP.NET is good for below reasons: 

1.       This will stop the confusion among developers to use what ASP.NET MVC Controller (JSON data from controller) or WCF Rest API

2.       Moving to ASP.NET MVC enables to better code re-use, easier & maintenance. One can use the same model to expose your data as HTML, JSON, XML, ATOM, OData etc….No Need of one more WCF Layer.

3.       HTTPClient / System.Net.HTTP part of .NET Framework 4.5 would be better suitable part of ASP.NET rather than WCF. Web API name itself contains both Web & Services! And Http belongs to more of Web than Services.

4.       Remember one of the main goal for WCF is unification of Microsoft’s distributed computing technologies (ASMX, .NET Remoting, Enterprise Services, WSE, System.Messaging, System.Net etc) with SOAP/XML as base framework. WCF won’t support or scale HTTP to full extent.  

This is not end of WCF, but the scope of exposing data via WCF is reduced (Mostly SOAP). World is around REST now. In the competitive world, the system or technology that are easily maintainable, sustainable, easy reach or interoperable including browsers, phones (IPhone, Android, Windows Phone etc….), tablets (IPad) only survives.  Restful approach follows most of the things – Simple, easily maintainable, reach etc. With Web API moves into ASP.NET, overall it is good for end-users. ASP.NET Web API is great for building services that follow the RESTful way.

 Why HTTP?

The Hypertext Transfer Protocol (HTTP) is an application protocol for distributed, collaborative systems. HTTP is not just for serving up web pages. HTTP is simple, flexible, stateless and ubiquitous.

HTTP provides the following nine methods or verbs that we can perform on a identified resource. 
  • HEAD – Similar to a GET request without the response body. This is useful for retrieving meta-information written in response headers.
  • GET  - Requests to just retrieve the specified resource.
  • POST – Client sends data (message body) to the server for an action .
  • PUT - Uploads or updates the resource.
  • DELETE Deletes the specified resource.
  • TRACE - allows the client to see what is being received at the other end of the request chain and use that data for testing or diagnostic information
  • OPTIONS Returns the HTTP methods that the server supports for specified URL.
  • PATCH Is used to apply partial modifications to a resource.
What is REST?
REST defines an architectural style for building services in the “Web” way. REST is not tied to any particular technology or platform – it’s just another way to design things to work like the Web. Again this is not something new. REST concept exists for a long time but not utilized to its full power, until now.

Operations in Restful services are supported using HTTP methods (Like GET, PUT, POST, or DELETE).

Definition:
"Representational state transfer (REST) is a style of software architecture for distributed hypermedia systems such as the World Wide Web. The term Representational State Transfer (REST) was introduced and defined in 2000 by Roy Fielding[1][2] in his doctoral dissertation. Fielding is one of the principal authors of the Hypertext Transfer Protocol (HTTP) specification versions 1.0 and 1.1." - From wikipedia.org

Why REST Popular?
 


Is Web Popular?! ;)

Web - WWW, which is omnipresent everywhere now. Almost everyone knows about Web. RESTful architecture simply follows the tenets of the web which provides the same reach to people. I will give you a specific simple example - Just think of accessing a Service as below: You can access whatever the book detail of any author you want through HTTP GET itself! No Soap Messages, Proxy etc.


amazon.com/authors/{author}/{book}
Ex: amazon.com/authors/ArunGanesh/VS2010
amazon.com/authors/{author}?book={book}
Ex: amazon.com/authors/ArunGanesh?book=VS2010
Key Items to remember (REST):

  


1. In Web, every resource being referred by a unique identifier, also known as a universal resource identifier (URI).

URI / Segment of a URI map to Application Logic. In the above example you can see that the segment of the URL itself being mapped to an application logic.


2. Utilize

HTTP Verbs - HTTP GET, POST, PUT, DELETE etc.


3. Utilize HTTP Headers for representing what content type is required and services is returning. For instance, you can represent things like: languages, authentication, authorization, accepted encoding, char set, content type, length etc...

What ASP.NET Web API provides: 

The integrated stack supports the following features: 
  • Modern HTTP programming model
  • Full support for ASP.NET Routing
  • Format flexibility
  • HTTP Client integration
  • Enabled OAuth and OData support
  • Configuration simplification
  • Content negotiation and custom formatters
  • Model binding and validation
  • Filters
  • Query composition
  • Easy to unit test
  • Improved Inversion of Control (IoC) via DependencyResolver
  • Code-based configuration
  • Self-host

What’s the key difference: 

ASP.NET Web APIs are based on controllers, classes which derive from a new ApiController class.

WCF Web API
ASP.NET Web API
Service
Web API controller                  
Operation               
Action
Service contract
Not applicable
Endpoint
Not applicable
URI templates
ASP.NET Routing
Message handlers
Same
Formatters
Same
Operation handlers
Filters, model binders


NuGet Packages:

Will post more on this topic in upcoming weeks.

Sunday, February 12, 2012

"Office 15" Technical Preview


Office 15 is the codename for the next generation of the Microsoft Office products and services. Microsoft announced the Technical Preview for a select group of partners under non-disclosure agreements for testing and to provide feedback. In the upcoming months, we may see few more details.
While announcing the Windows 8 ARM's plan, they also showed a quick preview of Office 15 too.


Watch this Video to get a quick preview of Office 15.

Thursday, February 02, 2012

Kinect for Windows

As you all known, Kinect is the game changer in game industry. In most of our home, who love to play games will be having Kinect console. Kinect is no more just a playing console, it show potential to use it many other industries like healthcare, diagnosysis etc...

Check it out this inspiring video for Kinnect Effect!

Now Microsoft released Kinect for Windows. So What's in this? and What we can do with this?
With this SDK, you can know
  • How the Kinect color and depth camera work
  • How to use skeletal tracking to track joint positions in your application. 
  • How to use the Kinect to record audio
  • How to use speech recognition to control your application via voice commands and much more

Are you excited, then what are you waiting for, download and have fun!!!


Saturday, January 28, 2012

Azure Portal and Training Kit Transformed


Both the Azure portal and training kit evolved over the years. Portal is easy to navigate, build and manage Azure services. It also have all the useful help links.



I recently installed Azure Training kit and surprised on looking at all the demos, presentation for each and every artifacts. The content would be very helpful for the developer community to jump-in into Azure world.  
Installation experience is also good. The pros is all the required component can be installed from the same wizard (which in turns use the Web platform Wizard). The con part is the memory it takes and sometime get stuck.


Check out the Trainig kit here: Windows Azure Training Kit - January Refresh

Friday, January 20, 2012

Windows Azure AppFabric name is missing!


When I was searching for Azure Appfabric, I noticed there is no more Appfabric term being used.

Specifcally when I noticed in the Appfabric blog that they are moving from this blog to general Windows Azure Team blog, it is clear that no more Appfabric term.

So what happens to all the services - Windows Azure Service Bus, Windows Azure Access Control, Windows Azure Caching etc... It's look like still all services exists only the name changes from Appfabric to just Azure.

In a way, it is better, during inital days, I was confused between Azure Appfabric and Windows Server Appfabric. But I am sure, it will take some time for deverlopers to understand this brand name change.

Check all my Azure related blogs: http://arunmvp.blogspot.com/search/label/Azure

Thursday, January 05, 2012

What is the Windows Azure platform?


The Windows Azure platform is nothing but Microsoft’s cloud computing services platform. Windows Azure, Microsoft SQL Azure and AppFabric are the key components of the Windows Azure platform. Microsoft’s Windows Azure platform is a group of cloud technologies, each providing a specific set of services to end users.




·         Windows Azure Compute: Windows Azure compute service enables developers to run any applications starting from .NET, Java, PHP etc… In Windows Azure for an application to scale out, it will run multiple copy of the code in various virtual machines.  Windows Azure application consists of Web role instances and/or Worker role instances, each of which runs in its own Windows virtual machine.

·      Windows Azure Storage: The Windows Azure storage services provide storage for binary and text data, messages, and structured data in Windows Azure

·         Microsoft SQL Azure: Provides relational cloud database solution

·         Windows Azure platform Services (Connectivity, Identiry and Perforamance) : It includes services like: AppFabric Access Control, AppFabric Service Bus, CDN and AppFabric Caching Service.

Check all my Azure related blogs: http://arunmvp.blogspot.com/search/label/Azure

Thursday, November 24, 2011

Azure Pattern - Scale Application

In Windows Azure for an application to scale out, it will run multiple copy of the code in various virtual machines. Windows Azure application consists of Web role instances and/or Worker role instances, each of which runs in its own Windows virtual machine.

Web role instance nothing but which accepts a HTTP/HTTPS request and respond back to customer web request via IIS 7 (ASP.NET Application). This instance needs to run in an IIS 7 Web Server only.

Worker role instance will do some background job (similar to Windows Service) and doesn’t expose to outside world directly. For instance one can use Worker role process to do some parallel bulk computing operations and then share with web role instance. A worker role can have any number of HTTP, HTTPS, or TCP endpoints. 

Queue: It allows Web role instances to communicate asynchronously with Worker role instances. It acts as a reliable and persistent messaging between services.  
Windows Azure services may be comprised of one or both types of roles and can run multiple instances of each type. Web / Worker Role instances can be added or removed based on demand and allow applications to quickly and economically scale-up or down as per the need. Windows Azure also exposes set of API’s to programmatically control the role instances.  

The typical Pattern for scaling up application on demand would look like below:


Tuesday, November 15, 2011

Web API - WCF Web API programming model


WCF Web API is a set of Windows Communication Foundation (WCF) components to develop Web APIs (Future Services).

Check out here for more details: http://wcf.codeplex.com/releases

Tuesday, October 18, 2011

Azure Storage


The Windows Azure storage services provide storage for binary and text data, messages, and structured data in Windows Azure

Option 1: Blob – Contains binary data: Blobs are organized by container.  Each storage account will be partitioned
by hierarchal containers which in turns have one or many blobs. We can store huge amount of data (text, audio, video, images etc…) with association of metadata like author details etc…

Two types of blobs:

·         Block blobs, which are optimized for streaming. Block blobs are comprised of blocks, each of which is identified by a block ID. Contain up to 200 GB.

·         Page blobs, which are optimized for random read/write operations. Page blobs are a collection of pages. Contain up to 1 TB.

A URL to refer to a blob includes the account name, the container name, and the blob name, as follows: http://myaccount.blob.core.windows.net/mycontainer/myblob

Sharing Policy: Container ACL access:

·         Full public read access: Container and blob data can be read via anonymous request.

·         Public read access for blobs only: Blob data within this container can be read via anonymous request, but container data is not available.

·         No public read access: Container and blob data can be read by the account owner only.


Windows Azure Drives: A Windows Azure drive acts as a local drive mounted on the file system and is accessible to code running in a role. The data written to a Windows Azure drive is stored in a page blob defined within the Windows Azure Blob service, and cached on the local file system.

Delivering High-Bandwidth Content with the Windows Azure Content Delivery Network:

This Windows Azure CDN feature enables customers to provide maximum bandwidth content to their users. As of now, Windows Azure CDN has 18 locations globally (United States, Europe, Asia, Australia and South America). As Windows Azure CDN caches Windows Azure blobs at strategically placed locations which is close to the location from which the request being made.  This is applicable to only blobs that are in public blob containers, which are available for anonymous access.


Option 2: Table - Entity Data Store: Tables store data as collections of entities. Table made up of rows / columns. Entities are similar to rows. A property is a name, typed-value pair, similar to a column. Don’t consider this as a RDBMS; it is more similar to ADO.NET Data services with reduced sub set including integer, string etc... It is mainly for store durable and scalable data structure that can be queried. It is equivalent of Amazon SimpleDB.

The operations are almost similar to that of a conventional database – tables. You can create, query and delete.

Option 3: Queue: It allows Web role instances to communicate asynchronously with Worker role instances. It acts as a reliable and persistent messaging between services.

In all the above options, Windows Azure storage keep the data replicated in many places and ensure data safety. Even one data copy being deleted or missed out can be available from another data copy from a data center. Isn’t this cool? Yes, this is nice feature which provides reliability and business continuity.

Moreover each of the data storage has a named URI (universal resource identifier) which can be accessible by any application including on cloud or on premises application through REST. REST defines an architectural style based on a set of constraints for building things the “Web” way. For more information on REST, refer my blog.


Check all my Azure related blogs: http://arunmvp.blogspot.com/search/label/Azure

Saturday, September 24, 2011

Wanna Try Windows Azure?

Do you want to try / explore Windows Azure, then check here: http://www.windowsazure.com/en-us/pricing/free-trial/ 

Free trial includes the following:
Free Trial Details:

  • compute VM
  • 750 small compute hours per month
  • relational database
  • 1GB web edition SQL Azure database
  • storage
  • 20GB with 50,000 storage transactions
  • bandwidth
  • Unlimited inbound / 20GB Outbound

Thursday, September 15, 2011

Scenarios where we can use Windows Azure Platform?

Key Scenarios where we can use Windows Azure Platform?
Please remember one point, cloud computing is not the ONLY best option for all scenarios. It suits best for some key scenarios. 

One can leverage Azure platform in various scenarios, few thoughts:

  • Speed to Market: Small vendors or initial startup company can utilize windows azure platform to deploy their application without worrying about the infrastructure. Based on the application popularity they can scale up the platform.
  • Peak Load (Predictable and unpredictable): Enterprise applications can utilize windows azure platform especially during peak load. For instance, in support.xbox.com site, the load is at its peak during Christmas Holiday season. We can’t just add more hardware just for few weeks, unless we have something like Azure where one can scale up or down the hardware in minutes with very less cost. Another best example would be IRCTC, Indian railway online ticket booking web site, this will be always at its peak at 8.00 – 8.30 A.M (that’s the time Tatkal is open), Azure is a place where we can set such that only for this specific time frame to scale the hardware resources to serve the end client.
  • Limited Time frame: In scenarios where we want to expose an application for only specific time frame. For instance, a movie release, the web site provides all the movie information review etc. This site will exist for minimal duration depends on film.
  • Scalability: Scenarios where one no need to worry about capacity planning. Increase or reduce the capacity real time.
  • Heavy Computing: Scenarios where you need to do large scale processing like analytics. You can leverage cloud for infinite computing capacity.
    Check all my Azure related blogs: http://arunmvp.blogspot.com/search/label/Azure

Monday, August 22, 2011

Do I really need to consider Cloud Computing?!

(Image From Wiki)

To answer the question why cloud computing, first we need to look into what is the existing traditional way of computing, deploying and maintain the applications and what are the available options:

Option 1: Companies can have their own servers with required software and connectivity. In this option, we need to spend more initial infrastructure cost and we have complete control.

Option 2: Hosted Servers on rental. You have less control over here, but the user no need to worry about the maintenance of the server including hardware and software.  But one key downside in this approach is you need to still pay even your application usage is idle.

With both these options, we have still the following open questions:

  1. How to scale up or down your hardware very quickly with very low cost?
  2. How to reduce your operation costs based on the usage?
  3. How to provide high availability / business continuity?
  4. How quickly I can make my application Go-Live?
Cloud computing is a new emerging third option which answer the above questions.  

Option 3:    Cloud computing which is a scalable virtualized hosting environment. Cloud computing users can avoid capital charges on hardware, software, and services. Just pay the provider only for what we use (consumption based model). Charging will be similar to resources consumed, like electricity or subscription time-based, like a newspaper.

What are the Benefits?

  1. Agile: Ability to implement, deploy the solutions for end users very quickly.
  2. Low Cost: Operation and capital cost will be less.
  3. Scalability / Flexibility: Ability to scale up/down your application hardware / software in minutes.
  4. Pricing Model: You pay for what you use. Based on the Usage of resources.
  5. Reliability:  Multiple redundant sites and the quality maintained in Datacenters by Microsoft / Amazon etc makes more reliable. Most of the time, it will be 99.99% availability.
  6. Maintenance: Less maintenance (Hardware / Software) as it will be takes care by service providers.
  7. Better Operational models:  For instance, we can utilize in places where we require scale-up hardware only for particular time frame alone where the user load is heavy.
  8. Easier Deployment: Simplified Application Deployment and management.

Check all my Azure related blogs: http://arunmvp.blogspot.com/search/label/Azure