Created
August 31, 2014 06:14
-
-
Save robdmoore/f82d74d4c377d4f3755e to your computer and use it in GitHub Desktop.
List all documents in an Azure DocumentDB Document Collection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Task.WaitAll(new[] {DoStuff()}); | |
} | |
private static async Task DoStuff() | |
{ | |
var client = new DocumentClient(new Uri("https://<documentdbtenant>.documents.azure.com:443/"), | |
"<authkey>"); | |
var db = (await client.ReadDatabaseFeedAsync()).Single(d => d.Id == "Diagnostics"); | |
var col = (await client.ReadDocumentCollectionFeedAsync(db.CollectionsLink)).Single(c => c.Id == "Logs"); | |
var docs = client.CreateDocumentQuery(col.DocumentsLink).ToList(); | |
foreach (var document in docs) | |
{ | |
Console.WriteLine(document.ToString()); | |
} | |
Console.ReadLine(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment