Search code examples
c#wpfazureazure-storage-queues

Sending message to Azure queue from WPF application


I am trying to make a windows application in WPF that needs to send messages to Azure queue that belongs to other cloud application. Later a worker role will extract those messages from the queue and make some manipulation on the data.

  • Is it even possible or do I have to use a cloud application with a web role?
  • If it is, can someone point me to a good reading source on how to do it?
  • If its not, how can I make a windows executable app that uses Azure queues?

edit: this is my code, I included this:

using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.StorageClient;
using Microsoft.WindowsAzure.ServiceRuntime;


var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");
var queue = storageAccount.CreateCloudQueueClient();

I get this exception:

SetConfigurationSettingPublisher needs to be called before FromConfigurationSetting can be used

I've tried to look up this exception but didn't find a normal solution. Every post is talking about an azure cloud application while I'm trying to do it from WPF.


Solution

  • I managed to make it work, with some help from a friend. This is what I did:

    Added reference to System.Configuration in order to use ConfigurationManager

    Added to the App.Config:

    <appSettings> <add key="StorageConnectionString" value="UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://127.0.0.1:10001/"/> </appSettings>

    In order to connect to local storage account:

    CloudStorageAccount st = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["StorageConnectionString"].ToString());

    Hopes it helps other stuck with same problem!