Step-By-Step Create First Azure Application 

First Application Developing

We first open Visual Studio 2013 as Administrator and create a new project. Open "File" -> "New" -> "Project...". From the cloud tab select Azure Cloud Service and click on the OK button.


Now we need to select our prefered language. We can use any of the three languages to develop an application but now select Visual C#.


After clicking the Visual C# language we will get the option to select Web Role or Worker Role.


Before we proceed we first need to understand what a Web Role and Worker Role are.

A Web Role defines the important role, its provides the Internet Information Services (IIS) for hosting front-end applications. The Worker Role basically gets input from the Window Azure Storage or Web Role, to do some background task in Window Azure.

Now back to creating web application on Windows Azure. In the Role Window we will select the ASP.NET Web Role and click the OK button.


If we are exploring in the Solution Explorer we will find two projects, one is a Windows Azure project and the other is an ASP.Net Web Role.


When we explore the Window Azure project, it contains the following two Configuration files:

  • ServiceConfiguration.Cloud.cscfg
  • ServiceConfiguration.Local.cscfg

 

ServiceConfiguration.Cloud.cscfg: This service provides the configuration file for the cloud service and it contains settings for the roles. This file contains the information for the number of instances for the service. Whenever we want to increase the number of instances of the role this configuration is required for changing the instances.

ServiceConfiguration.Local.cscfg: This service provides the configuration file for the local services. Whenever we want changes in the number of instances for the role in the local services, this file is required for changing the instance.

When we click on the service Configuration file, we will get the following XML.

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <ServiceConfiguration serviceName="MyFirstWindowsAzureApplication" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2014-06.2.4">  
  3. <Role name="WebRole1">  
  4. <Instances count="1" />  
  5. <ConfigurationSettings />  
  6. </Role>  
  7. </ServiceConfiguration>  

In the service configuration file the following information is provided.

  • Operating System Version
  • Connection string settings
  • Instance counts

By default an instance count set to 1. That shows that it has one instance of Web Role and now we change the instances value count to 2.

  1. <Instance count="2" />  

When we open the service definition file we will get the following XML.

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <ServiceDefinition name="My First Windows AzureApplication" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2014-06.2.4">  
  3. <WebRole name="WebRole1" vmsize="Small">  
  4. <Sites>  
  5. <Site name="Web">  
  6. <Bindings>  
  7. <Binding name="Endpoint1" endpointName="Endpoint1" />  
  8. </Bindings>  
  9. </Site>  
  10. </Sites>  
  11. <Endpoints>  
  12. <InputEndpoint name="Endpoint1" protocol="http" port="80" />  
  13. </Endpoints>  
  14. </WebRole>  
  15. </ServiceDefinition>  

The service definition file contains the information related to the binding sites. It also contains the information about the EndPoints and the default port number. In normal work we don't need to change or edit the file.

The next important file in the Windows Azure is the WebRole1. If you remember, we have not changed the name of the Web Role when we created it in the previous steps.

When we click on the WebRole1, we will get the following UI:


In this UI we can do various settings like:

  • Manage Setting
  • Configure Local Storage
  • Manage Virtual Networks
  • Configure End Points
  • Specify the storage Account
  • Configure Web Role

Now we have some understanding of the various files in the Window Azure project in the solution. In the other project is a normal ASP.NET web application that contains the one other file called the WebrRole.cs. The basic work of this web application is to host the web application in Windows Azure.


Let us open the default.aspx and modify the code.

  1. <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebRole1._Default" %>  
  2. <asp:Content ID="HeaderContent" ContentPlaceHolderID="HeadContent" runat="server">  
  3. </asp:Content>  
  4. <asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">  
  5. <h1>  
  6. This is first Azure Application  
  7. </h1>  
  8. </asp:Content>  


In this way you can start developing for Window Azure. I hope this article is helpful for the readers. Thanks for reading the article.

Up Next
    Ebook Download
    View all
    Learn
    View all