Article
    C#
    ADO.Net
    .NET
    ASP.Net & Web Forms
    Custom Controls
    Web Development
    Exception Handling
    XML
    Database
    Security in .Net
    Testing
    Web Services
    Windows Services
    Windows Controls
    WCF
    AJAX
    WPF
    XAML
    Reporting
    Setup
    VB.Net
    LINQ
    JQuery
    SilverLight
    JavaScript
    HTML5
    Crystal Report
    Cloud Computing
    Share Point
    Visual C++
    MVC
    Android
    PHP
    Java
    HTML
    WordPress
    Joomla
    Products
    Drupal
    Windows Phone
    JSON
    LightSwitch
    iPhone/iPad
    Ruby on Rails
    IIS 7
    Windows 8
    CSS/CSS3
    Excel
    MS Access
    Shortcut Keys
    Visual SourceSafe
    Team Foundation Server
    APIs
Follow Us
Follow _MindStick_ on Twitter View MindStick Software's LinkedIn profile View MindStick Software's Facebook profile
Top Contributor
Advertisement
Advertise with Us
Mindstick
Article Article  Forum Forum  Blog Blog  Quiz Quiz  Beginner Beginner  Careers Careers  Contact Contact  Login Login  
Home | Product | Services | About Us | Interview | DeveloperSection | Submit an Article | Submit Blog

Home >> Cloud Computing >> Install and Create a Windows Azure Application in VS 2010
Install and Create a Windows Azure Application in VS 2010
Install and Create a Windows Azure Application in VS 2010


by Rohit Kesharwani on 1/23/2012 2:13:19 PM

Views: 853       Comments: 0

Install and Create a Windows Azure Application in VS 2010

To install the Windows Azure Tools, on the menu bar, choose File – New – Project. From Installed Templates choose either the Visual Basic or Visual C# node, and then choose the Cloud node that contains a project template named Enable Windows Azure Tools.

To download the tools, choose the OK button.
After the successful installation A Windows Azure Project tab is displays instead of Enable Windows Azure Tools.

A windows azure application consists of roles that perform the actions required by the application. When you publish your application to Windows Azure, each role is run on a virtual machine in the cloud.

Create a Windows Azure Application:

·         Start Visual Studio 2010 as an administrator.

·         To create a Windows Azure project, on the menu bar, choose FileNewProject.

·         Choose the Cloud template from the Installed template.

·         Choose Windows Azure project and enter the name of the project.

·         Click OK.

Install and Create a Windows Azure Application in VS 2010

·         To add a web role to the solution, choose ASP.NET Web Role and then choose the right arrow. You can add multiple web and worker roles to your Windows Azure solution.
The roles are displayed in the Windows Azure solution pane of the dialog box.

·         Click OK.

Install and Create a Windows Azure Application in VS 2010

You now have a solution with the following two projects:

·         A Windows Azure project

·         A Web role that is an ASP.NET web application

       The Solution explorer view will look similar to the following illustration:

Install and Create a Windows Azure Application in VS 2010

Now to add the code in the Web role project

·         Open Default.aspx file and choose View Designer from the context menu.

·         Open toolbox (Ctrl + Alt + X) and add a new button in the form.

·         To add a click handler for the button, double click the button that you added in the page.

·         Add the namespaces given below:

            using Microsoft.WindowsAzure;

using Microsoft.WindowsAzure.Diagnostics;

using Microsoft.WindowsAzure.ServiceRuntime;

 

·         On the click of the button add the following code given below:

     // Setup the connection to Windows Azure Storage

            var storageAccount =  CloudStorageAccount.Parse (
                                  RoleEnvironment.GetConfigurationSettingValue
                                  ("MyConnectionString"));

            var blobClient = storageAccount.CreateCloudBlobClient();

 

            // Get and create the container

            var blobContainer = blobClient.GetContainerReference("quicklap");

            blobContainer.CreateIfNotExist();

 

            // upload a text blob

            var blob = blobContainer.GetBlobReference(Guid.NewGuid().ToString());

            blob.UploadText("Hello Windows Azure");

 

            // log a message that can be viewed in the diagnostics tables called          
             WADLogsTable

            System.Diagnostics.Trace.WriteLine("Added blob to Windows Azure Storage");

 

The above accomplish the tasks given below:

·         Create a CloudStorageAccount instance from a connection string in the configuration settings

·         Create a blob container

·         Upload a text blob to that container

·         Add a diagnostics message for a web role

Add code to set up the diagnostics monitor to transfer the logs every second and start the monitor. The diagnostics monitor uses a connection string that is added when you create the Windows Azure project. The following code must be added at the beginning of the OnStart method in WebRole.cs:

DiagnosticMonitorConfiguration diagObj = DiagnosticMonitor.GetDefaultInitialConfiguration();

 

//Set the service to transfer logs every second to the storage account

diagObj.Logs.ScheduledTransferPeriod = TimeSpan.FromSeconds(1);

 

//Start Diagnostics Monitor with the new storage account configuration            DiagnosticMonitor.Start("Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString", diagObj);

 

Build and Debug your application

1.      To build the project, open the shortcut menu for the Windows Azure project and then choose Build.

2.      To see the build output, open the shortcut menu for the Windows Azure project and then choose Open Folder in Windows Explorer. Go to the bin\debug directory to view the build output.

3.      To modify settings, choose a role under the Roles node for your Windows Azure project in Solution Explorer, open the shortcut menu for the role and choose Properties.

This will display the property pages for the web role. Every role-level element and attribute in the service definition and service configuration files can be edited using the property pages.

Install and Create a Windows Azure Application in VS 2010

1.      To configure Visual Studio to use the local storage emulator when you run or debug your Windows Azure application, you must add the connection string that you used in the button click event handler. Use the following steps to do this:

a.      On the Settings tab choose the Add Setting button.

b.      In the Name text box, type MyConnectionString.

c.       In the Type combo box, choose Connection String.

d.      Choose the ellipsis in the Value text box. The Storage Account Connection String dialog box is displayed. Choose Use the Windows Azure storage emulator and then choose the OK button.

e.      On the toolbar, choose the Save icon.

Install and Create a Windows Azure Application in VS 2010

To Debug the Windows Azure Project

  1. On the menu bar, choose Debug, Start Debugging (Keyboard: F5).\

The storage emulator and the compute emulator for Visual Studio are started. These emulators enable you to run and debug your Windows Azure application locally before you publish it to Windows Azure.

2.      To manage your local deployments, open the shortcut menu for the Windows Azure icon in the notification area and then choose Show Compute Emulator UI.

The Windows Azure Compute Emulator is displayed.

3.      Choose WebRole1 to display the instances of the web role, as shown in the following illustration. Choose a specific instance to view only that individual instance.

 

Install and Create a Windows Azure Application in VS 2010

To view the data that you added to the blob, on the menu bar choose View, Server Explorer. Open the Windows Azure Storage node in the tree, and then choose the Development, Blobs node. Double-click the quicklap node, as displayed in the following illustration:

Install and Create a Windows Azure Application in VS 2010

The data in the blob is displayed in the quicklab tab.

If you are using the storage emulator, open the shortcut menu for the Windows Azure icon in the notification area and then choose Show Storage Emulator UI to bring up the following dialog, which will allow you to control the running storage services as well as reset all data.

Install and Create a Windows Azure Application in VS 2010

After reading this article you can easily create and build your first windows azure application.

Report Abuse Form
Reason:    
 

Title :
Comment :
Text ColorBackground Color
BoldItalicUnderline
LeftCenterRightJustify
Ordered ListBulleted List
IndentOutdent
Horizontal Rule
SubscriptSuperscript
HyperlinkImage
Design ModeDesign
View HtmlHtml
     
 
Latest Article by Rohit KesharwaniRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Latest BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Top Viewed ArticlesRSS Feed
    
    
    
    
    
    
    
    
    
    
Top Viewed BlogsRSS Feed
    
    
    
    
    
    
    
    
    
    
Latest Interview QuestionsRSS Feed
    
    
    
    
    
    
    
    
    
    
More...
Total Online Users: 5637
Advertisement
MindStick DataConver
Advertise with Us
  
Copyright © 2013MindStick. All Rights Reserved.