Reputation: 8943
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.
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.
Upvotes: 0
Views: 931
Reputation: 8943
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!
Upvotes: 0
Reputation: 71067
You can send messages to an Azure queue from anywhere, as long as you have proper permissions to do so. I'm assuming you're talking about Storage queues (vs Service Bus queues): You'd either need the storage account key or a Shared Access Signature for the queue. At that point, you can write messages from whatever app you want to.
Just create the queue client, create your message, and add a message to the queue. If your app is running on-premises, on a mobile device, or in a different data center than the storage account the queue is stored in, there will be a bit of latency when adding the message but, otherwise, works just fine.
Upvotes: 1