Consider testing $H_0 : \mu = \mu_0$ vs $H_a : \mu \neq \mu_0$ at level $\alpha$. We then wish to control for the type II error, that is have $P(\text{type II error} \ | \ \mu = \mu_1) = \beta$ for a predetermined $\beta$
Assume $\bar{X}$ is approximately normal with mean $\mu$ and standard deviation $\sigma / \sqrt{n}$. Base a hypothesis test on the standardized variable $Z = \frac{\bar{X}-\mu_0}{\sigma/\sqrt{n}}$, where $\bar{X} = \frac{1}{n} \sum_{i=1}^n X_i$
Then the power function is
$\gamma(\mu) = P(\text{reject} \ H_0 \ | \ \mu) = P(\frac{\bar{X}-\mu_0}{\sigma/\sqrt{n}} \geq -z_{\alpha/2} \ \text{or} \ \frac{\bar{X}-\mu_0}{\sigma/\sqrt{n}} \leq z_{\alpha/2} \ | \ \mu)$
$= P(\frac{\bar{X}-\mu_0}{\sigma/\sqrt{n}} \geq -z_{\alpha/2} \ | \ \mu) + P(\frac{\bar{X}-\mu_0}{\sigma/\sqrt{n}} \leq z_{\alpha/2} \ | \ \mu) = 1-\Phi(z_{\alpha/2} + \frac{\mu_0-\mu}{\sigma/\sqrt{n}}) + \Phi(-z_{\alpha/2} + \frac{\mu_0-\mu}{\sigma/\sqrt{n}})$
where we have solved the inequalities for $\bar{X}$ and restandardized with $\mu_1$.
Then, for $\mu_1 \neq \mu_0$,
$P(\text{type II error} \ | \ \mu=\mu_1) = P(\text{don't reject} \ H_0 \ | \ \mu=\mu_1)$ $=1 - P(\text{reject} \ H_0 \ | \ \mu=\mu_1) = 1 - (1-\Phi(z_{\alpha/2} + \frac{\mu_0-\mu_1}{\sigma/\sqrt{n}}) + \Phi(-z_{\alpha/2} + \frac{\mu_0-\mu_1}{\sigma/\sqrt{n}}))$ $= \Phi(z_{\alpha/2} + \frac{\mu_0-\mu_1}{\sigma/\sqrt{n}}) + \Phi(-z_{\alpha/2} + \frac{\mu_0-\mu_1}{\sigma/\sqrt{n}})$
$ = \beta$
How to solve this for $n$? The answer is supposed to be $n = \bigg(\frac{\sigma (z_{\alpha/2} + z_{\beta})}{\mu_0 - \mu_1}\bigg)^2$ (see Devore & Berk, Modern Mathematical Statistics with Applications, 2012: page 441)
Sidenote: The way I solved it in the one-tailed case was simply by doing
$\Phi(z_{\alpha/2} + \frac{\mu_0-\mu_1}{\sigma/\sqrt{n}}) = \beta$
$\Phi^{-1}\Phi(z_{\alpha/2} + \frac{\mu_0-\mu_1}{\sigma/\sqrt{n}}) = \Phi^{-1}\beta = -z_\beta$, etc