April 17, 2014
Hot Topics:
RSS RSS feed Download our iPhone app

Building in the Cloud with Azure Storage and the Azure SDK, Page 4

  • November 12, 2009
  • By Matt Goebel
  • Send Email »
  • More Articles »

Putting It All Together

Finally, you will want to add the code to "Default.aspx.cs" that allows the user to retrieve the calculated value. To enable the user to do so add the following code to the retrieve calculation button's click event handler.

Default.aspx.cs (Part 3)

  protected void cmdRetrieveCalculation_Click(object sender, EventArgs e)
          {
              // Create account info objects for accessing table storage
              StorageAccountInfo accountTableInfo = StorageAccountInfo.GetDefaultTableStorageAccountFromConfiguration();
             
              CalculationDataServiceContext calcDSContext = new CalculationDataServiceContext(accountTableInfo);
  
              // Retrieve the Calculation entity from Table storage
              Calculation calc = (from c in calcDSContext.Calculations
                                  where c.PartitionKey == "TEST" 
                                  && c.RowKey == txtCalculationKey.Text
                                  select c).FirstOrDefault();
  
              lblCalculatedValue.Text = calc.CalcValue.ToString();
              lblCalculatedValue.Visible = true;
          }

Debug the application and you will now be able to start a calculation and retrieve the result. Keep in mind that the service is only waking up every 10 seconds to check the queue to wait the appropriate time before trying to retrieve the calculated value.


Figure 1.6 Final Funtioning Application Screen
Click here for larger image

Figure 1.6 Final Funtioning Application Screen

Conclusion

While building a basic adding machine in the cloud is not exactly necessary, you can learn from the above walkthrough many important features of cloud service applications. The walkthrough has shown you how to create a new cloud service, set up configuration files to use Azure Storage, use Table storage to store, retrieve and update data, use Queue storage to pass messages between cloud service roles and finally how the Azure SDK provided StorageClient project can be leveraged for quick development against Azure Storage services.

About the Author

Matt Goebel is the Founder and President of AP Innovation, Inc. in Indianapolis, Indiana. He can be reached at 859-802-7591 or matt .goebel@apinnovation.com.





Page 4 of 4



Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Sitemap | Contact Us

Rocket Fuel