Console App talking to Azure Storage

Yesterday I have looked into developing a Console Application which can communicate with Azure Storage. In theory it is easy. In practic I hit few small hickups. In this article I would like to share my findings with you.

1. References to Windows Azure Assemblies

In order to use StorageClient API in your Console App you need to add Windows Azure assemblies. But when I tried to add Microsoft.WindowsAzure.StorageClient.dll I could not locate it in the list. The trick is to change the Target FrameWork in the project settings to ".NET Framework 4" from the default setting ".NET Framework 4 Client". It turns out that the default setting filters out the dlls which are not likely used in the Console App.

 Project Settings

 

2. Windows Azure configuration

My second little discovery was that you have to enable the Console App to read the Azure Storage connection string configuration from the app.config. To do so, configure the ConfigurationSettingsPublisher to read the settings from the App.Config instead of the ServiceConfiguration.cscfg

 

CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) => { 

// for a console app, reading from App.config

configSetter(

      ConfigurationManager.ConnectionStrings["DataConnectionString"].ConnectionString);

 

});

 

3. Running Dev Storage on your local machine

My final snag (not even a snag) that in order to run the app on your own machine using the Development Storage you have to manually start the Develoment Storage. That could be done via Start/Windows Azure SDK/Development Fabric. After which I was able to run my Console App!

Conclusion

Developing a Console Application which communicates with other parties located in Windows Azure is easy. However an novice user may face few little technology problems which require understanding of Windows Azure concepts.

Add comment

Microsoft Partner

Copyright © 2005-2012

CodeMasters International, LLC.

All Rights Reserved