/// <summary> /// Process a message that was written to the environments queue. /// </summary> /// <param name="message">An instance of <see cref="BrokeredMessage"/> that represents the message written to the queue.</param> /// <param name="log"></param> /// <returns>An instance of <see cref="Task"/> that represents the asynchronous operation.</returns> public static async Task ProcessEnvironmentQueueMessageAsync([ServiceBusTrigger(MigrationConstants.EnvironmentQueueName)] BrokeredMessage message, TextWriter log) { EnvironmentEntity entity; List <MailboxEntity> mailboxes; IMigrationManager manager; try { entity = message.GetBody <EnvironmentEntity>(); manager = new MigrationManager(Program.Service); mailboxes = await manager.GetMailboxesAsync(entity); await manager.CreateMigrationEndpointAsync(entity); await Program.Service.Storage.WriteBatchToTableAsync(MigrationConstants.MailboxTableName, mailboxes); log.WriteLine(message); } finally { entity = null; manager = null; } }