Sharepoint 2013 : Overview of Windows Azure for Sharepoint (part 5) - DEVELOPING WINDOWS AZURE APPLICATIONS - Creating a Model

11/28/2013 2:13:01 AM
3. Creating a Model (MyFirstAzureApp.sln)

Now create a simple model to represent the data (which will be a small set of sales data), and then expose that data as a return value using the default controller. The example uses the default plumbing code as much as possible to keep things straightforward.

1. Right-click the Models folder and select Add ⇒ Class. Name the class Sales and then click Add.

2. Add the following bolded code to the Sales class, which provides you with a small set of properties for your custom Sales object.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MyFirstAzureWebAPI.Models
public class Sales
public string Company { get; set; }
public string FY09Sales { get; set; }
public string FY10Sales { get; set; }
public string FY11Sales { get; set; }

Now that you’ve created a model (or class), you’ll use this class to create a return List collection object that your Web API service will return in JSON format.

3. Expand the Controllers folder and double-click the ValuesController class.

4. Amend the class with the following bolded code (note these are fictional companies and sales figures).
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using MyFirstAzureWebAPI.Models;

namespace MyFirstAzureWebAPI.Controllers
public class ValuesController : ApiController
// GET api/values
public List<Sales> Get()
List<Sales> mySales = new List<Sales>();

mySales.Add(new Sales

mySales.Add(new Sales

mySales.Add(new Sales
Company = "Wingtip",
FY09Sales = "$9,032,522,000,129.00",
FY10Sales = "$9,115,339,990,899.00",
FY11Sales = "$9,001,439,321,666.00"

return mySales;



The code that you added uses the Sales object to create a List collection object. When you append the Web API URI with "api/values" it will return the three SalesList collection as a JSON formatted object. objects within the
5. Press F6 to build.
6. When you’ve added and successfully compiled the code, press F5 to debug the cloud application. (The solution uses the local cloud emulator to debug the Web API.)
7. When debugging, you’ll see the ASP.NET default page appear (within the domain). When you append the "api/values" path to the URL (as in Figure 12), the Web API service passes back a JSON-formatted object.



How it Works

The MVC templates are a versatile set of ASP.NET Web templates, and the Web API is a specific template that enables you to easily build REST-based services for Windows Azure. You’ll find that Cloud services (such as REST or WCF-based services) will be important to your cloud development efforts for a number of reasons, such as service reuse or application extensibility. In this exercise, you built a REST API with the scaffolding provided by the MVC templates, and the result was a REST service that returned a JSON object.
The JSON object, shown in the following code (with purely fictional data), reflects the List collection you created in the Get method. In essence, this is a small set of data that is returned to you via the REST service call.
When deployed, the REST service would behave similarly, except the endpoint would be configured to a production URI (for example,

Congratulations! You’ve created your first Windows Azure application; that is, a REST-based Web API that returns JSON data. When you deploy it to a production environment, you can use the REST service from a multitude of clients and process the JSON data within your applications — whether it is SharePoint, Windows Phone, Windows 8, or other device/tablet applications.

Even before you deploy your first application to your Windows Azure account, you can use this REST service locally within the cloud emulator environment with other applications. Although you won’t deploy this application to Windows Azure now , you can right-click the cloud project (MyFirstAzureApp) and select Publish. This invokes the Publish Windows Azure Application dialog, which enables you to walk through a wizard and deploy your application directly to your Windows Azure subscription — which you can then manage within the Windows Azure portal. See Figure 13 for the Start page of the Publish Windows Azure Application wizard.



At this point, you should at least have a basic understanding of what Windows Azure is, how to set up the Windows Azure development environment, and the types of applications that you can build using Windows Azure. You might now be asking yourself, “Why all the Windows Azure hubbub?” When paired with SharePoint 2013, Windows Azure becomes important in two ways:

  • It is natively integrated within the SharePoint application development and deployment experience — you use Windows Azure to build and deploy cloud-hosted applications.
  • You can also use Windows Azure in the broader cloud application development experience — just like you could use an array of other Web technologies and standards.
  •  Windows Small Business Server 2011 : Customizing a SharePoint Site - Customizing Companyweb (part 5) - Adding RemoteApps Links - Add the Web Part to Companyweb
  •  Windows Small Business Server 2011 : Customizing a SharePoint Site - Customizing Companyweb (part 4) - Adding RemoteApps Links - Register the Web Part as Safe
  •  Windows Small Business Server 2011 : Customizing a SharePoint Site - Customizing Companyweb (part 3) - Adding RemoteApps Links - Configure RD Web Access
  •  Windows Small Business Server 2011 : Customizing a SharePoint Site - Customizing Companyweb (part 2) - Adding RemoteApps Links - Add the RD Web Access Role Service
  •  Windows Small Business Server 2011 : Customizing a SharePoint Site - Customizing Companyweb (part 1) - Adding a Workspace
  •  Windows Small Business Server 2011 : Customizing a SharePoint Site - Introducing SharePoint Foundation 2010
  •  Sharepoint 2010 : The Search User Interface - The People Search Page (part 3) - Expertise Search, The Preferences Page
  •  Sharepoint 2010 : The Search User Interface - The People Search Page (part 2) - Using People Search Results, Taking Action on Results
  •  Sharepoint 2010 : The Search User Interface - The People Search Page (part 1) - People Search Options
  •  Sharepoint 2010 : The Search User Interface - The Advanced Search Page (part 2) - Picking Property Restrictions
    Most View
    Microsoft SharePoint 2010 Web Applications : Presentation Layer Overview - Ribbon (part 1)
    The Cyber-athletic Revolution – E-sports’ Era (Part 1)
    Windows Server 2003 : Implementing Software Restriction Policies (part 4) - Implementing Software Restriction Policies - Creating a Path Rule, Designating File Types
    Sql Server 2012 : Hierarchical Data and the Relational Database - Populating the Hierarchy (part 1)
    Two Is Better Than One - WD My Cloud Mirror
    Programming ASP.NET 3.5 : Data Source-Based Data Binding (part 3) - List Controls
    Windows 8 : Configuring networking (part 5) - Managing network settings - Understanding the dual TCP/IP stack in Windows 8, Configuring name resolution
    Nikon Coolpix A – An Appealing Camera For Sharp Images (Part 2)
    Canon PowerShot SX240 HS - A Powerful Perfection
    LG Intuition Review - Skirts The Line Between Smartphone And Tablet (Part 2)
    Popular Tags
    Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS
    Top 10
    Review : Acer Aspire R13
    Review : Microsoft Lumia 535
    Review : Olympus OM-D E-M5 Mark II
    TomTom Runner + MultiSport Cardio
    Timex Ironman Run Trainer 2.0
    Suunto Ambit3 Peak Sapphire HR
    Polar M400
    Garmin Forerunner 920XT
    Sharepoint 2013 : Content Model and Managed Metadata - Publishing, Un-publishing, and Republishing
    Sharepoint 2013 : Content Model and Managed Metadata - Content Type Hubs