public async Task<IListener> CreateAsync(ListenerFactoryContext context) { SharedQueueWatcher sharedQueueWatcher = _sharedContextProvider.GetOrCreate<SharedQueueWatcher>( new SharedQueueWatcherFactory(_messageEnqueuedWatcherSetter)); SharedBlobListener sharedBlobListener = _sharedContextProvider.GetOrCreate<SharedBlobListener>( new SharedBlobListenerFactory(_account, _backgroundExceptionDispatcher, _blobWrittenWatcherSetter)); // Note that these clients are intentionally for the storage account rather than for the dashboard account. // We use the storage, not dashboard, account for the blob receipt container and blob trigger queues. IStorageQueueClient queueClient = _account.CreateQueueClient(); IStorageBlobClient blobClient = _account.CreateBlobClient(); string hostId = await _hostIdProvider.GetHostIdAsync(context.CancellationToken); string hostBlobTriggerQueueName = HostQueueNames.GetHostBlobTriggerQueueName(hostId); IStorageQueue hostBlobTriggerQueue = queueClient.GetQueueReference(hostBlobTriggerQueueName); IListener blobDiscoveryToQueueMessageListener = await CreateBlobDiscoveryToQueueMessageListenerAsync( hostId, sharedBlobListener, blobClient, hostBlobTriggerQueue, sharedQueueWatcher, context.CancellationToken); IListener queueMessageToTriggerExecutionListener = CreateQueueMessageToTriggerExecutionListener( _sharedContextProvider, sharedQueueWatcher, queueClient, hostBlobTriggerQueue, blobClient, sharedBlobListener.BlobWritterWatcher); IListener compositeListener = new CompositeListener( blobDiscoveryToQueueMessageListener, queueMessageToTriggerExecutionListener); return compositeListener; }
public async Task<IListener> CreateAsync(CancellationToken cancellationToken) { SharedQueueWatcher sharedQueueWatcher = _sharedContextProvider.GetOrCreate<SharedQueueWatcher>( new SharedQueueWatcherFactory(_messageEnqueuedWatcherSetter)); SharedBlobListener sharedBlobListener = _sharedContextProvider.GetOrCreate<SharedBlobListener>( new SharedBlobListenerFactory(_hostAccount, _backgroundExceptionDispatcher, _blobWrittenWatcherSetter)); // Note that these clients are intentionally for the storage account rather than for the dashboard account. // We use the storage, not dashboard, account for the blob receipt container and blob trigger queues. IStorageQueueClient queueClient = _hostAccount.CreateQueueClient(); IStorageBlobClient blobClient = _hostAccount.CreateBlobClient(); string hostId = await _hostIdProvider.GetHostIdAsync(cancellationToken); string hostBlobTriggerQueueName = HostQueueNames.GetHostBlobTriggerQueueName(hostId); IStorageQueue hostBlobTriggerQueue = queueClient.GetQueueReference(hostBlobTriggerQueueName); IListener blobDiscoveryToQueueMessageListener = await CreateBlobDiscoveryToQueueMessageListenerAsync( hostId, sharedBlobListener, blobClient, hostBlobTriggerQueue, sharedQueueWatcher, cancellationToken); // Important: We're using the "data account" here, which is the account that the // function the listener is for is targeting. This is the account that will be used // to read the trigger blob. IStorageBlobClient userBlobClient = _dataAccount.CreateBlobClient(); IListener queueMessageToTriggerExecutionListener = CreateQueueMessageToTriggerExecutionListener( _sharedContextProvider, sharedQueueWatcher, queueClient, hostBlobTriggerQueue, userBlobClient, sharedBlobListener.BlobWritterWatcher); IListener compositeListener = new CompositeListener( blobDiscoveryToQueueMessageListener, queueMessageToTriggerExecutionListener); return compositeListener; }