private async Task EnsureLoggersAsync(CancellationToken cancellationToken)
        {
            if (_loggersSet)
            {
                return;
            }

            IStorageAccount dashboardAccount = await _storageAccountProvider.GetDashboardAccountAsync(cancellationToken);

            IFunctionInstanceLogger functionLogger = new FunctionInstanceLogger(_loggerFactory);

            if (dashboardAccount != null)
            {
                // Create logging against a live Azure account.
                IStorageBlobClient dashboardBlobClient = dashboardAccount.CreateBlobClient();
                IPersistentQueueWriter <PersistentQueueMessage> queueWriter = new PersistentQueueWriter <PersistentQueueMessage>(dashboardBlobClient);
                PersistentQueueLogger queueLogger = new PersistentQueueLogger(queueWriter);
                _hostInstanceLogger     = queueLogger;
                _functionInstanceLogger = new CompositeFunctionInstanceLogger(queueLogger, functionLogger);
                _functionOutputLogger   = new BlobFunctionOutputLogger(dashboardBlobClient);
            }
            else
            {
                // No auxillary logging. Logging interfaces are nops or in-memory.
                _hostInstanceLogger     = new NullHostInstanceLogger();
                _functionInstanceLogger = functionLogger;
                _functionOutputLogger   = new ConsoleFunctionOutputLogger();
            }

            _loggersSet = true;
        }
예제 #2
0
        private void EnsureLoggers()
        {
            if (_loggersSet)
            {
                return;
            }

            IFunctionInstanceLogger functionLogger = new FunctionInstanceLogger(_loggerFactory);


            if (_storageAccountProvider.Dashboard != null)
            {
                var dashboardAccount = _storageAccountProvider.GetDashboardStorageAccount();

                // Create logging against a live Azure account.
                var dashboardBlobClient = dashboardAccount.CreateCloudBlobClient();
                IPersistentQueueWriter <PersistentQueueMessage> queueWriter = new PersistentQueueWriter <PersistentQueueMessage>(dashboardBlobClient);
                PersistentQueueLogger queueLogger = new PersistentQueueLogger(queueWriter);
                _hostInstanceLogger     = queueLogger;
                _functionInstanceLogger = new CompositeFunctionInstanceLogger(queueLogger, functionLogger);
                _functionOutputLogger   = new BlobFunctionOutputLogger(dashboardBlobClient);
            }
            else
            {
                // No auxillary logging. Logging interfaces are nops or in-memory.
                _hostInstanceLogger     = new NullHostInstanceLogger();
                _functionInstanceLogger = functionLogger;
                _functionOutputLogger   = new ConsoleFunctionOutputLogger();
            }

            _loggersSet = true;
        }