Warning
This page is located in archive.

.NET Introduction, Windows Azure Platform basics

Practice tasks

Task 1 - ASP.NET MVC 3 Application - Hello World

  1. Start Visual Studio
  2. Create new project ASP.NET MVC3 project
  3. Use appropriate template
  4. Test application locally
  5. Study application (role) structure. Identify parts of MVC.
  6. Open Site.Master view, add item called „Submit message“ into menu.
  7. Extend corresponding controller (Home) and add a new view (Insertion).
  8. Add new models MessageModel and MessagesModel (see bellow).
  9. Add controller Insertion for storing message board message.
  10. Implement class SimpleStorage to provide data container for messages.
  11. Provide Index view with messages model (from corresponding controller).
  12. Output content of MessagesModel in Index view.

ISimpleStorage

 public interface ISimpleStorage
 {
     List<string> Messages { get; }
     void AddMessage(string message);
 }
                                

Models

    public class MessageModel
    {
        [Required]
        [DataType(DataType.Text)]
        [Display(Name = "Your Message")]
        public string Message { get; set; }
    }

    public class MessagesModel
    {
        [DataType(DataType.Text)]
        public List<string> Messages { get; set; }
    }

Insertion view

<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<MvcApplication2.Models.MessageModel>" %>

<asp:Content ID="aboutTitle" ContentPlaceHolderID="TitleContent" runat="server">
    About - My ASP.NET MVC Application
</asp:Content>

<asp:Content ID="aboutContent" ContentPlaceHolderID="MainContent" runat="server">
    <hgroup class="title">
        <h1>You can insert your messages here</h1>
     </hgroup>

    <% using (Html.BeginForm())
       {%>
    <div>
        <fieldset>
            <div class="editor-label">
                <%: Html.LabelFor(m =>m.Message) %>
            </div>
            <div class="editor-field">
                <%: Html.TextAreaFor(m =>m.Message) %>
                <%: Html.ValidationMessageFor(m =>m.Message) %>
            </div>
            <p>
                <input type="submit" value="Uloz vzkaz"/>
            </p>
        </fieldset>     
    </div>
      <%  } %>

    <aside>
        <h3>Aside Title</h3>
        <p>
            Use this area to provide additional information.
        </p>
        <ul>
            <li><%: Html.ActionLink("Home", "Index", "Home") %></li>
            <li><%: Html.ActionLink("About", "About", "Home") %></li>
            <li><%: Html.ActionLink("Contact", "Contact", "Home") %></li>
        </ul>
    </aside>
</asp:Content>

Only for education purposes. The approach above is not correct and should not be used for production.

Task 2 - Cloud Migration

  1. Add new Windows Azure Cloud Service Project
  2. Don't add any roles
  3. Add MVCApplication1 role to Azure project roles
  4. Configure the web role
    1. Instance count = 2
    2. VM size = extra small
  5. Test application locally

Task 3 - Cloud Deployment

  1. Register for trial version of Windows Azure Platform
  2. Start deployment (publish)
  3. Sign in with your Microsoft account
  4. Name your service and storage account (e.g. wa2testx, unique)
  5. Select region (e.g. West Europe)
  6. Click on “Publish” and wait for a few minutes
  7. Test deployment online
  8. What is the problem?
courses/a4m39wa2/tutorials/06/start.txt · Last modified: 2014/12/03 13:36 (external edit)