The smart grid, perceived as the next generation power grid, uses two-way flow of electricity and information to create a widely distributed automated energy delivery network. By grouping distributed renewable energy generations and loads, a microgrid, which is seen as one of the cornerstones of the future smart grids, can disconnect from the macrogrid and function autonomously. This intentional islanding of generations and loads has the potential to provide a higher local reliability than that provided by the power system as a whole. One of the fundamental issues for a user in an islanded microgrid is how to find the one among the distributed renewable energy resources (DRERs) in a microgrid, which can supply the power most efficiently, effectively and reliably, as its power supply source. This problem is difficult since the power pattern of renewable resources, such as wind and solar, is variable and generally speaking is not easy to accurately predict. In order to solve this problem, we first propose a distributed DRER discovery approach to discover all the available DRERs within a microgrid. Furthermore, based on the online machine learning theory, we propose two distributed algorithms according to the information the user can obtain, in order to compute a good DRER access strategy, with no assumption on what distribution the power patterns of the DRERs follow. We prove that when the time horizon is sufficiently large, on average the upper bound on the gap between the expected profit obtained at each time slot by using the global optimal strategy and that by using our algorithms is arbitrarily small.