With the increasing global energy demand, increasing the development and utilization of renewable energy is the key to solve the problem of energy shortage and environmental pollution. The development of intelligent microgrid which mainly absorbs renewable energy is an important means of renewable energy development and utilization, and also an important direction of future development. Firstly, a reliability evaluation index for capacity allocation of grid-connected microgrid is constructed. The mathematical model of each unit of microgrid and the optimal capacity allocation model of grid-connected microgrid are established. Finally, the grey Wolf algorithm is used to solve the problem. Under the same reliability constraints, the optimal configuration results of off-grid and grid-connected microgrids in this region are obtained. The results show that the economic cost of grid-connected microgrid is lower.