private void openOrCreateQueue(string channelName) { this.WriteDebugMessage("Attempting to open queue for channel {0}", channelName); try { CloudStorageAccount.SetConfigurationSettingPublisher( (configurationKey, publishConfigurationValue) => { var connectionString = RoleEnvironment.IsAvailable ? RoleEnvironment.GetConfigurationSettingValue(configurationKey) : ConfigurationManager.AppSettings[configurationKey]; publishConfigurationValue(connectionString); }); var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); var queueClient = storageAccount.CreateCloudQueueClient(); _queue = queueClient.GetQueueReference(channelName.ToLower()); if (!_queue.Exists()) { this.WriteDebugMessage("Queue {0} does not exist. Attempting to create it.", channelName); _queue.Create(); this.WriteDebugMessage("Created queue for channel {0}", channelName); } } catch (Exception e) { this.WriteErrorMessage("Failed to open or create queue for channel {0}", e, channelName); throw; } this.WriteDebugMessage("Opened queue for channel {0}", channelName); }