GlobalDemo.DAL.Azure.StorageRepository.SendBroadcastQueueMessageAsync C# (CSharp) Method

SendBroadcastQueueMessageAsync() public method

Sends a queue message
public SendBroadcastQueueMessageAsync ( string data ) : Task
data string The message to send
return Task
        public async Task SendBroadcastQueueMessageAsync(string data)
        {
            var client = _account.CreateCloudQueueClient();
            
            //Send to the broadcast queue.  The local
            //  web job will pick this up and broadcast
            //  to every region.  
            var queue = client.GetQueueReference(DAL.Azure.StorageConfig.BroadcastQueueName);

            var message = new CloudQueueMessage(data);

            await queue.AddMessageAsync(message);
        }

Usage Example

        /// <summary>
        /// Notify the backend that a new file was uploaded
        /// by sending a queue message.
        /// </summary>
        /// <param name="value">The name of the blob to be processed</param>
        /// <returns>Void</returns>
        public async Task Post(CompleteRequest item)
        {
            string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
            //Get the owner name field
            string ownerName = ClaimsPrincipal.Current.FindFirst("name").Value;
            //Replace any commas with periods
            ownerName = ownerName.Replace(',', '.');

            string message = string.Format(
                "{0},{1},{2},{3}, {4}, {5}, {6}", 
                item.ID, 
                item.ServerFileName, 
                item.StorageAccountName, 
                owner, 
                ownerName, 
                item.BlobURL, 
                SettingsHelper.CurrentRegion);

            //Send a queue message to the local storage account 
            //The local web job will pick it up and broadcast to 
            //all storage accounts in appSettings prefixed with "Storage"

            var repo = new StorageRepository(SettingsHelper.LocalStorageConnectionString);
            await repo.SendBroadcastQueueMessageAsync(message);
                        
        }