Monday, October 4, 2010

Azure error SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used

When you start Visual studio azure project using development storage if you get the following error

SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used

go to webrole.cs and modify OnStart code to

public override bool OnStart()
{
DiagnosticMonitor.Start("DiagnosticsConnectionString");

// For information on handling configuration changes
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357.
// RoleEnvironment.Changing += 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.
CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) =>
{
// Provide the configSetter with the initial value
configSetter(RoleEnvironment.GetConfigurationSettingValue(configName));

RoleEnvironment.Changed += (sender, arg) =>
{
if (arg.Changes.OfType<RoleEnvironmentConfigurationSettingChange>()
.Any((change) => (change.ConfigurationSettingName == configName)))
{
// The corresponding configuration setting has changed, propagate the value
if (!configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)))
{
// 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)
RoleEnvironment.RequestRecycle();
}
}
};
});
#endregion

return base.OnStart();
}

This should work!

Saturday, October 2, 2010

Azure Linq Queries

Interesting links for Linq queries

  1. http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx
  2. http://msdn.microsoft.com/en-us/library/bb397676.aspx
  3. http://convective.wordpress.com/2010/02/06/queries-in-azure-tables/
  4. http://msdn.microsoft.com/en-us/library/dd894039.aspx

For some reason Linq queries with directly selecting the required entity using select new { test1, test2} does not seem to work.

Using Linq to select all entities and then use another linq query to filter data does not work.

Using Linq to select all entities and then use foreach to filter the entities required seem to work

Azure Development storage loses all properties

Interesting problem with Azure storage which loses all properties.

couple of interesting fixes for this.

http://social.msdn.microsoft.com/Forums/en-US/windowsazure/thread/020d9146-f374-453a-bc1b-f656306b766c

http://devstoragesync.codeplex.com/

used insert dummy row to fix this.

Convert XML files to class files in Visual studio

xsd.exe gtest1.xsd  /cThese are the steps to convert xml files to class files in Visual Studio.

  1. Open the XML file in Visual Studio.
  2. Create Schema in the XML option.
  3. Run the Visual Studio command prompt from programs.
  4. Cd to the relevant file:
    1. cd C:\test1\test2\\xml_files
  5. To convert file
    1. xsd.exe test1.xsd  /c
  6. to convert multiple files
    1. xsd.exe test1.xsd test2.xsd  /c
  7. when converted individually lot of duplicate names had to be commented out.
  8. Easier approach use the XSD files create constructor for each item.