An optimal operation scheme for a building microgrid with a rooftop greenhouse in islanded mode is proposed in this paper. In islanded mode, the fulfillment of entire demand is challenging due to the absence of connection with the utility grid and the scarcity of local resources. The situation becomes more challenging when one or more pieces of equipment fail during the islanded mode. Therefore, in addition to islanded mode operation, component outage and recovery are also considered in this paper. In order to use the available energy efficiently, prioritization of building loads and control parameters of the greenhouse are proposed. A priority weight matrix is adopted to decide the supply of energy to fulfill the requirements of control parameters in the case of insufficient energy. In addition to the normal operation bounds, new bounds are defined to operate the control parameters if the resources are not sufficient. Additional penalties are imposed if the new bounds are chosen, due to violation of the normal operation range. The microgrid system is rescheduled if any component outage or recovery is detected from the outage point to the end of the scheduling horizon. The performance of the proposed method is evaluated by carrying out several simulations including component outage, component recovery, and simultaneous outage of two or more types of equipment. Numerical simulation results have demonstrated the effectiveness of the proposed operation scheme for optimal operation of building microgrids with a rooftop greenhouse in islanded mode.