Proceeding pursuant to CPLR article 78 (transferred to the Appellate Division of the Supreme Court in the Fourth Judicial Department by order and judgment of the Supreme Court, Oneida County [Bernadette T. Clark, J.], entered February 7, 2013) to review a determination finding after a tier II hearing that petitioner had violated an inmate rule.
It is hereby ordered that said appeal insofar as it concerns the declaratory judgment action is unanimously dismissed, the determination is confirmed without costs and the petition is dismissed.
Memorandum: Petitioner commenced this hybrid CPLR article 78 proceeding and declaratory judgment action, seeking to challenge the determination, following a tier II disciplinary hearing, that he violated inmate rule 106.10 (see 7 NYCRR 270.2 [B] [7] [i] [refusal to obey orders]). Supreme Court sua sponte dismissed the declaratory judgment causes of action in the complaint and transferred the CPLR article 78 proceeding to this Court pursuant to CPLR 7804 (g), to review a question of substantial evidence.
We note at the outset that the appeal must be dismissed insofar as it concerns the court’s sua sponte dismissal of the declaratory judgment causes of action (see Mohler v Nardone, 53 AD3d 600, 600 [2008]). No appeal lies as of right “from an ex parte order, including an order entered sua sponte” (Sholes v Meagher, 100 NY2d 333, 335 [2003]; see Obot v Medaille Coll., 82 AD3d 1629, 1630 [2011], appeal dismissed 17 NY3d 756 [2011]), and permission to appeal has not been granted (see CPLR 5701 [c]).
Contrary to petitioner’s contention with respect to the CPLR article 78 proceeding, the determination is supported by substantial evidence. We reject petitioner’s contention that the *1412Hearing Officer erred in refusing to permit him to present evidence concerning his allegedly valid excuse for failing to obey the correction officer’s order. The reason for the order is “irrelevant to the issue of his guilt or innocence” (Matter of Washington v Napoli, 73 AD3d 1300, 1300 [2010]). Indeed, “ ‘[t]he risks inescapably attendant on the refusal of an inmate to carry out even an illegal order of a correction officer are such as to require compliance at the time’ ” the order is given (Matter of Roman v Coughlin, 202 AD2d 1000, 1001 [1994], quoting Matter of Rivera v Smith, 63 NY2d 501, 515 [1984]; see Matter of Hogan v Fischer, 90 AD3d 1544, 1545 [2011], lv denied 19 NY3d 801 [2012]).
We have considered petitioner’s remaining contentions with respect to the CPLR article 78 proceeding, and we conclude that they are without merit. Present — Smith, J.P, Centra, Fahey, Garni and Whalen, JJ.