Windows Azure–Table Storage

Windows Azure provides three storage services – Table, Blobs and Queues. Here I explained about the Table Storage. Before getting into the coding stuff let me put some points about the Azure table storage.

Do not get misunderstand the Azure tables with a RDBMS table. In RDBMS table is an entity, but Azure table is a storage service.

We have rows and columns structure in Azure table. A row is called an Entity in Azure table. Columns are called Properties.

There 3 system properties attached to each Azure table, they are Partition Key, Row Key and Timestamp. Ex If you are creating a Azure table with Name, Address properties then your table would have total of 5 properties including the 3 system properties.

What are the System Properties ?

Partition Key – We know Windows Azure is a cloud OS hosted in MS datacenters. Where the applications and services we deploy are distributed among several servers. So when storing data in Windows Azure, partition key allows us to distribute the data among different partitions. (physically these partitions no need to be in different servers, they can be in one particular server as well; but Windows Azure maintains a method of grouping the data)

So If your table has very few numbers of entities, then probably you don’t need to create more partition keys. One is enough.

Still there are plenty of arguments and posts on selecting a proper partition key. Select the partition key in a way that you can balance the load of your table storage.

Partition keys are string values.

Row Key – Row keys are unique within a particular partition. We know partition keys form partitions. Within a partition a row key cannot be duplicated. So the partition key and the row key together forms a the unique identifier for a entity, similar to primary key known as Data Service Key.

Row key is also string value. Normally in the MS sites you can see this kind of row key implementation

RowKey = string.Format("{0:10}_{1}", DateTime.MaxValue.Ticks – DateTime.Now.Ticks, Guid.NewGuid());

This picture will explain you the concept of Partition Key and Row Key

image

 

Timestamp – This is fully maintained by the system. Every entity has a version maintained by the system. Timestamp is not a property for application programming uses. It is transparent to the users.

According MS Documentation – Timestamp is a read-only system maintained property which should be treated as an opaque property.

Azure Table Storage More…

An application must use a valid account to access Windows Azure Storage. You can create a new account via the Windows Azure portal web interface. The user will receive a 256-bit secret key once the account is created. This secret key is then used to authenticate user requests to the storage system.

Specifically, a HMAC SHA256 signature for the request is created using this secret key. The signature is passed with each request to authenticate the user requests. The account name is part of the host name in the URL. The hostname for accessing tables is <accountName>.table.core.windows.net.

An entity can have at most 255 properties including the mandatory system properties, so we can have our own 252 properties (columns).

Partition Key and Row Key are of string type, and each key is limited to 1KB in size.

Combined size of all data in an entity cannot exceed 1MB. This size includes the size of the property names as well as the size of the property values or their types, which includes the two mandatory key properties (Partition Key and Row Key).

Supported property types are: Binary, Bool, DateTime, Double, GUID, Int, Int64, String.

LightSwitch beta 1

Microsoft has introduced a new easy way to create Windows and Web based applications. When we develop applications much of the code we write for CRUD operations and data validation. LightSwitch makes this really easier by providing a very friendly manner.

You can download the LightSwitch beta 1and try it out. Download the LightSwitch Training kit. (Training Kit only provides VB.NET samples ).

LightSwitch is built on the Silverlight out of the browser feature. It has specific data types like phone number, email and others. These types are transparent to the database since a typical RDBMS ( in this case SQL Server) doesn’t have those types. So if you create table with email type in the LightSwitch it makes the SQL data type as varchar and it keeps the data type as email. So this makes LightSwitch to validate the string as email and store it in a typical varchar value in the database.

This works similar to the validation module we have in the ASP.NET where the validation is done through a Javascript code. Adobe Dreamweaver’s Spry also does the same thing.

But LightSwitch has more cool features like guided database relations, screen selections and connecting to external live data sources like bing maps.

Download the module and have fun

Smile

MCTS and MCPD Certification pathways

.NET 4.0 exams are there on the shelf. They have made plenty of changes to the .NET 4.0 and its exams as well. The main reason is .NET 4.0 has a CLR update and it is using a different version CLR. Normally there is no update from MCTS (old version) to MCTS (new version) the update exam available only for the MCPD holders. This is applicable to the .NET 4.0 also.

The .NET 4.0 has 4 MCTS versions and 3 MCPD versions.

MCTS Versions

  • .NET 4.0 Windows Application Development (includes WPF and XAML)
  • .NET 4.0 Web Application Development (includes Silverlight , MVC 2.0)
  • .NET 4.0 Data Access Application Development (ADO.NET)
  • .NET 4.0 Service Application Development (WCF)

MCPD Versions

  • .NET 4.0 MCPD in Windows Development  ( Following MCTS are pre requisites : Windows Application,Data Access,WCF)
  • .NET 4.0 MCPD in Web Development ( Following MCTS are pre requisites : Web Application,Data Access,WCF)
  • .NET 4.0 MCPD Enterprise Application Development ( Following MCTS are pre requisites : Windows Application,Web Application,Data Access,WCF)

There’s no separate exams for WPF, WF in .NET 4.0. But they may arrive very soon. I think MCTS for WF will definitely arrive with the SharePoint 2010 exams.

Starting a process from a Windows Service

If you have some knowledge about Windows services and their functionalities then go ahead. Otherwise you may not understand some of the points mentioned here.

Are you suffering from starting a process from your windows service ? I have a cunning solution for that. Normally we cannot start any process either on our local machine or from a remote machine through a windows service.

We can start the process by enabling the Desktop Interactive of the service, but the UAC system of Vista and Windows 7 is a problem, that every time we start the process from a service it asks whether to allow the desktop interactivity. We can’t ask our clients to stop the UAC system. So what is the solution ?

Now I think you have some idea why can’t we start a process from service. But you might have a question in your mind why we need a process for a service ? There can be several answers

  • We need to perform a CPU intensive operation
  • COM interoperability is clashing with some threading components of the service
  • Some actions can be performed more efficiently by a separate process rather than a service

I figured out this solution as I suffered from the bolded point. Here the method I have used.

Create an ASPX webpage (it should be hosted in a later version of IIS 4.0)

In the Page_Load method start the process.

Then Create the Windows Service to access the the web page. (Access it through normal WebRequest and WebResponse). Cool !

The real cool thing is you can almost start all the processes by using this method from a windows service. Even processes with arguments and Verbs.’

Here’s the code for the webpage

protected void Page_Load(object sender, EventArgs e)
{

Process p = new Process();

p.StartInfo.FileName = "path to your process (your .exe file)"

p.StartInfo.UseShellExecute = false;

p.StartInfo.CreateNoWindow = true;

p.Start();

p.WaitForExit();

p.Dispose();

}

 

In the service within the OnStart() put the following code

try

{

HttpWebRequest req = (HttpWebRequest)WebRequest.Create("ASPX page path");

HttpWebResponse resp = (HttpWebResponse)req.GetResponse();

}

catch (Exception ex)

{

}

Cloud Computing

What is cloud computing ? Before getting into the term what is cloud computing ask a question to yourself whether you have experiences working in the cloud. Every day we deal with cloud computing and use it. But the matter is we don’t know that is the cloud computing. The buzz cloud computing was a hot topic in 2007 and 2008. And still plenty of researches and business analyses are going in cloud computing.

Cloud computing is nothing other than using websites and web services for our use. Use in the sense it can be personal,business oriented or any thing else. Simply Facebook provides you a service of social networking. You save photos, videos and your notes in your accounts. You access them whenever you have an Internet connection. So the availability of the resources is high. Your share documents in the Skydrive, again whenever you have the access to Internet you have the access to your documents. And recently the Microsoft started the Office Web App. So the resources you saved and shared float above you like a cloud. Whenever you need them, you access it through the Internet. So cloud computing is not new to us and it is not other than the Internet computing and web services.

There are some buzz stories why we use the term cloud. One is most of the places and text books a cloud symbol is used to represent the Internet. So some say that’s the reason we call it cloud computing. Another story is the resources and the services you need, just float there and available every where like a cloud, and you can access it whenever you want it. Some say this is the reason how the word cloud came. But personally I prefer the 2nd one since it is more reasonable than the first one.

When it comes to cloud it has plenty of advantages

  • Hardware and Software independent. (You just need a machine with Internet connection)
  • High availability of the applications
  • The companies need not to worry about the Server farm requirements
  • Very cost effective
  • And much more..

Please do not get confused between the web hosting and the Cloud computing. Web hosting is getting a domain name from a hosting company and pay the company, then your site is up there in the Internet. Cloud is hosting of course but differs from the normal hosting. When it comes to cloud computing it is a platform and a development environment but a normal hosting doesn’t have those features.

Cloud application provides more scalability for the applications, managing, configuring and much more. Apart from that cloud does not include only web pages (web pages work as front end for the application / service).

Understanding the cloud computing is simple and easy. One simple googling on cloud computing will fetch you thousands of resources.

SQL Server Protocols

Based on some missing images this document might appear in a broken flow

SQL Server is the Microsoft’s Enterprise Data Management system. Recent release is SQL Server 2008 R2 (x64 bit only). We all know about the Database Management System and Database related concepts.
SQL Server comes with two powerful tools SQL Server Management Studio and SQL Server Configuration Manager.

To start learning SQL Server 2008 you should have an instance of database engine. Install it and connect to using SQL Server Management Studio.

To connect to the default instance type (local) or . (a dot) or server name. In your local machine the server name would be your machine’s name, in my case Thurupathan-PC or type localhost Typically you can specify the <server name>/<instance name>. If you do not provide the instance name it will connect to the default instance.

The parameters you can specify as server are

  • (local) – to connect to the local default instance
  • . – to connect to the default instance
  • localhost – to your local machine to default instance (Thurupathan-PC also same)
  • server name/instance name (ex – Thurupathan-PC/Sharepoint)

Here server is the physical (or a virtual ) machine. You can install more than one instance of database engine in one server.

You are connected to the default instance. Download the Adventure Works 2008 database from http://www.codeplex.com . This comes as a .msi file you can just double click it to install. (I didn’t explain the Restore Database process here for older Adventure works scripts, but I’ll explain restoring the database using another example). You do need to have the adventure works database in order to do the following exercise.

Then you are done with the learning track of the SQL Server 2008 or SQL Server 2008 R2.

Here I do not explain from the very beginning SELECT statements as you can Google for plenty of SQL statement tutorials. I explain only some specific things related to SQL Server configurations.

SQL Server runs on top of SQL Server OS which runs on a Windows OS. It has four protocols to connect with the database engine. You can view them through the SQL Server Configuration Manager.

MS SQL Server uses the port 1433 as its default port.

The default MSSQLSERVER instance can be configured with 4 different protocols.

  • Shared Memory – This protocols is used to run the server in the local machine.(You can right click and make it enable and disable)
  • Named Pipes – This used serve the machines in the local network. (typically in a specific broadcasting domain)
  • TCP/IP – This TCP/IP as we all know used to connect over the Internet, beyond a single broadcasting domain.
  • VIA – Virtual Interface Adapter is used to connect machines using specific machines by specifying the NIC number. This is also used to make transactions with different Database management systems.(I’m searching for some good explanation for VIA)

You can get a question that if Shared Memory, Named Pipes and TCP/IP are enabled which will be used for a connection. The Shared Memory cannot gain access to an external machine so no need to talk about that.

If the server and the client are in a single broadcasting domain what will be used ? Named Pipes or TCP/IP. It is based on which order the protocols are configured. You can change the order by switching to the SQL Native Client 10.0 Configuration and Client Protocols.Named Pipes are typically faster than the TCP/IP.

And Finally by executing this query (in SQL Server Management Studio) you can view the currently used protocol. (After executing in your local machine you’ll get the Shared Memory as result)

SELECT net_transport FROM sys.dm_exec_connections WHERE session_id = @@SPID;

You can disable various protocols and try to the above query to get different results. (If you are enabling or disabling the protocols you should have to disconnect from the instance and restart the service to take effect)