Develop and test a Windows Azure Service using emulator (local environment)

by Jagadish Pulakhandam on 12/22/2011 12:20:23 PM
Rated 0 from 0 votes
Brief: Demonstrates on creating/developing a new Windows Azure Service (using WCF Service Web Role) and testing the same locally using Windows Azure Emulator.
Posted to: Microsoft Azure Technologies
Add to DiggAdd to del.icio.usAdd to FURLAdd to RedditAdd to YahooAdd to BlinklistAdd to GoogleAdd to ma.gnoliaAdd to ShadowsAdd to Technorati

Attached video demonstrates the following:

  • Creating a new Windows Azure project using Visual Studio 2010
  • Working with "WCF Service Web Role"
  • Modify Service Contract and Operation Contract of the Service to do a simple and basic operation (GetSum which returns sum of two integers passed to it)
  • Using Windows Azure emulator to host the service
  • Consume the service using "WCF Test Client"
Source code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
 
namespace CalcServiceWebRole
{
    [ServiceContract]
    public interface IService1
    {
 
        [OperationContract]
        int GetSum(int a, int b);
 
    }
 
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
 
namespace CalcServiceWebRole
{
    public class Service1 : IService1
    {
 
        public int GetSum(int a, int b)
        {
            return a + b;
        }
    }
}

<?xml version="1.0"?>
<configuration>
  <!--  To collect diagnostic traces, uncomment the section below. 
        To persist the traces to storage, update the DiagnosticsConnectionString setting with your storage credentials.
        To avoid performance degradation, remember to disable tracing on production deployments.
  <system.diagnostics>    
    <sharedListeners>
      <add name="AzureLocalStorage" type="CalcServiceWebRole.AzureLocalStorageTraceListener, CalcServiceWebRole"/>
    </sharedListeners>
    <sources>
      <source name="System.ServiceModel" switchValue="Verbose, ActivityTracing">
        <listeners>
          <add name="AzureLocalStorage"/>
        </listeners>
      </source>
      <source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
        <listeners>
          <add name="AzureLocalStorage"/>
        </listeners>
      </source>
    </sources>
   </system.diagnostics> -->
  <system.diagnostics>
    <trace>
      <listeners>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
          name="AzureDiagnostics">
          <filter type="" />
        </add>
      </listeners>
    </trace>
  </system.diagnostics>
  <system.web>
    <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true"/>
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>
</configuration>



Join the .NET Code Central Community and join the discussion!
Signing-up is FREE and quick. Do it now, we want to hear your opinion
0

Rated 0 from 0 votes ( login  to rate)
DotnetKicks DotnetKicksDe DotNetShoutout

Attachments / Source Code
You need to Login or Join for FREE to download the following

Video/Screen Recording (may not have audio narration/annotations)
You need to Login or Join for FREE to download the following