Warning
This page is located in archive.

Windows Azure applications

ASP.NET, Windows Azure

Tutorial Tasks

Task 1 - Preparation

  1. Subscribe to Azure guaranteed zero cost account, see Step-by-step guide

Task 2 - ASP.NET MVC3 application

  1. Create new project (you can use a new empty solution) (Visual C# → Web → ASP.NET MVC3 Application).
  2. Use project template - Internet application with an account controller that uses forms authentication.
  3. Test application locally
  4. Study application (role) structure. Identify parts of MVC.
  5. Open Site.Master view, add item called “Submit message” into menu.
    1. If you have time, rewrite the default content in order to represent a simple message board.
  6. Extend corresponding controller (Home) and add a new view (Insertion).
  7. Add new model MessageModel
  8. Add action Insertion for storing message board messages.
  9. Implement simple static class SimpleStorage to provide data container for messages.
  10. Provide Index view with messages model (from corresponding controller).
  11. Output content of MessagesModel in Index view.

Messages Model

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

Insertion view

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

<asp:Content ID="aboutTitle" ContentPlaceHolderID="TitleContent" runat="server">
    Message submission
</asp:Content>

<asp:Content ID="aboutContent" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Message submission</h2>

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

Insertion action

        [HttpPost]
        public ActionResult Insertion (MessageModel model, string returnUrl)
        {
            SimpleStorage.Messages.Add(model.Message);
            return RedirectToAction("Index");
        }

Messages model

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

Task 3 - Azure application deployment

There is currently problem to use visual studio tools for deploying azure applications. You can use direct upload of application package instead.
  1. Add new project (Cloud → Windows Azure Project)
  2. Don't add any roles (we will use the current one)
  3. Add MVCApplication1 to Azure project roles (Roles→Add→Web Role Project in solution)
  4. Configure the only web role (WindowsAzureProjectx → Roles → MvcApplicationx → right click).
    1. Instance count = 2
    2. VM size = extra small
  5. Test application locally (if possible)
  6. Cloud deployment
    1. WindowsAzureProjectx → right click → publish
    2. Choose your subscription → manage → new
    3. Create new certificate, enter a friendly name
    4. Copy full path of the certificate to clipboard
    5. Go to windows azure portal → management certificate
    6. Right click on your subscription → Add certificate → browse
    7. Copy path to address bar → select certificate → click ok
    8. Copy Subscription Id from Windows Azure Management Portal
    9. Go back to Visual Studio and paste the Subscription Id
    10. Choose your new subscription → Next
    11. Leave settings as it is → Next → Publish
  7. Wait until the role is published and the environment started. Test the deployment online. What is the problem?
courses/a4m39wa2/tutorials/07/start.txt · Last modified: 2014/12/05 13:06 (external edit)