Friday, 5 June 2015

Microsoft Azure DevCamp Hackathon :Our Solution

Our Solution:

We created a simple web application using visual studio 2013 & Azure. Our application was to ask user to enter Employee details (First Name, Last Name, Address and Email ID) and store this in Azure Table. The saved details were then displayed on a web page.

Steps to be followed to implement the proposed solution in VS 2013 & Azure:

1. Create a MVC Web Application with visual studio 2013

2. Install ‘Nuget Package’ : Install-Package WindowsAzure.Storage -Version 4.3.0


Note: Now, we need to create a table. So, we will use Storage feature of Azure

3. Create a storage on azure portal.



4. View Page: Created a form with three input box and two buttons. On click,‘Save’ button is sending data to Controller.

5. Controller Class

5.1 Create CloudStorageAccount client with ‘Account Name’ & ‘Account Key’.
   _storageAccount = CloudStorageAccount.Parse(WebConfigurationManager.AppSettings["storageAccount"]);

5.2  Now, create the tableClient
                _tableClient = _storageAccount.CreateCloudTableClient();       

5.3  Create a model class extending TableEntity class.

5.4  Initialize table client.
 _table = tableClient.GetTableReference("mytable");
 _table.CreateIfNotExists();

5.5  Added data to Model, and called TableOperation class
    TableOperation insertOperation = TableOperation.Insert(model);
    _table.Execute(insertOperation);


6. Publish

6.1  Select project and right click, and click on publish



6.2  Enter Site name, select Region, and choose database if any, and click on next,


6.3 In next window, click on publish, Website will be published on azure and will be listed inside Web App on Azure Portal.



6.4 After Publish, to save record on azure table, open URL in browser

6.5 Manually Add data and, Click on save button to save data

6.6 To view data of Azure table, click on 'ViewData' from menu

We presented this on stage and yes, we were the first one to do so.