Old Code:
public string GetDocs()
{
return JsonConvert.SerializeObject(CreateDocumentQuery().ToList());
}
New Code (properly written - while async would work, it gives compile warnings):
public Task<string> GetDocs()
{
return Task.ResultFrom(JsonConvert.SerializeObject(CreateDocumentQuery().ToList());
}
this code converts sync code to callable as async (returns a Task), but does not make the code actually async. You are just adding the async calling overhead.
you need to use cosmos db async access methods if you want to improve performance. if this is for asp.net core, you should always use the async versions and never use the sync methods (ToList(), First(), etc).