WCF Azure Silverlight Calculator

This sample creates a simple WCF calculator service and builds a Silverlight client for it. The client is then hosted alonside the service in the Azure fabric.

 
 
 
 
 
4 Star
(4)
5,454 times
Add to favorites
4/27/2011
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
VB.NET
Imports System.Linq
Imports Microsoft.WindowsAzure.Diagnostics
Imports Microsoft.WindowsAzure.ServiceRuntime
Imports Microsoft.WindowsAzure

Namespace WcfSamples
    Public Class WebRole
        Inherits RoleEntryPoint
        Public Overrides Function OnStart() As Boolean
            DiagnosticMonitor.Start("DiagnosticsConnectionString")

            ' For information on handling configuration changes
            ' see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
            AddHandler RoleEnvironment.Changing, AddressOf RoleEnvironmentChanging

            '			#Region "Setup CloudStorageAccount Configuration Setting Publisher"

            ' This code sets up a handler to update CloudStorageAccount instances when their corresponding
            ' configuration settings change in the service configuration file.
            ' Provide the configSetter with the initial value
            ' The corresponding configuration setting has changed, propagate the value
            ' In this case, the change to the storage account credentials in the
            ' service configuration is significant enough that the role needs to be
            ' recycled in order to use the latest settings. (for example, the 
            ' endpoint has changed)
            CloudStorageAccount.SetConfigurationSettingPublisher(Sub(configName, configSetter)
                                                                     configSetter(RoleEnvironment.GetConfigurationSettingValue(configName))
                                                                     AddHandler RoleEnvironment.Changed, Sub(sender, arg)
                                                                                                             If arg.Changes.OfType(Of RoleEnvironmentConfigurationSettingChange)().Any(Function(change) (change.ConfigurationSettingName Is configName)) Then
                                                                                                                 If Not configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)) Then
                                                                                                                     RoleEnvironment.RequestRecycle()
                                                                                                                 End If
                                                                                                             End If
                                                                                                         End Sub
                                                                 End Sub)
            '			#End Region

            Return MyBase.OnStart()
        End Function


        Private Sub RoleEnvironmentChanging(ByVal sender As Object, ByVal e As RoleEnvironmentChangingEventArgs)
            ' If a configuration setting is changing
            If e.Changes.Any(Function(change) TypeOf change Is RoleEnvironmentConfigurationSettingChange) Then
                ' Set e.Cancel to true to restart this role instance
                e.Cancel = True
            End If
        End Sub
    End Class
End Namespace