Azure 存储队列 - 消息 ID

Azure Storage Queue - message Id

将消息添加到 Azure 消息队列时,是否有获取消息 ID(GUID 字符串)的方法?

            var storageAccount = CloudStorageAccount.Parse(Storage.ConnectionString);
            var queueClient = storageAccount.CreateCloudQueueClient();
            var messageQueue = queueClient.GetQueueReference(Storage.Queue.Property);

            await messageQueue.AddMessageAsync(message: new CloudQueueMessage(message)
                , timeToLive: TimeSpan.MaxValue
                , initialVisibilityDelay: null
                , options: null
                , operationContext: null);

            // How do I get message Id

我需要能够创建队列中的内容的日志,以及在将项目添加到队列时的日志,消息 ID 接缝将在 Azure 内部创建,无法作为选项传递。

好的,没问题。发送后只读消息Id属性:

            var storageAccount = CloudStorageAccount.Parse(Storage.ConnectionString);
            var queueClient = storageAccount.CreateCloudQueueClient();
            var messageQueue = queueClient.GetQueueReference(Storage.Queue.Property);

            var queueMessage = new CloudQueueMessage(message);

            await messageQueue.AddMessageAsync(message: queueMessage 
                , timeToLive: TimeSpan.MaxValue
                , initialVisibilityDelay: null
                , options: null
                , operationContext: null);

            // How do I get message Id
            Console.WriteLine(queueMessage.Id);