private async Task Start() { var settings = Settings(); var connectionPolicy = new ConnectionPolicy { ConnectionMode = ConnectionMode.Direct, ConnectionProtocol = Protocol.Tcp, MaxConnectionLimit = 100 }; this.client = new DocumentClient(new Uri(settings.CosmosEndpointUri), settings.CosmosPrimaryKey, connectionPolicy); var gtfsDataFolder = await DownloadGtfsData(settings); await CreateCollectionIfNotExists(settings); var data = new TransitFeedData(); data.Read(gtfsDataFolder); await WriteDataToCosmos(settings.CosmosDatabaseName, settings.CosmosCollectionName, data); }
private async Task WriteDataToCosmos(string databaseName, string collectionName, TransitFeedData data) { var documentCollection = UriFactory.CreateDocumentCollectionUri(databaseName, collectionName); await CreateDocumentsAsync(documentCollection, data.Stops.ToList()); await CreateDocumentsAsync(documentCollection, data.Trips); }