示例#1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JobHostConfiguration"/> class, using the
        /// specified connection string for both reading and writing data as well as Dashboard logging.
        /// </summary>
        /// <param name="dashboardAndStorageConnectionString">The Azure Storage connection string to use.
        /// </param>
        public JobHostConfiguration(string dashboardAndStorageConnectionString)
        {
            if (!string.IsNullOrEmpty(dashboardAndStorageConnectionString))
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this, dashboardAndStorageConnectionString);
            }
            else
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this);
            }

            Singleton = new SingletonConfiguration();

            // add our built in services here
            IExtensionRegistry       extensions       = new DefaultExtensionRegistry();
            ITypeLocator             typeLocator      = new DefaultTypeLocator(ConsoleProvider.Out, extensions);
            IConverterManager        converterManager = new ConverterManager();
            IWebJobsExceptionHandler exceptionHandler = new WebJobsExceptionHandler();

            AddService <IExtensionRegistry>(extensions);
            AddService <StorageClientFactory>(new StorageClientFactory());
            AddService <INameResolver>(new DefaultNameResolver());
            AddService <IJobActivator>(DefaultJobActivator.Instance);
            AddService <ITypeLocator>(typeLocator);
            AddService <IConverterManager>(converterManager);
            AddService <IWebJobsExceptionHandler>(exceptionHandler);

            string value = ConfigurationUtility.GetSettingFromConfigOrEnvironment(Constants.EnvironmentSettingName);

            IsDevelopment = string.Compare(Constants.DevelopmentEnvironmentValue, value, StringComparison.OrdinalIgnoreCase) == 0;
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JobHostConfiguration"/> class, using the
        /// specified connection string for both reading and writing data as well as Dashboard logging.
        /// </summary>
        /// <param name="dashboardAndStorageConnectionString">The Azure Storage connection string to use.
        /// <param name="configuration">A configuration object that will be used as the source of application settings.</param>
        /// </param>
        public JobHostConfiguration(string dashboardAndStorageConnectionString, IConfiguration configuration)
        {
            if (configuration != null)
            {
                ConfigurationUtility.SetConfigurationFactory(() => configuration);
            }

            if (!string.IsNullOrEmpty(dashboardAndStorageConnectionString))
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this, dashboardAndStorageConnectionString);
            }
            else
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this);
            }

            var sasBlobContainer = _storageAccountProvider.InternalSasStorage;

            if (sasBlobContainer != null)
            {
                var uri          = new Uri(sasBlobContainer);
                var sdkContainer = new CloudBlobContainer(uri);

                this.InternalStorageConfiguration = new JobHostInternalStorageConfiguration
                {
                    InternalContainer = sdkContainer
                };
            }

            Singleton  = new SingletonConfiguration();
            Aggregator = new FunctionResultAggregatorConfiguration();

            // add our built in services here
            IExtensionRegistry       extensions       = new DefaultExtensionRegistry();
            ITypeLocator             typeLocator      = new DefaultTypeLocator(ConsoleProvider.Out, extensions);
            IConverterManager        converterManager = new ConverterManager();
            IWebJobsExceptionHandler exceptionHandler = new WebJobsExceptionHandler();

            AddService <IQueueConfiguration>(_queueConfiguration);
            AddService <IConsoleProvider>(ConsoleProvider);
            AddService <ILoggerFactory>(new LoggerFactory());
            AddService <IStorageAccountProvider>(_storageAccountProvider);
            AddService <IExtensionRegistry>(extensions);
            AddService <StorageClientFactory>(new StorageClientFactory());
            AddService <INameResolver>(new DefaultNameResolver());
            AddService <IJobActivator>(DefaultJobActivator.Instance);
            AddService <ITypeLocator>(typeLocator);
            AddService <IConverterManager>(converterManager);
            AddService <IWebJobsExceptionHandler>(exceptionHandler);
            AddService <IFunctionResultAggregatorFactory>(new FunctionResultAggregatorFactory());

            string value = ConfigurationUtility.GetSetting(Host.Constants.EnvironmentSettingName);

            IsDevelopment = string.Compare(Host.Constants.DevelopmentEnvironmentValue, value, StringComparison.OrdinalIgnoreCase) == 0;
        }