public BlobListenerFactory(IHostIdProvider hostIdProvider, IQueueConfiguration queueConfiguration, IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IContextSetter <IBlobWrittenWatcher> blobWrittenWatcherSetter, IContextSetter <IMessageEnqueuedWatcher> messageEnqueuedWatcherSetter, ISharedContextProvider sharedContextProvider, TraceWriter trace, string functionId, IStorageAccount account, IStorageBlobContainer container, IBlobPathSource input, ITriggeredFunctionExecutor executor) { if (hostIdProvider == null) { throw new ArgumentNullException("hostIdProvider"); } if (queueConfiguration == null) { throw new ArgumentNullException("queueConfiguration"); } if (backgroundExceptionDispatcher == null) { throw new ArgumentNullException("backgroundExceptionDispatcher"); } if (blobWrittenWatcherSetter == null) { throw new ArgumentNullException("blobWrittenWatcherSetter"); } if (messageEnqueuedWatcherSetter == null) { throw new ArgumentNullException("messageEnqueuedWatcherSetter"); } if (sharedContextProvider == null) { throw new ArgumentNullException("sharedContextProvider"); } if (trace == null) { throw new ArgumentNullException("trace"); } if (account == null) { throw new ArgumentNullException("account"); } if (container == null) { throw new ArgumentNullException("container"); } if (input == null) { throw new ArgumentNullException("input"); } if (executor == null) { throw new ArgumentNullException("executor"); } _hostIdProvider = hostIdProvider; _queueConfiguration = queueConfiguration; _backgroundExceptionDispatcher = backgroundExceptionDispatcher; _blobWrittenWatcherSetter = blobWrittenWatcherSetter; _messageEnqueuedWatcherSetter = messageEnqueuedWatcherSetter; _sharedContextProvider = sharedContextProvider; _trace = trace; _functionId = functionId; _account = account; _container = container; _input = input; _executor = executor; }
private static IReadOnlyDictionary<string, Type> CreateBindingDataContract(IBlobPathSource path) { Dictionary<string, Type> contract = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase); contract.Add("BlobTrigger", typeof(string)); IReadOnlyDictionary<string, Type> contractFromPath = path.CreateBindingDataContract(); if (contractFromPath != null) { foreach (KeyValuePair<string, Type> item in contractFromPath) { // In case of conflict, binding data from the value type overrides the built-in binding data above. contract[item.Key] = item.Value; } } return contract; }
private BlobTriggerExecutor CreateProductUnderTest(IBlobPathSource input, IBlobReceiptManager receiptManager, IBlobTriggerQueueWriter queueWriter) { return(CreateProductUnderTest("FunctionId", input, receiptManager, queueWriter)); }
public BlobTriggerBinding(ParameterInfo parameter, IArgumentBinding <IStorageBlob> argumentBinding, IStorageAccount hostAccount, IStorageAccount dataAccount, IBlobPathSource path, IHostIdProvider hostIdProvider, IQueueConfiguration queueConfiguration, JobHostBlobsConfiguration blobsConfiguration, IWebJobsExceptionHandler exceptionHandler, IContextSetter <IBlobWrittenWatcher> blobWrittenWatcherSetter, IContextSetter <IMessageEnqueuedWatcher> messageEnqueuedWatcherSetter, ISharedContextProvider sharedContextProvider, SingletonManager singletonManager, TraceWriter trace) { if (parameter == null) { throw new ArgumentNullException("parameter"); } if (argumentBinding == null) { throw new ArgumentNullException("argumentBinding"); } if (hostAccount == null) { throw new ArgumentNullException("hostAccount"); } if (dataAccount == null) { throw new ArgumentNullException("dataAccount"); } if (path == null) { throw new ArgumentNullException("path"); } if (hostIdProvider == null) { throw new ArgumentNullException("hostIdProvider"); } if (queueConfiguration == null) { throw new ArgumentNullException("queueConfiguration"); } if (blobsConfiguration == null) { throw new ArgumentNullException("blobsConfiguration"); } if (exceptionHandler == null) { throw new ArgumentNullException("exceptionHandler"); } if (blobWrittenWatcherSetter == null) { throw new ArgumentNullException("blobWrittenWatcherSetter"); } if (messageEnqueuedWatcherSetter == null) { throw new ArgumentNullException("messageEnqueuedWatcherSetter"); } if (sharedContextProvider == null) { throw new ArgumentNullException("sharedContextProvider"); } if (singletonManager == null) { throw new ArgumentNullException("singletonManager"); } if (trace == null) { throw new ArgumentNullException("trace"); } _parameter = parameter; _argumentBinding = argumentBinding; _hostAccount = hostAccount; _dataAccount = dataAccount; StorageClientFactoryContext context = new StorageClientFactoryContext { Parameter = parameter }; _blobClient = dataAccount.CreateBlobClient(context); _accountName = BlobClient.GetAccountName(_blobClient); _path = path; _hostIdProvider = hostIdProvider; _queueConfiguration = queueConfiguration; _blobsConfiguration = blobsConfiguration; _exceptionHandler = exceptionHandler; _blobWrittenWatcherSetter = blobWrittenWatcherSetter; _messageEnqueuedWatcherSetter = messageEnqueuedWatcherSetter; _sharedContextProvider = sharedContextProvider; _singletonManager = singletonManager; _trace = trace; _converter = CreateConverter(_blobClient); _bindingDataContract = CreateBindingDataContract(path); }
private static BlobTriggerExecutor CreateProductUnderTest(IBlobPathSource input, IBlobETagReader eTagReader, IBlobReceiptManager receiptManager, IBlobTriggerQueueWriter queueWriter) { return CreateProductUnderTest("FunctionId", input, eTagReader, receiptManager, queueWriter); }
public BlobListenerFactory(IHostIdProvider hostIdProvider, IQueueConfiguration queueConfiguration, JobHostBlobsConfiguration blobsConfiguration, IWebJobsExceptionHandler exceptionHandler, IContextSetter <IBlobWrittenWatcher> blobWrittenWatcherSetter, IContextSetter <IMessageEnqueuedWatcher> messageEnqueuedWatcherSetter, ISharedContextProvider sharedContextProvider, TraceWriter trace, ILoggerFactory loggerFactory, string functionId, IStorageAccount hostAccount, IStorageAccount dataAccount, IStorageBlobContainer container, IBlobPathSource input, ITriggeredFunctionExecutor executor, SingletonManager singletonManager) { if (hostIdProvider == null) { throw new ArgumentNullException("hostIdProvider"); } if (queueConfiguration == null) { throw new ArgumentNullException("queueConfiguration"); } if (blobsConfiguration == null) { throw new ArgumentNullException("blobsConfiguration"); } if (exceptionHandler == null) { throw new ArgumentNullException("exceptionHandler"); } if (blobWrittenWatcherSetter == null) { throw new ArgumentNullException("blobWrittenWatcherSetter"); } if (messageEnqueuedWatcherSetter == null) { throw new ArgumentNullException("messageEnqueuedWatcherSetter"); } if (sharedContextProvider == null) { throw new ArgumentNullException("sharedContextProvider"); } if (trace == null) { throw new ArgumentNullException("trace"); } if (hostAccount == null) { throw new ArgumentNullException("hostAccount"); } if (dataAccount == null) { throw new ArgumentNullException("dataAccount"); } if (container == null) { throw new ArgumentNullException("container"); } if (input == null) { throw new ArgumentNullException("input"); } if (executor == null) { throw new ArgumentNullException("executor"); } if (singletonManager == null) { throw new ArgumentNullException("singletonManager"); } _hostIdProvider = hostIdProvider; _queueConfiguration = queueConfiguration; _blobsConfiguration = blobsConfiguration; _exceptionHandler = exceptionHandler; _blobWrittenWatcherSetter = blobWrittenWatcherSetter; _messageEnqueuedWatcherSetter = messageEnqueuedWatcherSetter; _sharedContextProvider = sharedContextProvider; _trace = trace; _loggerFactory = loggerFactory; _functionId = functionId; _hostAccount = hostAccount; _dataAccount = dataAccount; _container = container; _input = input; _executor = executor; _singletonManager = singletonManager; }
private static BlobTriggerExecutor CreateProductUnderTest(string functionId, IBlobPathSource input, IBlobETagReader eTagReader, IBlobReceiptManager receiptManager, IBlobTriggerQueueWriter queueWriter) { return(new BlobTriggerExecutor(String.Empty, functionId, input, eTagReader, receiptManager, queueWriter)); }
private static BlobTriggerExecutor CreateProductUnderTest(IBlobPathSource input) { return CreateProductUnderTest(input, CreateDummyETagReader()); }
private static BlobTriggerExecutor CreateProductUnderTest(IBlobPathSource input, IBlobETagReader eTagReader) { return(CreateProductUnderTest(input, eTagReader, CreateDummyReceiptManager())); }
private static BlobTriggerExecutor CreateProductUnderTest(IBlobPathSource input, IBlobETagReader eTagReader, IBlobReceiptManager receiptManager) { return(CreateProductUnderTest("FunctionId", input, eTagReader, receiptManager, CreateDummyQueueWriter())); }
private static BlobTriggerExecutor CreateProductUnderTest(IBlobPathSource input) { return(CreateProductUnderTest(input, CreateDummyETagReader())); }
public BlobTriggerBinding(ParameterInfo parameter, IArgumentBinding<IStorageBlob> argumentBinding, IStorageAccount hostAccount, IStorageAccount dataAccount, IBlobPathSource path, IHostIdProvider hostIdProvider, IQueueConfiguration queueConfiguration, IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IContextSetter<IBlobWrittenWatcher> blobWrittenWatcherSetter, IContextSetter<IMessageEnqueuedWatcher> messageEnqueuedWatcherSetter, ISharedContextProvider sharedContextProvider, TraceWriter trace) { if (parameter == null) { throw new ArgumentNullException("parameter"); } if (argumentBinding == null) { throw new ArgumentNullException("argumentBinding"); } if (hostAccount == null) { throw new ArgumentNullException("hostAccount"); } if (dataAccount == null) { throw new ArgumentNullException("dataAccount"); } if (path == null) { throw new ArgumentNullException("path"); } if (hostIdProvider == null) { throw new ArgumentNullException("hostIdProvider"); } if (queueConfiguration == null) { throw new ArgumentNullException("queueConfiguration"); } if (backgroundExceptionDispatcher == null) { throw new ArgumentNullException("backgroundExceptionDispatcher"); } if (blobWrittenWatcherSetter == null) { throw new ArgumentNullException("blobWrittenWatcherSetter"); } if (messageEnqueuedWatcherSetter == null) { throw new ArgumentNullException("messageEnqueuedWatcherSetter"); } if (sharedContextProvider == null) { throw new ArgumentNullException("sharedContextProvider"); } if (trace == null) { throw new ArgumentNullException("trace"); } _parameter = parameter; _argumentBinding = argumentBinding; _hostAccount = hostAccount; _dataAccount = dataAccount; StorageClientFactoryContext context = new StorageClientFactoryContext { Parameter = parameter }; _blobClient = dataAccount.CreateBlobClient(context); _accountName = BlobClient.GetAccountName(_blobClient); _path = path; _hostIdProvider = hostIdProvider; _queueConfiguration = queueConfiguration; _backgroundExceptionDispatcher = backgroundExceptionDispatcher; _blobWrittenWatcherSetter = blobWrittenWatcherSetter; _messageEnqueuedWatcherSetter = messageEnqueuedWatcherSetter; _sharedContextProvider = sharedContextProvider; _trace = trace; _converter = CreateConverter(_blobClient); _bindingDataContract = CreateBindingDataContract(path); }
public BlobTriggerBinding(string parameterName, IArgumentBinding <IStorageBlob> argumentBinding, IStorageAccount account, IBlobPathSource path, IHostIdProvider hostIdProvider, IQueueConfiguration queueConfiguration, IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IContextSetter <IBlobWrittenWatcher> blobWrittenWatcherSetter, IContextSetter <IMessageEnqueuedWatcher> messageEnqueuedWatcherSetter, ISharedContextProvider sharedContextProvider, TextWriter log) { if (argumentBinding == null) { throw new ArgumentNullException("argumentBinding"); } if (account == null) { throw new ArgumentNullException("account"); } if (path == null) { throw new ArgumentNullException("path"); } if (hostIdProvider == null) { throw new ArgumentNullException("hostIdProvider"); } if (queueConfiguration == null) { throw new ArgumentNullException("queueConfiguration"); } if (backgroundExceptionDispatcher == null) { throw new ArgumentNullException("backgroundExceptionDispatcher"); } if (blobWrittenWatcherSetter == null) { throw new ArgumentNullException("blobWrittenWatcherSetter"); } if (messageEnqueuedWatcherSetter == null) { throw new ArgumentNullException("messageEnqueuedWatcherSetter"); } if (sharedContextProvider == null) { throw new ArgumentNullException("sharedContextProvider"); } if (log == null) { throw new ArgumentNullException("log"); } _parameterName = parameterName; _argumentBinding = argumentBinding; _account = account; _client = account.CreateBlobClient(); _accountName = BlobClient.GetAccountName(_client); _path = path; _hostIdProvider = hostIdProvider; _queueConfiguration = queueConfiguration; _backgroundExceptionDispatcher = backgroundExceptionDispatcher; _blobWrittenWatcherSetter = blobWrittenWatcherSetter; _messageEnqueuedWatcherSetter = messageEnqueuedWatcherSetter; _sharedContextProvider = sharedContextProvider; _log = log; _converter = CreateConverter(_client); _bindingDataContract = CreateBindingDataContract(path); }
public BlobTriggerBinding(string parameterName, IArgumentBinding<IStorageBlob> argumentBinding, IStorageAccount account, IBlobPathSource path, IHostIdProvider hostIdProvider, IQueueConfiguration queueConfiguration, IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IContextSetter<IBlobWrittenWatcher> blobWrittenWatcherSetter, IContextSetter<IMessageEnqueuedWatcher> messageEnqueuedWatcherSetter, ISharedContextProvider sharedContextProvider, TextWriter log) { if (argumentBinding == null) { throw new ArgumentNullException("argumentBinding"); } if (account == null) { throw new ArgumentNullException("account"); } if (path == null) { throw new ArgumentNullException("path"); } if (hostIdProvider == null) { throw new ArgumentNullException("hostIdProvider"); } if (queueConfiguration == null) { throw new ArgumentNullException("queueConfiguration"); } if (backgroundExceptionDispatcher == null) { throw new ArgumentNullException("backgroundExceptionDispatcher"); } if (blobWrittenWatcherSetter == null) { throw new ArgumentNullException("blobWrittenWatcherSetter"); } if (messageEnqueuedWatcherSetter == null) { throw new ArgumentNullException("messageEnqueuedWatcherSetter"); } if (sharedContextProvider == null) { throw new ArgumentNullException("sharedContextProvider"); } if (log == null) { throw new ArgumentNullException("log"); } _parameterName = parameterName; _argumentBinding = argumentBinding; _account = account; _client = account.CreateBlobClient(); _accountName = BlobClient.GetAccountName(_client); _path = path; _hostIdProvider = hostIdProvider; _queueConfiguration = queueConfiguration; _backgroundExceptionDispatcher = backgroundExceptionDispatcher; _blobWrittenWatcherSetter = blobWrittenWatcherSetter; _messageEnqueuedWatcherSetter = messageEnqueuedWatcherSetter; _sharedContextProvider = sharedContextProvider; _log = log; _converter = CreateConverter(_client); _bindingDataContract = CreateBindingDataContract(path); }
public BlobTriggerExecutor(string hostId, FunctionDescriptor functionDescriptor, IBlobPathSource input, IBlobReceiptManager receiptManager, IBlobTriggerQueueWriter queueWriter, ILogger <BlobListener> logger) { _hostId = hostId; _functionDescriptor = functionDescriptor; _input = input; _queueWriter = queueWriter; _receiptManager = receiptManager; _logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
public BlobListenerFactory(IHostIdProvider hostIdProvider, IQueueConfiguration queueConfiguration, IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IContextSetter<IBlobWrittenWatcher> blobWrittenWatcherSetter, IContextSetter<IMessageEnqueuedWatcher> messageEnqueuedWatcherSetter, ISharedContextProvider sharedContextProvider, TextWriter log, string functionId, IStorageAccount account, IStorageBlobContainer container, IBlobPathSource input, ITriggeredFunctionExecutor<IStorageBlob> executor) { if (hostIdProvider == null) { throw new ArgumentNullException("hostIdProvider"); } if (queueConfiguration == null) { throw new ArgumentNullException("queueConfiguration"); } if (backgroundExceptionDispatcher == null) { throw new ArgumentNullException("backgroundExceptionDispatcher"); } if (blobWrittenWatcherSetter == null) { throw new ArgumentNullException("blobWrittenWatcherSetter"); } if (messageEnqueuedWatcherSetter == null) { throw new ArgumentNullException("messageEnqueuedWatcherSetter"); } if (sharedContextProvider == null) { throw new ArgumentNullException("sharedContextProvider"); } if (log == null) { throw new ArgumentNullException("log"); } if (account == null) { throw new ArgumentNullException("account"); } if (container == null) { throw new ArgumentNullException("container"); } if (input == null) { throw new ArgumentNullException("input"); } if (executor == null) { throw new ArgumentNullException("executor"); } _hostIdProvider = hostIdProvider; _queueConfiguration = queueConfiguration; _backgroundExceptionDispatcher = backgroundExceptionDispatcher; _blobWrittenWatcherSetter = blobWrittenWatcherSetter; _messageEnqueuedWatcherSetter = messageEnqueuedWatcherSetter; _sharedContextProvider = sharedContextProvider; _log = log; _functionId = functionId; _account = account; _container = container; _input = input; _executor = executor; }
public void ExecuteAsync_IfLeasedIncompleteReceipt_EnqueuesMessageMarksCompletedReleasesLeaseAndReturnsSuccessResult() { // Arrange string expectedFunctionId = "FunctionId"; BlobTriggerExecutorContext context = CreateExecutorContext(); string expectedETag = context.Blob.BlobClient.GetProperties().Value.ETag.ToString(); IBlobPathSource input = CreateBlobPath(context.Blob); Mock <IBlobReceiptManager> managerMock = CreateReceiptManagerReferenceMock(); managerMock .Setup(m => m.TryReadAsync(It.IsAny <BlockBlobClient>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(BlobReceipt.Incomplete)); managerMock .Setup(m => m.TryAcquireLeaseAsync(It.IsAny <BlockBlobClient>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult("LeaseId")); managerMock .Setup(m => m.MarkCompletedAsync(It.IsAny <BlockBlobClient>(), It.IsAny <string>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(0)) .Verifiable(); managerMock .Setup(m => m.ReleaseLeaseAsync(It.IsAny <BlockBlobClient>(), It.IsAny <string>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(0)) .Verifiable(); IBlobReceiptManager receiptManager = managerMock.Object; Mock <IBlobTriggerQueueWriter> queueWriterMock = new Mock <IBlobTriggerQueueWriter>(MockBehavior.Strict); queueWriterMock .Setup(w => w.EnqueueAsync(It.IsAny <BlobTriggerMessage>(), It.IsAny <CancellationToken>())) .Returns(Task.FromResult(("testQueueName", "testMessageId"))); IBlobTriggerQueueWriter queueWriter = queueWriterMock.Object; ITriggerExecutor <BlobTriggerExecutorContext> product = CreateProductUnderTest(expectedFunctionId, input, receiptManager, queueWriter); // Act Task <FunctionResult> task = product.ExecuteAsync(context, CancellationToken.None); // Assert task.WaitUntilCompleted(); queueWriterMock .Verify( w => w.EnqueueAsync(It.Is <BlobTriggerMessage>(m => m != null && m.FunctionId == expectedFunctionId /*&& m.BlobType == StorageBlobType.BlockBlob $$$ */ && m.BlobName == context.Blob.BlobClient.Name && m.ContainerName == context.Blob.BlobClient.BlobContainerName && m.ETag == expectedETag), It.IsAny <CancellationToken>()), Times.Once()); managerMock.Verify(); Assert.True(task.Result.Succeeded); // Validate log is written var logMessage = _loggerProvider.GetAllLogMessages().Single(); Assert.AreEqual("BlobMessageEnqueued", logMessage.EventId.Name); Assert.AreEqual(LogLevel.Debug, logMessage.Level); Assert.AreEqual(7, logMessage.State.Count()); Assert.AreEqual("FunctionIdLogName", logMessage.GetStateValue <string>("functionName")); Assert.AreEqual(context.Blob.BlobClient.Name, logMessage.GetStateValue <string>("blobName")); Assert.AreEqual("testQueueName", logMessage.GetStateValue <string>("queueName")); Assert.AreEqual("testMessageId", logMessage.GetStateValue <string>("messageId")); Assert.AreEqual(context.PollId, logMessage.GetStateValue <string>("pollId")); Assert.AreEqual(context.TriggerSource, logMessage.GetStateValue <BlobTriggerSource>("triggerSource")); Assert.True(!string.IsNullOrWhiteSpace(logMessage.GetStateValue <string>("{OriginalFormat}"))); }
private static BlobTriggerExecutor CreateProductUnderTest(IBlobPathSource input, IBlobETagReader eTagReader) { return CreateProductUnderTest(input, eTagReader, CreateDummyReceiptManager()); }
private BlobTriggerExecutor CreateProductUnderTest(IBlobPathSource input) { return(CreateProductUnderTest(input, CreateDummyReceiptManager())); }
private static BlobTriggerExecutor CreateProductUnderTest(string functionId, IBlobPathSource input, IBlobETagReader eTagReader, IBlobReceiptManager receiptManager, IBlobTriggerQueueWriter queueWriter) { return new BlobTriggerExecutor(String.Empty, functionId, input, eTagReader, receiptManager, queueWriter); }
public BlobListenerFactory(IHostIdProvider hostIdProvider, IQueueConfiguration queueConfiguration, IBackgroundExceptionDispatcher backgroundExceptionDispatcher, IContextSetter<IBlobWrittenWatcher> blobWrittenWatcherSetter, IContextSetter<IMessageEnqueuedWatcher> messageEnqueuedWatcherSetter, ISharedContextProvider sharedContextProvider, TraceWriter trace, string functionId, IStorageAccount hostAccount, IStorageAccount dataAccount, IStorageBlobContainer container, IBlobPathSource input, ITriggeredFunctionExecutor executor, SingletonManager singletonManager) { if (hostIdProvider == null) { throw new ArgumentNullException("hostIdProvider"); } if (queueConfiguration == null) { throw new ArgumentNullException("queueConfiguration"); } if (backgroundExceptionDispatcher == null) { throw new ArgumentNullException("backgroundExceptionDispatcher"); } if (blobWrittenWatcherSetter == null) { throw new ArgumentNullException("blobWrittenWatcherSetter"); } if (messageEnqueuedWatcherSetter == null) { throw new ArgumentNullException("messageEnqueuedWatcherSetter"); } if (sharedContextProvider == null) { throw new ArgumentNullException("sharedContextProvider"); } if (trace == null) { throw new ArgumentNullException("trace"); } if (hostAccount == null) { throw new ArgumentNullException("hostAccount"); } if (dataAccount == null) { throw new ArgumentNullException("dataAccount"); } if (container == null) { throw new ArgumentNullException("container"); } if (input == null) { throw new ArgumentNullException("input"); } if (executor == null) { throw new ArgumentNullException("executor"); } if (singletonManager == null) { throw new ArgumentNullException("singletonManager"); } _hostIdProvider = hostIdProvider; _queueConfiguration = queueConfiguration; _backgroundExceptionDispatcher = backgroundExceptionDispatcher; _blobWrittenWatcherSetter = blobWrittenWatcherSetter; _messageEnqueuedWatcherSetter = messageEnqueuedWatcherSetter; _sharedContextProvider = sharedContextProvider; _trace = trace; _functionId = functionId; _hostAccount = hostAccount; _dataAccount = dataAccount; _container = container; _input = input; _executor = executor; _singletonManager = singletonManager; }