An ensemble approach to the structure-function problem in microbial communities