public void Configure(IWebJobsBuilder builder) { string environment = Environment.GetEnvironmentVariable("AZURE_FUNCTIONS_ENVIRONMENT"); builder.Services.AddSingleton(_ => ElasticClientFactory.Create()); builder.Services.AddSingleton(_ => DocumentClientFactory.Create()); builder.Services.AddSingleton <IAttemptService, AttemptService>(); builder.Services.AddSingleton <IZoneService, ZoneService>(); builder.Services.AddSingleton <IToyDistributionProblemRepository, ToyDistributionProblemRepository>(); if (!string.Equals(environment, "Development", StringComparison.OrdinalIgnoreCase)) { builder.Services.AddLogging(loggingBuilder => loggingBuilder .AddSerilog(new LoggerConfiguration() .WriteTo .Elasticsearch(new ElasticsearchSinkOptions(ElasticClientFactory.Url) { AutoRegisterTemplate = true, AutoRegisterTemplateVersion = AutoRegisterTemplateVersion.ESv7, MinimumLogEventLevel = LogEventLevel.Information, ModifyConnectionSettings = connection => { connection.BasicAuthentication(ElasticClientFactory.Username, ElasticClientFactory.Password); return(connection); } }) .CreateLogger())); } }
private async Task InitializeAsync() { _documentClient = DocumentClientFactory.Create(_configuration); _documentDatabase = await _documentClient.CreateDatabaseIfNotExistsAsync(new Database { Id = DocumentDatabaseName }); _documentCollection = await _documentClient.CreateDocumentCollectionIfNotExistsAsync(UriFactory.CreateDatabaseUri(DocumentDatabaseName), new DocumentCollection { Id = DocumentCollectionName }); }
public Service(StatelessServiceContext context) : base(context) { services = new ServiceCollection(); services.AutoRegisterHandlersFromAssemblyOf <CreateProfileCommandHandler>(); services.AddSingleton <IDocumentClient>(DocumentClientFactory.Create()); }
private static Task <FeedResponse <ClimateData> > QueryClimateData() { var client = DocumentClientFactory.Create( Environment.GetEnvironmentVariable("CosmosDbConnectionString")); var queryOptions = new FeedOptions { MaxItemCount = 30, EnableCrossPartitionQuery = true }; IDocumentQuery <ClimateData> dataQuery = client.CreateDocumentQuery <ClimateData>( UriFactory.CreateDocumentCollectionUri( Environment.GetEnvironmentVariable("CosmosDbNameDeviceData"), Environment.GetEnvironmentVariable("CosmosDbCollectionClimateData")), queryOptions).OrderByDescending(d => d.Timestamp).AsDocumentQuery(); return(dataQuery.ExecuteNextAsync <ClimateData>()); }
private static void InitializeDocumentClient() { _documentClient = DocumentClientFactory.Create( Environment.GetEnvironmentVariable("CosmosDbConnectionString")); }
/// <summary> /// Initialize repository and client document /// Must be in this order /// </summary> static DeviceManager() { ComplyNowDoumentDbDocumentClient = DocumentClientFactory.Create(); ComplyNowDoumentDbDeviceRepository = new Repository <Device>(ComplyNowDoumentDbDocumentClient, DocumentDbConfig.DocDbDatabase); }
/// <summary> /// Initialize repository and client document /// Must be in this order /// </summary> static ComplianceManager() { ComplyNowDoumentDbDocumentClient = DocumentClientFactory.Create(); ComplyNowDoumentDbComplianceResponseRepository = new Repository <ComplianceResponseSet>(ComplyNowDoumentDbDocumentClient, DocumentDbConfig.DocDbDatabase); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); services.AddSingleton <IDocumentClient>(DocumentClientFactory.Create()); }