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 ‘cloud’

Local Storage Example

Posted by JP on November 6, 2011

In this article, we are trying to experiment the local storage feature of Windows Azure. From the previous article we found that local storage is one of the primitive storage mechanisms in Windows Azure.

The core features of Local Storage are:

  • Temporary Storage
  • Feature provided by the Operating System
  • Similar to Hard Drive
  • Exposed as logical file system
  • .Net Directory/File IO Framework used to access it
  • Can be used for storing Cache items

Creating a Local Storage

Here we are creating a local resource through the step by step activities.

Step1: Create new Web Role project

You will be familiar with web role creation and you can repeat the same. After the solution is created, the Solution Explorer will be looking like below:

clip_image002

Step 2: Open the local storage pane

Now double click on the WebRole1 item shown above to open the project configuration, Form there click the Local Storage pane item.

clip_image004

Step 3: Add a new Local Storage item

Add a new local storage items by clicking the Add Local Storage button. Rename it to TestStorage Change the Size to 10 MB as shown in the figure and save the configuration.

clip_image006

The above change will modify the configuration file of the application.

Step 4: Show Information about the Local Resource

Now we can place a label on the page, rename it to InfoLabel. Then on the page load event we can access the local resource and show the properties it has.

clip_image008

The RootPath property gives the current path of the resource in machine.

The MaximumSizeInMegabytes property returns the size allocated to it.

On executing the application we can see the following output.

clip_image010

Step 5: Start using the folder

Now we can use the above folder for our storage purpose. We can create folder, files inside it.

Create a new button on the page and name it as CreateFolderAndFileButton. On click of the button place the code to create a directory and file.

protected void CreateFolderAndFileButton_Click(object sender, EventArgs e)

{

LocalResource resource = RoleEnvironment.GetLocalResource(“TestStorage”);

Directory.CreateDirectory(resource.RootPath + “\\NewFolder”);

File.Create(resource.RootPath + “\\NewFile.txt”);

ShowContents(resource.RootPath);

}

private void ShowContents(string path)

{

InfoLabel.Text = “Directories inside it: <br>”;

foreach (string dir in Directory.GetDirectories(path))

{

InfoLabel.Text += dir + “<br>”;

}

InfoLabel.Text += “<br>Files inside it”;

foreach (string file in Directory.GetFiles(path))

{

InfoLabel.Text += file + “<br>”;

}

}

Execute the application and on clicking the button we can see the following output.

clip_image012

Summary

In this article we have found how to use the local storage feature of Windows Azure and creating folder and file inside it.

Advertisements

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

Windows Azure – WCF Hosting Methods

Posted by JP on October 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 »

Worker Role Detailed

Posted by JP on October 14, 2011

In this article we can summarize the points on Worker role deployed in previous article.

Virtual Machine Size

The virtual machine size provides the resource capacity of the virtual machine. The parameters varying with virtual machine size are:

  • CPU Speed
  • Memory (RAM)
  • Instance Storage (Hard Disk)
  • I/O Performance

The sizes for virtual machine are:

  • Extra Small
  • Small
  • Medium
  • Large
  • Extra Large

The cost of billing will be varying depending on the virtual machine size.

The ServiceDefinition.csdef file can be used to specify the VM size.

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

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

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

<Imports>

<Import moduleName=”Diagnostics” />

</Imports>

</WorkerRole>

</ServiceDefinition>

Instance Count

The number of instances of the Worker role can be specified using the instance count option. The number of instances will be managed by a Load Balancer automatically by the cloud.

The ServiceConfiguration.cscfg file can be used to specify the instance count.

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

<ServiceConfiguration serviceName=”WorkerRoleExample” xmlns=”http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration&#8221; osFamily=”1″ osVersion=”*”>

<Role name=”WorkerRole1″>

<Instances count=”1″ />

<ConfigurationSettings>

<Setting name=”Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString” value=”UseDevelopmentStorage=true” />

</ConfigurationSettings>

</Role>

</ServiceConfiguration>

Locating the files

From the solution explorer we can locate the files as shown below:

clip_image002

Deleting the Worker Role

As mentioned in the previous article, any computing hours excess of the trial limit will be charged. So we need to ensure that the instances are stopped and deleted. The steps are depicted below:

Step 1: Stopping an Instance

Sign in to the Windows Azure Portal, click the Hosted Services link to vie the hosted services and click Stop from the toolbar.

The order of clicking is depicted as sequence.

clip_image004

Step 2: Deleting an Instance

Once the instance is stopped, click on the Delete button to delete the instance. (This is for demonstration and one may keep the instance if it is needed in future)

clip_image006

On clicking the Delete button you will be prompted with a confirmation dialog.

clip_image008

Click on the Yes button for proceeding with the Delete operation. Now you can see the status being changed to Deleting…

clip_image010

After the operation is completed, the above entries are removed from the list. So it confirms the Delete operation.

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

Deploying the Worker Role

Posted by JP on October 14, 2011

After developing the Worker Role, we have to package it and deploy to the cloud. The entire steps in this are:

  • Create Worker Role
  • Create Package
  • Deploy to Cloud

Creating the Worker Role is performed in the previous article. Now we need to do the following steps.

Create Package

For creating the package, right click on the project context menu and click Package.

clip_image002

Now as dialog box will be appearing, leave the default options selected and click the Package button on the dialog.

clip_image004

After performing the packaging, the folder containing package is opened in a new explorer window automatically.

clip_image006

There are two files in the folder as shown above:

  • Configuration File
  • Service Package File

The Configuration file contains the instance count, application setting entries etc.

Deploy to Cloud

The deploying part contains deploying the package file and the configuration file. For deploying the files, we need to sign in to the Windows Azure Portal.

After signing in, click on the New Hosted Service button from the left top panel. The following dialog box appears.

clip_image008

Detailing Input Fields in Dialog Box

The subscription list automatically selects the default subscription (trial).

In the service name text box, enter a name for the service.

In the service URL prefix text box, enter a unique prefix name.

In the region, select an appropriate region of deployment.

Enter an appropriate deployment name in the final text box.

Select Package

Now, we need to specify the Package location and Configuration file. Use the Browse locally… button for these and select the files from your local machine.

After specifying all the inputs, click the Ok button. (In case of instance warning box, click Yes to override it for time being)

Now you can see that the entry is shown as preparing to upload in the list.

clip_image010

Waiting for Upload Operation

We need to wait a few minutes for the upload operation to be completed. After the upload operation is completed the instance will be started.

After all the operations are completed the status will turn to ready as show in the image below:

clip_image012

Getting the Deployed Url

The DNS name specifies the url to access the worker role as shown below:

clip_image014

For viewing the deployed Worker Role traces we need to change the trace configuration. This will be explained in further articles.

Warning

As the worker role we uploaded is having infinite loop, it will be quoting computing resources and any usage beyond monthly free limit will be charged to the credit card. So it is recommend you to delete the deployed worker role after the test.

Deletion is explained in the next tutorial.

Summary

In this article we have seen how to package and deploy a Worker Role to windows azure hosting.

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

Creating a Worker Role

Posted by JP on October 14, 2011

In this article we are creating a worker role using Visual Studio 2010. This will make the reader familiar with Windows Azure.

Open Visual Studio 2010 and use the command New Project. From the appearing dialog box select the Windows Azure Project option from Visual C# group.

clip_image002

Enter an appropriate name for the project and click Ok to continue. Now you will be prompted with another dialog for selecting the type of project.

Double click on the Worker role option to select a worker role project and click Ok button.

clip_image004

Now you are ready with the Worker role project.

Purpose of Worker Role

The Worker role can be used to host WCF services, provide endpoints, perform operations etc.

The default Run() method implementation contains an infinite loop as shown below:

public override void Run()

{

// This is a sample worker implementation. Replace with your logic.

Trace.WriteLine(“WorkerRole1 entry point called”, “Information”);

while (true)

{

Thread.Sleep(10000);

Trace.WriteLine(“Working”, “Information”);

}

}

Now execute the application and you will be able to see the application inside the browser. From the system tray, you can verify the Windows Azure Emulator as running.

If successfully executed, you can see the trace output messages as shown below.

clip_image006

Exceptional Cases

The exceptional cases are already addressed in the previous Web Role Example article.

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

Web Role Detailed

Posted by JP on October 14, 2011

In this article we can summarize the points on Web Role deployed in previous article.

Virtual Machine Size

The virtual machine size provides the resource capacity of the virtual machine. The parameters varying with virtual machine size are:

  • CPU Speed
  • Memory (RAM)
  • Instance Storage (Hard Disk)
  • I/O Performance

The sizes for virtual machine are:

  • Extra Small
  • Small
  • Medium
  • Large
  • Extra Large

The cost of billing will be varying depending on the virtual machine size.

The ServiceDefinition.csdef file can be used to specify the VM size.

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

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

<WebRole name=”WebRole1 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>

Instance Count

The number of instances of the Web Role can be specified using the instance count option. The number of instances will be managed by a Load Balancer automatically by the cloud.

The ServiceConfiguration.cscfg file can be used to specify the instance count.

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

<ServiceConfiguration serviceName=”WebRoleExample” xmlns=”http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration&#8221; osFamily=”1″ osVersion=”*”>

<Role name=”WebRole1″>

<Instances count=”1″ />

<ConfigurationSettings>

<Setting name=”Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString” value=”UseDevelopmentStorage=true” />

</ConfigurationSettings>

</Role>

</ServiceConfiguration>

Locating the files

From the solution explorer we can locate the files as shown below:

clip_image002

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

Deploying the Web Role

Posted by JP on October 14, 2011

After developing the web role, we have to package it and deploy to the cloud. The entire steps in this are:

  • Create Web Role
  • Create Package
  • Deploy to Cloud

Creating the web role is performed in the previous article. Now we need to do the following steps.

Create Package

For creating the package, right click on the project context menu and click Package.

clip_image002

Now as dialog box will be appearing, leave the default options selected and click the Package button on the dialog.

clip_image004

After performing the packaging, the folder containing package is opened in a new explorer window automatically.

clip_image006

There are two files in the folder as shown above:

  • Configuration File
  • Service Package File

The Configuration file contains the instance count, application setting entries etc.

Deploy to Cloud

The deploying part contains deploying the package file and the configuration file. For deploying the files, we need to sign in to the Windows Azure Portal.

After signing in, click on the New Hosted Service button from the left top panel. The following dialog box appears.

clip_image008

Detailing Input Fields in Dialog Box

The subscription list automatically selects the default subscription (trial).

In the service name text box, enter a name for the service.

In the service URL prefix text box, enter a unique prefix name.

In the region, select an appropriate region of deployment.

Enter an appropriate deployment name in the final text box.

Select Package

Now, we need to specify the Package location and Configuration file. Use the Browse locally… button for these and select the files from your local machine.

After specifying all the inputs, click the Ok button. (In case of instance warning box, click Yes to override it for time being)

Now you can see that the entry is shown as preparing to upload in the list.

clip_image010

Waiting for Upload Operation

We need to wait a few minutes for the upload operation to be completed. After the upload operation is completed the instance will be started.

After all the operations are completed the status will turn to ready as show in the image below:

clip_image012

Getting the Deployed Url

For viewing the deployed web role we need to get the url. For this select the Deployment 1 row from the list above.

clip_image014

From the property pane on the right we can see the DNS name.

Viewing the Deployed Web Role

Clicking on the DNS name link from the properties the web role will get opened in the browser as shown below (please note the staging url)

clip_image016

Summary

In this article we have seen how to package and deploy a web role to windows azure hosting.

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

Creating a Web Role

Posted by JP on October 14, 2011

In this article we are creating a web role using Visual Studio 2010. This will make the reader familiar with Windows Azure.

Open Visual Studio 2010 and use the command New Project. From the appearing dialog box select the Windows Azure Project option from Visual C# group.

clip_image002

Enter an appropriate name for the project and click Ok to continue. Now you will be prompted with another dialog for selecting the type of project.

Double click on the ASP.NET Web Role option to select a web role project and click Ok button.

clip_image004

Now you are ready with the Web Role project. Now execute the application and you will be able to see the application inside the browser. From the system tray, you can verify the Windows Azure Emulator as running.

If successfully executed, you can see the web role opened in a browser like below:

clip_image006


Exceptional Case 1

In case the emulator raised an error like below dialog, you have to restart Visual Studio in the Computer Administrator context.

clip_image008

Exceptional Case 2

In case you are struck with issue of Compute Emulator Shutdown issue, you can resolve it with the link

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

Registering Online

Posted by JP on October 14, 2011

For beginners to experiment with Azure,

Step 1: Create new Account

For creating a new account, you can use the url: http://www.microsoft.com/windowsazure/

clip_image002

Click on the “Try it free now!” button and you will be prompted with the following screen:

clip_image004

Proceed with clicking the “Get the free trial” button and now you will be prompted with the windows live id authentication. You can use an msn/hotmail id to login. If you do not have a live id, then create one and login.

clip_image006

After logging in, you will be prompted with the following screen:

clip_image008

Enter the details and click the Next button to see the following screen:

clip_image010

Click next to continue..


Step 2: Provide Credit Card Details

After clicking next, you will be prompted to provide the Credit Card details. Please not that the charges will be held on credit card if:

  • Any usage after 90 days of trial period
  • The usage exceeded the computation limits within the trial period

One can use Greybox (http://www.greybox.codeplex.com/) to monitor the consumption in the specified account. This will ensure that no unattended usage causes billing problems later.

After providing the details click the Submit button and the creation process is completed.

Step 3: Verify Account

Now login to the Window Azure Portal using the link below:

http://www.microsoft.com/windowsazure/

clip_image012

Click on the Sign in to the Management Portal and provide your credentials. You will be getting the following verification screen.

clip_image014

Step 4: Management Portal

After successful registration, you will be able to see the following portal screen:

clip_image016

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

Setting up Visual Studio

Posted by JP on October 14, 2011

After creating account, we can proceed with setting up the development environment.

Windows Azure applications can be developed in multiple environments.

  • Visual Studio 2008, 2010
  • Standalone SDK

In this article, we are focusing on setting up SDK for Visual Studio.

Open the url: http://www.microsoft.com/windowsazure/sdk/ and click on the Get Tools & SDK button.

clip_image002

On clicking the button an executable named WindowsAzureToolsVS2010.exe will be downloaded. Run the executable and it will be installing the needed tools for Visual Studio.

The installer above will be installing all the required features including Azure Tools, SDK, ASP.NET MVC, IIS settings, hotfixes etc.

After the installation, you can start the Visual Studio and from the New Project dialog box you can view the Azure Project item.

clip_image004

SDK Tool Runtime Components

Following are some of the important components of runtime.

Windows Azure Compute Emulator This is the tool that enables local Azure environment for developing and testing applications.

Windows Azure Storage Emulator This is the tool that enable storage (Blob, Queue, Table) services in the local machine.

SDK Support for Other Languages

There is SDK support for other languages like:

  • Java
  • PHP
  • Ruby

Know Issues

You can read the known issues associated with the latest SDK 1.5 release.

http://msdn.microsoft.com/en-us/library/hh472165.aspx

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