Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand

Posts Tagged ‘windows azure’

Windows Azure – AppFabric Access Control Service – Introduction

Posted by JP on December 21, 2011

In this article we can explore the Access Control service of Windows Azure AppFabric. As you know the services provided by AppFabric are shown below.

clip_image002

Theory on Access Control

The Access Control Service (ACS) provides a flexible way of authentication and authorization in the cloud premises. The ACS extracts out the authentication and authorization code outside the application.

We can use ACS along with:

  • Web Applications
  • Web Services

Simply, the Access Control Service 2.0 allows us to integrate single sign on (SSO) and centralized authorization into the web applications.

In the old applications we need to incorporate the authentication and authorization code inside our applications. This will lead to mixing of business logic with the security overheads. The PrincipalPermission attribute, Cookie Presence Checking etc. are some of the ways of doing it. AppFabric through ACS provides a better way of dealing with security aspects.

Protocols: The following protocols are supported by ACS 2.0

  • WS-Trust
  • WS-Federation
  • OAuth

Identity Providers: The identity providers supported by ACS include:

  • Windows Live ID
  • Facebook
  • Google
  • Yahoo
  • WS-Federation Identity Providers

Compatibility: ACS is compatible with web platforms including:

  • .Net
  • PHP
  • Java
  • Ruby
  • Python

Difference between Old Application and Azure Application Security Aspects

clip_image004

Service Namespace: Like the Service Bus, we need to create a service namespace for the Access Control Service too. The services in a particular namespace share the same DNS name. The Service Namespace acts as a top level partition around the end points.

There are different endpoints inside the namespace:

  • Security Token Service
  • Management Service
  • Management Portal
  • Service Metadata

The format of the end point will be:

https://<servicenamespace&gt;.accesscontrol.windows.net/mgmt

Managed Namespace: A managed namespace is partially managed by another service. The Service Bus and Cache services uses managed namespaces characterized by –sb and –cache respectively.

Relying Party: In the context of ACS, relying party is an application for which we are implementing federated authentication. The configuration includes a term Realm which acts as the URI. There is a Return Url which is invoked to provide the token when the invoker is valid.

Example of Realm are: http://contesso.com. Any request with Realm prefix with http://contesso.com will be gaining valid tokens. We can also include http://localhost/ as a valid realm.

We can also configure an Error url which will be invoked during any problems in the login process. Eg: http://www.yourdomain/error.htm

The configuration of relying party application can be manual or through program. The relying party control flow is depicted below.

clip_image006

Rule Groups: A relying party application should be associated with at least one rule group. If the Real match one configured application which is not associated with any of the rule groups, the token will not be issued.

We can associate one rule group with more than one application and one application with more than one rule group.

Summary

In this article we have learnt about the AppFabric Access Control Service. It provides a better way of authentication and authorization. In the next article we can see how to create a service namespace and using the Access Control Service Portal.

Advertisements

Posted in Azure | Tagged: , , , | Leave a Comment »

Windows Azure – WCF in Worker Role

Posted by JP on November 29, 2011

In this article I am going to demonstrate the creation of WCF service in Worker Role and deployment to the cloud.

The attributes of WCF service on Worker role are:

  • Self Hosted
  • More Flexibility Attained
  • More Configurations Needed

Following are the steps involved.

Step 1: Create the WCF Service

Create a new Windows Azure project in Visual Studio 2010 and name it as WCFInWorkerRole as shown below

clip_image002

In the appearing dialog add one Worker Role project as shown below.

clip_image004

Add reference to the System.ServiceModel assembly.

clip_image006

Add the following 2 files

  • Interface named IMessengerService
  • Class named MessengerService

Replace the contents of above files with the following:

// IMessengerContract.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Runtime.Serialization;

using System.ServiceModel;

using System.Text;

namespace WorkerRole1

{

[ServiceContract]

public interface IMessengerService

{

[OperationContract]

string SendMessage(string name);

}

}

// MessengerService.cs

using System;

using System.Collections.Generic;

using System.Linq;

using System.Runtime.Serialization;

using System.ServiceModel;

using System.Text;

namespace WorkerRole1

{

public class MessengerService : IMessengerService

{

public string SendMessage(string name)

{

return “Hello ” + name + “. How do you do?”;

}

}

}

Remove the app.config from the worker role project as we are going to do manual configuration of WCF service. Now the solution explorer looks like below:

clip_image008

In the case of web role, the context and port was automatically identified. But in the worker role, we need to update the properties manually. The host name will be different in the development and deployment servers.

Modify the ServiceDefinition.csdef file as below.

<?xml version=”1.0″ encoding=”utf-8″?>

<ServiceDefinition name=”WCFInWorkerRole” xmlns=”http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition”&gt;

<WorkerRole name=”WorkerRole1″ vmsize=”Small”>

<Imports>

<Import moduleName=”Diagnostics” />

</Imports>

<Endpoints>

<InputEndpoint name=”port” protocol=”tcp” port=”9001″ />

<InputEndpoint name=”mexport” protocol=”tcp” port=”8001″ />

</Endpoints>

</WorkerRole>

</ServiceDefinition>

The content defines the port and metadata port for our WCF service. Now we can modify the OnStart() method of the Worker role class as given below.

public override bool OnStart()

{

// Set the maximum number of concurrent connections

ServicePointManager.DefaultConnectionLimit = 12;

// Create the host

ServiceHost host = new ServiceHost(typeof(MessengerService));

// Read config parameters

string hostName = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[“port”].IPEndpoint.Address.ToString();

int port = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[“port”].IPEndpoint.Port;

int mexport = RoleEnvironment.CurrentRoleInstance.InstanceEndpoints[“mexport”].IPEndpoint.Port;

// Create Metadata

ServiceMetadataBehavior metadatabehavior = new ServiceMetadataBehavior();

host.Description.Behaviors.Add(metadatabehavior);

Binding mexBinding = MetadataExchangeBindings.CreateMexTcpBinding();

string mexendpointurl = string.Format(“net.tcp://{0}:{1}/MessengerServiceMetadata”, hostName, 8001);

host.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, mexendpointurl, new Uri(mexendpointurl));

// Create end point

string endpointurl = string.Format(“net.tcp://{0}:{1}/MessengerService”, hostName, 9001);

host.AddServiceEndpoint(typeof(IMessengerService), new NetTcpBinding(SecurityMode.None), endpointurl, new Uri(endpointurl));

// Open the host

host.Open();

// Trace output

Trace.WriteLine(“WCF Listening At: ” + endpointurl);

Trace.WriteLine(“WCF MetaData Listening At: ” + mexendpointurl);

return base.OnStart();

}

The code performs the following:

  • Create Service Host
  • Read the Port number
  • Add the Metadata behaviour
  • Add the endpoints
  • Opens the Host

Note: The attached source code contains the working application.

Step 2: Test the application

Now we can test the application by executing it. If successfully executed we can see the trace from the Output window.

clip_image010

You can see two addresses from the above screen:

  • The actual service end point
  • The metadata end point

We can also see the trace from the load development machine. The Windows Azure Compute Emulator can be used for this purpose.

clip_image012

On invoking the Show Computer Emulator UI we can see the following window.

clip_image014

The above window contains the same trace output with the end point urls. You may try adding reference to the metadata end point using the metadata url. We are going to deploy the service to cloud and test it.

Step 3: Deploy to the cloud

Now our application is working fine and we can deploy it to the online cloud. For this right click on the project and click Package menu item.

clip_image016

In the appearing dialog box, choose the default options and click the Package button.

clip_image018

Now sign in to the Windows Azure portal and click on the New Hosted Service button from the top ribbon.

clip_image020

In the appearing dialog box enter the details as shown below.

clip_image022

Choose the option “Deploy to production environment”

Locate the package and configuration files from your application bin folder.

(Eg: ..\WCFInWorkerRole\bin\Debug\app.publish)

Please note that the URL prefix should be a unique name. If the URL prefix entered is already in use you need to change it.

After that click the Ok button of the dialog box. (You have to scroll down to see the button)

If any warning box appears, click Yes button to continue. Wait for a few minutes and your deployment will be ready in a few minutes as shown below.

clip_image024

Select the Deployment 2 row and from the properties window you can get the url of the worker role. Now we just need the host name. In this case wcfinworkerrole.cloudap.net

clip_image026

Step 3: Create the Client

Now we are ready to create the client application and test the deployed online cloud WCF service.

Create a new console application into the existing Azure project and name it as TestClient.

Use the add service reference option of the console application and in the appearing dialog enter the constructed service url as shown below.

Constructed Url: net.tcp://wcfinworkerrole.cloudapp.net:8001/MessengerServiceMetadata

Please note that we added the following:

  • Protocol as net.tcp
  • Host Name from previous step
  • Port number as 8001
  • Metadata Context Name

clip_image028

Click the Go button and after seeing the MessengerService item populated, Click the Ok button to continue.

Modify the main method in the Program.cs as following:

static void Main(string[] args)

{

ServiceReference1.MessengerServiceClient client = new ServiceReference1.MessengerServiceClient();

string result = client.SendMessage(“Kent”);

Console.WriteLine(string.Format(“Invoking WCF Service Result: {0}”, result));

Console.ReadKey(false);

}

Modify the configuration file with the url of the Messenger Service. Please note that the messenger service url is having different port number and context.

<client>

<endpoint

address=”net.tcp://wcfinworkerrole.cloudapp.net:9001/MessengerService

binding=”netTcpBinding”

bindingConfiguration=”NetTcpBinding_IMessengerService”

contract=”ServiceReference1.IMessengerService”

name=”NetTcpBinding_IMessengerService” />

</client>

Now set the console application as the start project and execute the application.

You can see the following results.

clip_image030

You can see the result Hello Kent. How do you do? from the WCF service.

This concludes our article on WCF service deployment as worker role and the testing.

Multiple End Point

I would like to add a note on the 2 end points we created for the WCF service.

net.tcp://wcfinworkerrole.cloudapp.net:8001/MessengerServiceMetaData

net.tcp://wcfinworkerrole.cloudapp.net:9001/MessengerService

You can see that there are 2 differences in the above urls:

  • Port
  • Context

Note: WCF with HTTP Port 80 endpoint configuration done as explained here.

Summary

In this article, we have seen how to host a WCF service using the Worker Role and deploy it to the cloud. This service is self hosted and experiments the service creation, hosting, metadata end point adding, deploying and testing with the client. The source code is attached and the application name in the url has to be changed according to your application name.

Posted in Azure | Tagged: , , , | Leave a Comment »

Windows Azure – WCF in Web Role

Posted by JP on November 29, 2011

In this article I would like to demonstrate the creation and deployment of WCF service in a Web Role.

The attributes of WCF service on Web role are:

  • IIS Hosted
  • IIS features like pooling and caching availability
  • Less Configurations Needed

Following are the steps involved.

Step 1: Create the WCF Service

Create a new Windows Azure project in Visual Studio 2010 and name it as WCFInWebRole as shown below

clip_image002

In the appearing dialog add one Web Role project as shown below.

clip_image004

Add a new WCF Service into the project. Name it as MessengerService.

clip_image006

Now the Solution Explore will look like below with the newly added contracts and service files.

clip_image008

Modify the DoWork() method in the interface IMessengerService as given below.

string SendMessage(string name);

Modify the DoWork() method in the interface IMessengerService as given below.

public string SendMessage(string name)

{

return “Hello ” + name;

}

Step 2: Test the application

Make the MessengerService.svc file as the start page as shown below.

clip_image010

Press F5 to execute the application and you can see the service opened in the browser as shown below.

clip_image012

Now are have tested the application and it is ready to be deployed to the cloud.

Step 3: Deploy to the cloud

Right click on the Web Role project and click package menu item as shown below.

clip_image014

In the appearing dialog select the default option and click the Package button.

clip_image016

Now sign in to the Windows Azure portal and click on the New Hosted Service button from the top ribbon.

clip_image018

In the appearing dialog box enter the details as shown below.

clip_image020

Choose the option “Deploy to production environment”

Locate the package and configuration files from your application bin folder.

(Eg: ..\WCFInWebRole\bin\Debug\app.publish)

Please note that the URL prefix should be a unique name. If the URL prefix entered is already in use you need to change it.

After that click the Ok button of the dialog box. (You have to scroll down to see the button)

If any warning box appears, click Yes button to continue. Wait for a few minutes and your deployment will be ready in a few minutes as shown below.

clip_image022

Select the Deployment 1 row and from the properties window you can get the url of the web role.

clip_image024

Click on the url and your application will get opened in the browser. Add the suffix MessengerService.svc to get the messenger service.

clip_image026

Step 3: Create the Client

Now we are ready to create the client application and test the deployed online cloud WCF service.

Create a new console application into the existing Azure project and name it as TestClient.

Use the add service reference option of the console application and in the appearing dialog enter the service url as shown below.

clip_image028

Click Ok button to continue.

Modify the main method in the Program.cs as following:

static void Main(string[] args)

{

ServiceReference1.MessengerServiceClient client = new ServiceReference1.MessengerServiceClient();

string result = client.SendMessage(“Ian”);

Console.WriteLine(string.Format(“Invoking WCF Service Result: {0}”, result));

Console.ReadKey(false);

}

Now set the console application as the start project and execute the application.

You can see the following results.

clip_image030

You can see the result Hello Ian from the WCF service.

This concludes our article on WCF service deployment as web role and the testing.

Summary

In this article we have seen how to deploy a WCF service to cloud platform. The WCF service inside the Web role will be hosted in IIS. The source code is attached and the application name in the url has to be changed according to your application name.

Posted in C# | Tagged: , , , | Leave a Comment »

Windows Azure – WCF Hosting Methods

Posted by JP on November 29, 2011

In the previous article we have experimented the ways of WCF hosting in Windows Azure. In this article I would like to summarize the important points of WCF service exposing in Windows Azure.

There are multiple ways of hosting WCF service in Windows Azure.

WCF Hosting

Description

Web Role

Hosted inside IIS with pooling and caching facilities

Worker Role

Self Hosted with more control

AppFabric

Self Hosting, Relayed connectivity through Service Bus

Let us examine them closely.

clip_image002

Method 1: Web Role Hosting

In the Web Role hosting, the WCF service is hosted inside IIS. This will give the advantages of IIS to the WCF service.

  • Identity Management
  • Recycling
  • Caching
  • Pooling
  • Logging


The Service creation will be much easier in this method as Visual Studio provides the templates for Service (.svc files). We need to create a new .svc file and place it in the web role project. The host names and ports are configured by the deployment and we can access the service through a browser.

The metadata end points are also automatically added. This saves a lot of amount of work from the developer side.

Method 2: Worker Role Hosting

Here the developer has to perform more work in creating the service contracts by defining the attributes in the contracts and implementation.

This method is advised if more control is needed over the service. We can easily configure the protocols in this way. In this case a corporate port has to be opened to expose the service while using the worker role.

Method 3: Hosting through AppFabric

In this method the WCF service is exposed through the Service Bus service feature of Windows Azure AppFabric. We can choose this option if we need to connect two disconnected applications.

This method is self hosted and more configurations needed. Here we can connect two disconnected applications using the Service Bus namespace. The namespace identifies the subscription and will be used for billing purposes on the cloud.

The Service Bus provides the following features:

  • Connectivity between disconnected applications
  • Higher Availability

Relay Service

There are two modes of connectivity in the Relay Service.

· TcpRelayConnectionMode.Relayed

· TcpRelayConnectionMode.Hybrid

The default mode is Relayed and here the service and client is connected through the relayed service.

Relayed Mode Connectivity

The following picture depicts the process in the Relayed mode.

clip_image004
The steps involved are following:

Step 1: The WCF Service authenticates and registers with the Relayed Service using the namespace and Provider keys.

Step 2: The Client authenticates with the Relay Service

Step 3: Client invokes a method using the Relay Service

Step 4: The Relay Service redirects the call to the registered WCF service.

Hybrid Mode Connectivity

In the Hybrid way of connectivity the client can communicate directly to the service. First the client connectivity starts as Relayed as usual and then if there is possibility of connecting directly to the service it will be provided.

Summary

In this article we have discussed the various WCF exposing methods in Windows Azure like web role, worker role and through AppFabric Service Bus.

Posted in Azure | Tagged: , , , | Leave a Comment »

Windows Azure – AppFabric Service – Server Creation

Posted by JP on November 15, 2011

This article is a continuation of the previous two.

  1. AppFabric Introduction
  2. Service Bus Application

Service Bus Theory

Service Bus is one of the AppFabric services in the cloud platform.

Service Bus provides the facility for disconnected applications to communicate with each other. In this article we are focusing on creating a WCF service which uses the Service Bus facilities. Later we will use a client to communicate to the same service through the Service Bus.

In this article we are focusing on the activity: Creating WCF Service using Service Bus. The steps involved are following.

Step 1: Create new console application

The console application is fine for our purpose. Create a new console application.

clip_image002[4]

Now change the project property Target Framework to .Net Framework 4 as shown below. This is needed because the Microsoft.ServiceBus assembly has dependency on the above framework assembly.

clip_image004[4]

Step 2: Add reference to System.ServiceModel assembly

For the WCF contracts, we need to add reference to the System.ServiceModel assembly as shown below.

clip_image006[4]

Step 3: Add reference to Service Bus assemblies

Now add reference to the following assemblies.

  • Microsoft.ServiceBus
  • RelayConfigurationInstaller

The above files can be located in your AppFabric SDK installation folder. In my computer it was located in the following folder.

C:\Program Files\Windows Azure AppFabric SDK\V1.5\Assemblies\NET4.0

clip_image008[4]

Step 4: Create WCF Service Contract and Implementation

Create a new interface named IGreetingContract add the new method as shown below.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.ServiceModel;

namespace AppFabricWCFService

{

[ServiceContract(Name=”IGreetingContract”, Namespace=”http://tempuri.org/&#8221;)]

public interface IGreetingContract

{

[OperationContract]

string GetMessage(string name);

}

}

Create a new class named GreetingService and implement the above method as shown below.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.ServiceModel;

namespace AppFabricWCFService

{

[ServiceBehavior(Name = “IGreetingContract”, Namespace = “http://tempuri.org&#8221;)]

public class GreetingService : IGreetingContract

{

public string GetMessage(string name)

{

return “Hello, ” + name;

}

}

}

Step 5: Get the Service Bus Properties

Now we can expose the service using the Service Bus properties. For this we need the following:

  • Service Bus Namespace
  • Issuer Name
  • Issuer Secret

The Service Bus Namespace was already created in the previous article. You can refere it here.

The Issuer Name and Issuer Secret can be located following the steps.

Sign in to the Windows Azure portal and select the following item.

clip_image010[4]

In the appearing dialog select the Service Bus and click on the View button for the Default Key property from the right side.

clip_image012[4]

On clicking the View button the following dialog box appears.

clip_image014[4]

The above window provides the Issuer Name and Issuer Secret. Copy the values for use in the next step.

Step 6: Host the WCF service using Service Bus

Now we are ready to host the WCF service. In the Program.cs modify the main method as shown below. Replace the highlighted areas with your corresponding service bus properties.

static void Main(string[] args)

{

string servicePath = “GreetingService”;

string serviceNamespace = “YourNameSpaceHere”;

string issuerName = “YourIssuerNameHere”;

string issuerSecret = “YourIssuerSecretHere”;

Uri uri = ServiceBusEnvironment.CreateServiceUri(“sb”, serviceNamespace, servicePath);

TransportClientEndpointBehavior sharedSecretServiceBusCredential = new TransportClientEndpointBehavior();

sharedSecretServiceBusCredential.CredentialType = TransportClientCredentialType.SharedSecret;

sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerName = issuerName;

sharedSecretServiceBusCredential.Credentials.SharedSecret.IssuerSecret = issuerSecret;

ServiceHost host = new ServiceHost(typeof(GreetingService), uri);

ContractDescription contractDescription = ContractDescription.GetContract(typeof(IGreetingContract), typeof(GreetingService));

ServiceEndpoint serviceEndPoint = new ServiceEndpoint(contractDescription);

serviceEndPoint.Address = new EndpointAddress(uri);

serviceEndPoint.Binding = new NetTcpRelayBinding();

serviceEndPoint.Behaviors.Add(sharedSecretServiceBusCredential);

host.Description.Endpoints.Add(serviceEndPoint);

host.Open();

Console.WriteLine(“Service Ready At: ” + serviceEndPoint.Address);

Console.ReadKey(false);

host.Close();

}

You can see that we are using the Relay version of NetTcp binding.

Note: The above code does not depend on the configuration file for end points and behaviours as it is for learning purposes. In the real life scenario the configuration file should be used for the same.

Step 7: Execute the application

Now press F5 and execute the application. You should be able to see the console window showing the service ready message.

clip_image016[4]

Please note the url starting with sb which is the default prefix for Service Bus.

Summary

In this article we have created a WCF service and hosted using the AppFabric Service Bus feature. In the upcoming article we can see how to create a client to use the service. The attached source code contains the service code which you can use it after modifying using your service bus properties.

Posted in C# | Tagged: , , | Leave a Comment »

Windows Azure – WCF Hosting Methods

Posted by JP on November 14, 2011

In the previous article we have experimented the ways of WCF hosting in Windows Azure. In this article I would like to summarize the important points of WCF service exposing in Windows Azure.

There are multiple ways of hosting WCF service in Windows Azure.

WCF Hosting

Description

Web Role

Hosted inside IIS with pooling and caching facilities

Worker Role

Self Hosted with more control

AppFabric

Self Hosting, Relayed connectivity through Service Bus

Let us examine them closely.

clip_image002

Method 1: Web Role Hosting

In the Web Role hosting, the WCF service is hosted inside IIS. This will give the advantages of IIS to the WCF service.

  • Identity Management
  • Recycling
  • Caching
  • Pooling
  • Logging


The Service creation will be much easier in this method as Visual Studio provides the templates for Service (.svc files). We need to create a new .svc file and place it in the web role project. The host names and ports are configured by the deployment and we can access the service through a browser.

The metadata end points are also automatically added. This saves a lot of amount of work from the developer side.

Method 2: Worker Role Hosting

Here the developer has to perform more work in creating the service contracts by defining the attributes in the contracts and implementation.

This method is advised if more control is needed over the service. We can easily configure the protocols in this way. In this case a corporate port has to be opened to expose the service while using the worker role.

Method 3: Hosting through AppFabric

In this method the WCF service is exposed through the Service Bus service feature of Windows Azure AppFabric. We can choose this option if we need to connect two disconnected applications.

This method is self hosted and more configurations needed. Here we can connect two disconnected applications using the Service Bus namespace. The namespace identifies the subscription and will be used for billing purposes on the cloud.

The Service Bus provides the following features:

  • Connectivity between disconnected applications
  • Higher Availability

Relay Service

There are two modes of connectivity in the Relay Service.

· TcpRelayConnectionMode.Relayed

· TcpRelayConnectionMode.Hybrid

The default mode is Relayed and here the service and client is connected through the relayed service.

Relayed Mode Connectivity

The following picture depicts the process in the Relayed mode.

clip_image004
The steps involved are following:

Step 1: The WCF Service authenticates and registers with the Relayed Service using the namespace and Provider keys.

Step 2: The Client authenticates with the Relay Service

Step 3: Client invokes a method using the Relay Service

Step 4: The Relay Service redirects the call to the registered WCF service.

Hybrid Mode Connectivity

In the Hybrid way of connectivity the client can communicate directly to the service. First the client connectivity starts as Relayed as usual and then if there is possibility of connecting directly to the service it will be provided.

Summary

In this article we have discussed the various WCF exposing methods in Windows Azure like web role, worker role and through AppFabric Service Bus.

Posted in C# | Tagged: , , | Leave a Comment »

Windows Azure – Summary of Storages

Posted by JP on November 13, 2011

In this article I would like to summarize the storage methods we learnt in Windows Azure. The advanced features are also discussed here.

Types of Storage

Recollecting that we have 3 types of storage in Windows Azure:

  • Local Storage
  • Windows Azure Storage
  • SQL Azure Storage

clip_image002

Below are some of the advanced storage features.


Local Storage Features

This is a temporary storage and the application cannot see the underlying disk or drive on which the storage is done. But the application can request up to 1 GB of data on the local storage.

The local storage space is not accessible outside or to any other instances. Windows Azure on the runtime chooses the best drive to store the data.

Windows Storage Features

The Windows Azure operating system allows 4 kinds of storage which are Blob, Table, Queue and Disk storage.

These storage accounts are publicly exposed so we can access they from virtually anywhere. The storage account data is exposed using HPTTP, REST and OData protocols.

The Blob storage provides huge amount of data manipulation. The table storage provides structured data processing as entities and Queue storage is efficient in back end and front end communication.

In Windows Azure Storage there is one more type called Drive storage. Windows Azure Drive allows us to upload Virtual Hard Drives as Blob. This provides great flexibility to developers. More information can be found here.

Automatic Replication is a feature that makes sure the data stored is replicated 3 times. This is taken care by the Content Delivery Network (CDN) and improves the performance.

Geo-replication is a new feature that provides replication for Blob and Table data at no additional cost. This provides the reliability during a crisis situation.

Queue Insert Message Timeout is a new feature that makes the queue message invisible until the specified time expires.

Table Query Projection is a new feature that allows partial reading of entity’s properties. This will improve the performance.

REST and Managed APIs support working with storage services. We need to download the REST API SDK to achieve this.

Pricing of Windows Azure Storage is performed based on the average usage of blob, table, queue and drive storage.

The updated information can be found here.

SQL Azure Storage Features

SQL Azure represents Cloud version of SQL Server. It is a highly available and scalable database on the cloud premises.

SQL Azure provides ease of use and maintenance. No need of installation and applying patches as these activities will be taken care by the provider.

ADO.NET, ODBC and JDBC providers are supported on SQL Azure.

The design time structure and data management can be done through:

  1. Windows Azure Portal
  2. SQL Azure Management Portal
  3. MMC Tool
  4. SQL Server Management Studio

The SQL Azure provides automatic replication of data and automatic switching of the server in case of failures.

Some of the current drawback of SQL Azure is:

  • Not all data types in SQL Server are supported
  • SSAS (SQL Server Analysis Services) not supported
  • Service Broker feature not supported

The editions in SQL Azure are the following:

  • Web Edition
  • Business Edition

The web edition can support 1 GB or 5 GB in size and good for small Web applications. The business edition can support up to 50 GB of data and good for independent software vendors and enterprise applications.

The layers in SQL Azure would be the following.

  • Client Layer
  • Services Layer
  • Platform Layer
  • Infrastructure Layer

clip_image004

The Client layer is hosted in windows azure and communicates with our application. The Service layer acts as a gateway between the client layer and the platform layer. The Platform layer includes the physical servers which supports the service layer. The Infrastructure layer consists of the IT administration of the physical hardware and operating systems that supports the service layer. More information can be found here.

Summary

In this article we have summarized the types of storages in Windows Azure and the advanced features provided by them.

Posted in C# | Tagged: , , , , | Leave a Comment »

Windows Azure – SQL Azure – Using ADO.NET Entity Framework – Data Operations

Posted by JP on November 13, 2011

In this article we are going to explore data operations using ADO.NET Entity Framework over our SQL Azure database. The data model creation which is an essential part required was discussed in the previous article.

Pre-Requisites

For working on this application, you need to have the following pre-requisites.

  • Azure project with web role
  • Entity data model with Employee class

You may use the project from the previous article.

After having the above, place the following on the Default.aspx page

  • 4 buttons with labels Insert, Update, Delete, Refresh
  • A grid control

clip_image002

Insert Operation

For creating a new employee, use the following code in the Insert button click event.

mysqlazureEntities context = new mysqlazureEntities();

Employee employe = new Employee();

employe.Name = “New Employee from EF”;

context.AddToEmployees(employe);

context.SaveChanges();

Update Operation

For creating a new employee, use the following code in the Update button click event.

mysqlazureEntities context = new mysqlazureEntities();

Employee employee = context.Employees.Where(emp => emp.Name == “New Employee from EF”).FirstOrDefault();

if (employee != null)

employee.Name = “Updated Name”;

context.SaveChanges();

Delete Operation

For creating a new employee, use the following code in the Delete button click event.

mysqlazureEntities context = new mysqlazureEntities();

Employee employee = context.Employees.Where(emp => (emp.Name == “New Employee from EF” || emp.Name==”Updated Name”)).FirstOrDefault();

if (employee != null)

context.DeleteObject(employee);

context.SaveChanges();

Select Operation

For creating a new employee, use the following code in the Refresh button click event.

GridView grid = GridView1;

grid.Columns.Clear();

grid.Columns.Add(new BoundField() { HeaderText = “Id”, DataField = “Id” });

grid.Columns.Add(new BoundField() { HeaderText = “Name”, DataField = “Name” });

mysqlazureEntities context = new mysqlazureEntities();

grid.DataSource = context.Employees.ToList();

grid.DataBind();

On executing the application and playing with the buttons you can view the following results.

clip_image004

Summary

In this article we have explored the data operations using ADO.NET Entity Framework over our SQL Azure database. You need to change the database name, user name and password in the configuration file.

Posted in C# | Tagged: , , , , | Leave a Comment »

Windows Azure – SQL Azure – Using ADO.NET Entity Framework – Creating DataModel

Posted by JP on November 13, 2011

Another good remarkable point regarding SQL Azure is the reuse of our existing skills with ADO.NET Entity Framework. As the SQL Azure connectivity using ADO.NET is possible, it opens the door for Entity Framework as well.

Abut ADO.NET Entity Framework

ADO.NET Entity Framework is an ORM (Object Relational Mapping) framework from Microsoft. It provides the flexibilities like tables to entities, relational mapping to properties, Data operations to encapsulated methods etc.

clip_image002

Surely it gives the advantages of:

  • Wrapping of database in Object Oriented Manner
  • More Manageability
  • More Flexibility
  • Less Development Time

But everything comes at the cost of learning. You can find more information here.

Creating Schema

Create a new Windows Azure project and add a new web role into it. After that right click on the project and use Add > New Item. In the appearing dialog choose the Data item from the left pane and ADO.NET Entity Data Model from the right pane.

clip_image004

Enter the names as MyModel as shown above. Click the Add button to continue to see the following screen.

clip_image006

In the above dialog choose the default option (Generate from database) and click the Next button to continue.

clip_image008

In the appearing dialog choose your existing connection from the drop down list and click Next to continue..

clip_image010

You will be prompted with the login dialog above. Enter your user name and password to continue. (The Save my password option saves the password to the connection string in config)

In the next dialog, select the tables as shown below and click Finish button.

clip_image012

This will generate the entity data model files in your project. You can see that the Employee table from previous example is populated in the tables and it generates the Employee class as shown below.

clip_image014

Note: If your database does not contain the above table, you may need to create the table and repeat the operations.

Summary

In this article we have explored the scope of using ADO.NET Entity Framework on SQL Azure. The possibilities give us more flexibility, control and reuse of our existing ORM skills. The source code attached contains the Entity Data Model code. You need to change the database name, user name and password in the configuration file.

Posted in C# | Tagged: , , , , | Leave a Comment »

Windows Azure – SQL Azure Management Portal – Create Database and Table

Posted by JP on November 13, 2011

In the previous article we have seen how to connect and create database using the SQL Server Management Portal application. In this article we can explore how to create create table, views, run sql queries on it etc.

Login to SQL Azure Management Portal

We need to sign in to the SQL Azure Management Portal before continuing with the topics. Use the database url for signing in. (eg: https://server.database.windows.net)

Creating Table

Now we can explore how to create a table using the management portal. After selecting the database, click on the New Table button to get the table creation screen.

clip_image002

Within a few seconds you will get the following screen for table creation. Enter the table details. I have named the table as Car and entered 3 columns.

clip_image004

Click on the Save button to save the table.

clip_image006

The left side tree view provides access to all tables, views and stored procedures in the current database.

clip_image008

For accessing the table, click on the Tables item as shown above.

clip_image010

Click on the Data button from the Car table row to view the data inside it.

clip_image012

We can use the Add Row button to create new rows in the table. After entering the records, use the Save button to commit the changes.

clip_image014

Note: Without using the Save button the records will not be saved in the database. This is an important point in dealing with data.

Creating Views, Stored Procedures

Similar to the way of table creation, we can create Views and Stored Procedures using the ribbon toolbar buttons.

For creating views, use the New View button.

clip_image016

For creating stored procedures, use the New Stored Procedure button.

clip_image018

Query Execution

You can write and execute SQL query on the database using the New Query button from the ribbon toolbar.

clip_image020

On clicking the button, the following query window appears.

clip_image022

Enter the query “SELECT * FROM Car” and click the execute button. You will see the results as shown below. (If you cannot see the results, make sure you clicked the Save button in the record creation screen)

clip_image024

Summary

In this article we have explored table creation, running sql query on the SQL Azure Management Studio web application.

Posted in C# | Tagged: , , , , | Leave a Comment »