Auxiliary services are vital for the operation of a substation. If a contingency affects the distribution feeder that provides energy for the auxiliary services, it could lead to the unavailability of the substation’s service. Therefore, backup systems such as diesel generators are used. Another alternative is the adoption of a microgrid with batteries and photovoltaic generation to supply substation auxiliary services during a contingency. Nevertheless, high battery costs and the intermittence of photovoltaic generation requires a careful analysis so the microgrid capacity is defined in a compromise between the investment and the unavailability reduction of auxiliary services. This paper proposes a method for the capacity sizing of a microgrid with batteries, photovoltaic generation, and bidirectional inverters to supply auxiliary services in substations under a contingency. A set of alternatives is assessed through exhaustive search and Monte Carlo simulations to cater for uncertainties of contingencies and variation of solar irradiation. An unavailability index is proposed to measure the contribution of the integrated hybrid microgrid to reduce the time that the substation is not in operation. Simulations carried out showed that the proposed method identifies the microgrid capacity with the lowest investment that satisfies a goal for the unavailability of the substation service.