Skip to content

Instantly share code, notes, and snippets.

@robdmoore
Created August 31, 2014 06:14
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robdmoore/f82d74d4c377d4f3755e to your computer and use it in GitHub Desktop.
Save robdmoore/f82d74d4c377d4f3755e to your computer and use it in GitHub Desktop.
List all documents in an Azure DocumentDB Document Collection
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