Friday, December 23, 2011

Understanding Amazon Web Services

Introduction

As the world largest online retailer, Amazon is also known as the pioneer of the cloud computing wave. It provides Amazon EC2 and S3 as first infrastructure-as-a-service (iaas). Some developers will think Amazon EC2 and S3 are Amazon’s Cloud Computing platform. Actually it is just two of products in Amazon cloud computing solution – Amazon Web Services. In this article, I will show all the cloud products in Amazon web service family to let developers have a big picture of Amazon cloud computing solution, so developers can build application to run on cloud. 

History of Amazon Could Computing

A decade ago, Amazon rose as one of the first online retailer. In order to provide highly reliable and scalable web site for shopper around the world, Amazon built many large data centers in US and around the world. Therefore, it accumulates a lot of experience on building, managing, and expanding data centers. After virtualization technology become maturate, dynamically creating, assigning, updating, and removing virtual server are possible, Amazon utilizes the virtualization technology to rebuild its infrastructure for itself, and also opens up as cloud computing service to external companies and developers.

August 25, 2006, Amazon announced a limited public beta of EC2. Access to EC2 was granted on a first come first served basis.
October 16, 2007, Amazon added two new instance types, large and extra-large.
May 29, 2008, Amazon added two more instance types, high-CPU medium and high-CPU extra-large.
March 27, 2008, Amazon added three new features. These features included static IP addresses, availability zones and user selectable kernels.
August 20, 2008, Amazon added Elastic Block Store (EBS).
October 23, 2008, Amazon EC2 beta label is dropped. It is moved to production stage. At the same day, Amazon announced other new features: a service level agreement for EC2, Microsoft Windows in beta form on EC2, Microsoft SQL Server in beta form on EC2.
May 18, 2009, Amazon added AWS management console, load balancing, auto-scaling, and cloud monitoring services.
December 2010, Amazon offers a bundle of free resource credits to new account holders. The credits are designed to run a “micro” sized server for one year. Charges are applied on demand so the credit need not be used in the first month.

Amazon Web Services Detail

There are many types of cloud products in Amazon Web Services. It includes Compute, Content Deliver, Database, Deployment & Management, E-Commerce, Messaging, Monitoring, Networking, Payments & Billing, Storage, Support, Web Traffic, and Workforce.
Amazon Web Services

Compute

The Compute category is the core category of Amazon Web Services. It contains products to allow developers use amazon’s computing power to run application or web site, such as running web application in Amazon’s EC2. There are three products in this category, Amazon Elastic Compute Cloud (EC2), Amazon Elastic MapReduce, and Auto Scaling.
Amazon Elastic Compute Cloud (EC2) – it delivers scalable, pay-as-you-go compute capacity in the cloud.
Amazon Elastic MapReduce – it is a web service that enables businesses, researchers, data analysts, and developers to easily and cost-effectively process vast amounts of data.
Auto Scaling – it allows you to automatically scale your Amazon EC2 capacity up or down according to conditions you define.

Content Delivery

This category contains products that can help delivering content to users. There is only one product in this category, Amazon CloudFront.
Amazon CloudFront – it is a web service that makes it easy to distribute content with low latency via a global network of edge locations.

Database

This category contains products that can store user data temporarily or permanently in the cloud. There are three products here, Amazon SimpleDB, Amazon Relational Database Service (RDS), and Amazon ElastiCache.
Amazon SimpleDB – it works in conjunction with Amazon S3 and Amazon EC2 to run queries on structured data in real time.
Amazon Relational Database Service (RDS) – it is a web service that makes it easy to set up, operate, and scale a relational database in the cloud.
Amazon ElastiCache – it is a web service that makes it easy to deploy, operate, and scale an in-memory cache in the cloud.

Deployment & Management

This category contains products that can help developers to deploy their application into cloud and manage their application. There are two products here, AWS Elastic Beanstalk and AWS CloudFormation.
AWS Elastic Beanstalk – it is an even easier way to quickly deploy and manage applications in the AWS cloud. You simply upload your application, and Elastic Beanstalk automatically handles the deployment details of capacity provisioning, load balancing, auto-scaling, and application health monitoring.
AWS CloudFormation – AWS CloudFormation is a service that gives developers and businesses an easy way to create a collection of related AWS resources and provision them in an orderly and predictable fashion.

E-Commerce

This category contains products that are for building e-commerce application. There is only one product here, Amazon Fulfillment Web Service.
Amazon Fulfillment Web Service (FWS) – it allows merchants to deliver products using Amazon.com’s worldwide fulfillment capabilities.

Messaging

This category contains products for sending and receiving messages. There are three products here, Amazon Simple Queue Service (SQS), Amazon Simple Notification Service (SNS), and Amazon Simple Email Service (SES).
Amazon Simple Queue Service (SQS) – it provides a hosted queue for storing messages as they travel between computers, making it easy to build automated workflow between Web services.
Amazon Simple Notification Service (SNS) – it is a web service that makes it easy to set up, operate, and send notifications from the cloud.
Amazon Simple Email Service (SES) – it is a highly scalable and cost-effective bulk and transactional email-sending service for the cloud.

Monitoring

This category contains products that provide information of how your resources are used. There is only one product here, Amazon CloudWatch.
Amazon CloudWatch – it is a web service that provides monitoring for AWS could resources, starting with Amazon EC2.

Networking

This category contains products that can be used to build a virtual network. There are four products here, Amazon Route 53, Amazon Virtual Private Cloud (VPC), AWS Direct Connect, and Elastic Load Balancing.
Amazon Route 53 – it is a highly available and scalable Domain Name System (DNS) web service.
Amazon Virtual Private Cloud (VPC) – it lets you provision a private, isolated section of the Amazon Web Services (AWS) Cloud where you can launch AWS resources in a virtual network that you define. With Amazon VPC, you can define a virtual network topology that closely resembles a traditional network that you might operate in your own datacenter.
AWS Direct Connect – it makes it easy to establish a dedicated network connection from your premise to AWS, which in many cases can reduce your network costs, increase bandwidth throughput, and provide a more consistent network experience than Internet-based connections.
Elastic Load Balancing – it automatically distributes incoming application traffic across multiple Amazon EC2 instances.

Payments & Billing

This category contains products that can add payment function in your cloud based application. There are two products here, Amazon Flexible Payment Service (FPS) and Amazon DevPay.
Amazon Flexible Payment Service (FPS) – it facilitates the digital transfer of money between any two entities, humans or computers.
Amazon DevPay – it is a billing and account management service which enables developers to collect payment for their AWS applications.

Storage

This category contains products that are used to store unstructured data. This is different with Database category. There are three products here, Amazon Simple Storage Service (S3), Amazon Elastic Block Store (EBS), and AWS Import/Export.
Amazon Simple Storage Service – Amazon Simple Storage Service provides a fully redundant data storage infrastructure for storing and retrieving any amount of data, at any time, from anywhere on the Web.
Amazon Elastic Block Store (EBS) – it provides block level storage volumes for use with Amazon EC2 instances. Amazon EBS volumes are off-instance storage that persists independently from the life of an instance.
AWS Import/Export – it accelerates moving large amounts of data into and out of AWS using portable storage devices for transport.

Support

This category contains products that can be used to get support from Amazon. There is only one product in this category, AWS Premium Support.
AWS Premium Support – it is a one-on-one, fast-response support channel to help you build and run applications on AWS Infrastructure Services.

Web Traffic

This category contains products that can help developer to get website traffic statistics. There are two products in this category, Alexa Web Information Service and Alexa Top Sites.
Alexa Web Information Service – it makes Alexa’s huge repository of data about structure and traffic patterns on the Web available to developers.
Alexa Top Sites – it exposes global website traffic data as it is continuously collected and updated by Alexa Traffic Rank.

Workforce

This category contains products that allow companies to award work to developers and let developers to find work from companies. There is only one product in this category, Amazon Mechanical Turk.
Amazon Mechanical Turk – it enables companies to access thousands of global workers on demand and programmatically integrate their work into various business processes.

Netflix

It’s interesting to know we are using services on Amazon cloud every day without notice it. Netflix streaming service is built on top of Amazon cloud platform. It let Amazon to provide a reliable infrastructure, so Netflix can focus on building and improving its business. By using Amazon cloud service, Netflix can easily deal with the increase demanding of their movie services.

Sunday, December 4, 2011

MVC on Azure for Beginner

Introduction

Windows Azure platform is Microsoft’s cloud solution. Compare to other cloud solutions, the biggest advantage is it seamlessly integrate with Microsoft .NET framework and development environment, therefore, regular .NET application can be moved to Azure effortless. This article will show how to develop and deploy an ASP.NET MVC web application to Windows Azure platform.

Develop a MVC application with Azure SDK

In order to develop an application that can run on Windows Azure, you must have Windows Azure SDK installed on your computer. The Azure SDK can be downloaded from Microsoft Windows Azure portal site.
Windows Azure Site
After installed Windows Azure SDK, you can open up Visual Studio to start a new project. There is a new project category Cloud in your Visual Studio project template. It has only one project template, Windows Azure Project.
Windows Azure Solution
After selected Windows Azure Project, you can choose different Roles. Role represents the application running in Windows Azure platform. There are three types of role defined in Windows Azure platform, web role, windows role and VM role. Web role stands for a web application, windows role stands for a windows service application, and VM role stands for a standalone Windows environment. In Visual Studio, you can create ASP.NET Web Role, ASP.NET MVC 3 Web Role, ASP.NET MVC 2 Web Role, and WCF Service Web Role. Not any application is suitable for running in Windows Azure.
New Windows Azure Project
If selected ASP.NET MVC 3 Web Role project, you can follow the project wizard to create the web application. This project wizard is identical to the normal ASP.NET MVC 3 project wizard. Below is what your solution end up with
Project Detail
If you compare this solution with a normal ASP.NET MVC solution, you will see an additional Azure project is in here. It contains configurations of our Windows Azure project. There are two kinds of configuration file: Service definition file, ServiceDefinition.csdef, and service configuration file, ServiceConfiguration.cscfg.
The service definition file defines all roles in your solution and their information that includes
1. Endpoint information. E.g. HTTP is used for web role.
2. Storage information. E.g.  local storage or Azure storage.
3. Any custom configuration information.
This is what ServiceDefinition.csdef file looks like in my Azure project
<?xml version="1.0" encoding="utf-8"?><ServiceDefinition name="MVConAzure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition"<WebRole name="Demo.MvcWebRole" vmsize="Small">    <Sites>      <Site name="Web">        <Bindings>          <Binding name="Endpoint1" endpointName="Endpoint1" />        </Bindings>      </Site>    </Sites>    <Endpoints>      <InputEndpoint name="Endpoint1" protocol="http" port="80" />    </Endpoints>    <Imports>      <Import moduleName="Diagnostics" />    </Imports>  </WebRole></ServiceDefinition>
The service definition cannot be changed at runtime. Any change requires a new deployment of your service. Your service is restricted in using only the network endpoints and resources that are defined in this file. You can think of this piece of the configuration as defining what the infrastructure of your service is, and how the parts fit together.
The service configuration file includes the entire configuration needed for the role instances in your service. Each role has its own configuration. The contents of the configuration file can be changed at runtime, which saves the need to redeploy your application when some part of the role configuration changes. You can also access the configuration in code, in a similar manner that you might read a web.config file in an ASP.NET application.
This is what ServiceConfiguration looks like in my Azure project
<?xml version="1.0" encoding="utf-8"?><ServiceConfiguration serviceName="MVConAzure" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*"<Role name="Demo.MvcWebRole">    <Instances count="1" />    <ConfigurationSettings>      <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />    </ConfigurationSettings>  </Role></ServiceConfiguration>
You can compile and run the application right now. The application is not running in Visual Studio Cassini local web server as the normal ASP.NET MVC application. It’s running in Windows Azure Emulator. Windows Azure platform includes three major pieces, Windows Azure, SQL Azure, and Windows Azure AppFabric. The emulator is acting very similar to Windows Azure platform. It allow developer to run and debug application without deploy to the public cloud.
Note: sometime you will see error
Windows Azure Tools: Failed to initialize Windows Azure storage emulator. Unable to start Development Storage. Failed to start Storage Emulator: the SQL Server instance ‘localhost\SQLExpress’ could not be found.   Please configure the SQL Server instance for Storage Emulator using the ‘DSInit’ utility in the Windows Azure SDK.
This is because Windows Azure storage emulator default uses SQLExpress as the backend database. If you don’t have SQLExpress database installed or it is not installed with the default name, then Storage Eumlator will not able to find it. To fix this error, you can use DSInit to change storage emulator to point to your local SQLServer database.

Deploy Application to Windows Azure Public Cloud

To deploy the application to Windows Azure platform, you need to have Windows Azure account first. You can register a Windows Azure account for 90 days free trial. However, you need to provide your credit card information, so Microsoft can charge you to your credit card for any over the limit usage.  The deployment is very simple. You can publish your Windows Azure based application directly to Windows Azure public cloud in Visual Studio.
Publish
Right click the Azure project and select Publish menu item. This will bring up Publish Windows Azure Application window.
1. Select your subscription.
2. Select your setting. Give a host service name. This name will be used as your subdomain name.
Note: if this is the first time publishing application to Windows Azure Platform, you will be prompted to add a Windows Azure authentication setting.
3. Click Pushing button to start the publish process. The Visual Studio will compile your application first, and then connect to Windows Azure platform with your account information to start deployment. There is new tab, Windows Azure Active Log, shows up in your Visual Studio IDE to display the progress of deployment. The entire deployment could take several minutes.
Publish Status in Visual Studio
You can also view the deployment status in your Azure control panel
Publish Status in Azure
After the deployment completed, the Windows Azure Activity Log window shows status as completed and all deployment information.
Windows Azure Activity Log
You can use the assigned URL, in here is http://mvconazure.cloudapp.net, to view just deployed MVC web application in Windows Azure public cloud.
Web Page

Summary

Cloud computing is getting popular right now because the benefits of cost saving, scalability, and easy implementation. The Windows Azure platform is the primary cloud computing choice for .NET application developers because it allows us to leverage all our .NET development knowledge to join the new trend.