In the planning of isolated microgrids aiming for a small carbon footprint, the penetration of renewable energy resources is expected to be high. Energy supply from renewable sources are highly variable and renewable energy sources have relatively a large capital investment although with a positive impact on the environment. In planning and designing of renewable energy based microgrids, we introduce the approach of two-stage stochastic programming to incorporate the various possible scenarios for renewable energy generation and cost in the planning of microgrids to tackle uncertainty. Most planning problems are similar to portfolio optimization problems. We wish to minimize risk in the investment due to uncertain nature of the resources and also minimize the expected cost of investment. Therefore, we introduced the idea of Markovitz (mean-variance) objective function to minimize the effect of uncertainties in the operation of the microgrid. The model is generic and can be used for any location to suit their geographical topography and demand/supply needs. The result shows the economic advantage of using the risk-averse stochastic programming approach over the deterministic approaches while satisfying environmental objectives.