Proving that the disjoint union of two affine schemes is isomorphic to an affine scheme An "Easy Exercise" from Vakil's text:

Show that the disjoint union of a finite number of affine schemes is also an affine
scheme.

To me it's not so easy.
Let's do it for two affine schemes $(Spec A_i,\mathscr O_{Spec A_i})$ where $i=1,2$.
We need to prove that there is an isomorphism of two ringed spaces:
$(Spec A_1\coprod Spec A_2, \mathscr O)\simeq (Spec_{A_1\times A_2},\mathscr O_{Spec(A_1\times A_2)})$ where $\mathscr O$ is the sheaf that is constructed from the following sheaf on a base $O$ by the procedure described in Vakil's Theorem 2.5.1:  $O(D(f_i))=(A_i)_{f_i}$.
Suppose we know somehow that $Spec A_1\coprod Spec A_2$ and $Spec(A_1\times A_2)$ are homeomorphic via $$\pi: Spec A_1\coprod Spec A_2\to Spec(A_1\times A_2)\\P_1\mapsto P_1\times A_2 \text{ if $P_1$ is a prime ideal of $A_1$}\\P_2\mapsto A_1\times P_2\text{ if $P_2$ is a prime ideal of $A_2$}$$ Then the only thing that remains to be proved is that there is a natural isomorphism of functors $\mathscr O_{Spec A_1\times A_2} \simeq \pi^\ast\mathscr O$, and this is where problems arise.
We need to define a natural transformation $\alpha$ whose components are isomorphisms in the category of rings. Is there a way to reduce this to defining only $\alpha_{D(f)}$ (the components of $\alpha$ at distinguished open sets)? (If we invoke the construction of $\mathscr O$ from Theorem 2.5.1 via tuples of compatible germs, I feel this will become very messy, but it's supposed to be an "easy exercise".)
Even if it's enough to define only $\alpha_{D(f)}$, I'm having trouble doing this. Each $\alpha_{D(f)}$ should be a ring isomorphism $$\alpha_{D(f)}:(A_1\times A_2)_f\to \mathscr O(\pi^{-1}D(f))=O(\pi^{-1}(D(f)))$$
I'm not sure how to simplify $O(\pi^{-1}(D(f)))$ and how to define $\alpha_{D(f)}$. And if it's not enough to define $\alpha_{D(f)}$, how to define $\alpha_U$ in general?
 A: Question: "An "Easy Exercise" from Vakil's text: Show that the disjoint union of a finite number of affine schemes is also an affine scheme. To me it's not so easy."
Answer: There is a "direct" approach: Let $X,Y$ be affine schemes and let the disjoint union (as topological spaces) have the following open sets: A set $U⊆X∪Y$ is open iff $U:=U_1∪U_2$ where $U_1⊆X,U_2⊆Y$ are open sets. By definition: For any open set $U_1∪U_2$ let $\mathcal{O}_{X∪Y}(U_1∪U_2):=\mathcal{O}_X(U_1)⊕\mathcal{O}_Y(U_2)$. It follows $(X∪Y,\mathcal{O}_{X∪Y})$ is a locally ringed space. If $U:=X⊆X∪Y$ it follows $(U,(\mathcal{O}_{X∪Y})_U)≅(X,\mathcal{O}_X)$ and similar for $Y$. Hence $X∪Y$ has an open cover of affine schemes and is therefore a scheme. If $X:=Spec(A),Y:=Spec(B)$ there is a canonical map of schemes $ϕ:X∪Y→Spec(A⊕B)$ induced by the canonical map $Id∈Hom_{rings}(A⊕B,Γ(X∪Y,\mathcal{O}_{X∪Y})) $(HH.Ex.II.2.4). The map $\phi$ is checked to be an isomorphism. This is because the ring $Γ(X∪Y,\mathcal{O}_{X∪Y}):=A⊕B$ by definition. Hence you do not need functors: The disjoint union $X∪Y$ can be constructed directly.
