I want to evaluate the following,
$$I(z)=\int_0^{\pi}\cos(z\sin x)e^{\cos (x)}\ dx,\quad z\in\mathbb{N}$$
using Bessel functions. My attempt where I ended up with a divergent series is below. I think the error comes from the switching of integration and summation, but I hope there is a way around this.
Using the known expansion in terms of the Bessel function $J_\alpha(z)$, $$\cos(z \sin x)=J_0(z)+2\sum_{k=1}^\infty J_{2k}(z)\cos(2kx)$$ $$\begin{align*}I(z)=\int_0^{\pi}\cos(z\sin x)e^{\cos (x)}\ dx&=\int_0^\pi J_0(z)e^{\cos(x)}\ dx+2\int_0^\pi \sum_{k=1}^\infty J_{2k}(z)\cos(2kx)e^{\cos(x)}\ dx\\&=\underbrace{J_0(z)\int_0^\pi e^{\cos(x)}\ dx}_{T_1}+\underbrace{2\sum_{k=1}^\infty J_{2k}(z)\int_0^\pi\cos(2kx)e^{\cos(x)}\ dx}_{T_2}.\end{align*}$$ We evaluate $T_1$ by subbing $z=e^{ix}$ and integrating over a circle contour $\gamma$ surrounding the origin in a counter clockwise sense, $$\begin{align*}J_0(z)\int_0^\pi e^{\cos(x)}\ dx&=\frac{J_0(z)}{2}\int_{-\pi}^\pi e^{\cos(x)}\ dx \\&=\frac{J_0(z)}{2}\int_{-\pi}^\pi \exp\left(\frac{e^{ix}+e^{-ix}}{2}\right)\frac{ie^{ix}}{ie^{ix}}\ dx \\&=\frac{J_0(z)}{2i}\oint_\gamma\frac{1}{z}\exp\left(\frac{z+z^{-1}}{2}\right)\ dz\end{align*}$$ the only singularity is at $z=0$, and we find the residue at the point by extracting the coefficient of the $z^{-1}$ term in the laurent expansion of the integrand, $$[z^{-1}]\left(\frac{1}{z}\exp\left(\frac{z+z^{-1}}{2}\right)\right)=[z^{-1}]\left(\frac{1}{z}\sum_{n=0}^\infty\frac{z^n}{n!2^n}\sum_{n=0}^\infty\frac{z^{-n}}{n!2^n}\right)=\sum_{n=0}^\infty\frac{1}{(n!2^{n})^2}=I_0(1)$$ where $I_0(z)$ is the Modified Bessel function and $[z^n]f(z)$ is the coefficient of $z^n$ in $f$. Thus by Cauchy's formula, $$T_1=\pi J_0(z)I_0(1).$$ For $T_2$ we can evaluate the integral in terms of the Modified Bessel function again, given the representation, $$I_\alpha(z)=\frac{1}{\pi}\int_0^\pi e^{z\cos(x)}\cos(\alpha x)\ dx-\frac{\sin(\alpha \pi)}{\pi}\int_0^{+\infty} e^{-z\cosh(x)-\alpha x}\ dx$$ we have, $$2\sum_{k=1}^\infty J_{2k}(z)\int_0^\pi\cos(2kx)e^{\cos(x)}\ dx=2\sum_{k=1}^\infty J_{2k}(z)\left(\pi I_{2k}(1)+\sin(2\pi k)\int_0^{+\infty} e^{-\cosh(x)-2kx}\ dx\right)$$ the integral on the RHS vanishes due to the $\sin(2\pi k)$ factor, $$T_2=2\pi\sum_{k=1}^\infty J_{2k}(z)I_{2k}(1)$$ hence, $$I(z)=\pi J_0(z)I_0(1)+2\pi\sum_{k=1}^\infty J_{2k}(z)I_{2k}(1)$$
Edit: The convergence of the series above is as follows.
For fixed $z$ and large $k$, $$J_{2k}(z)\sim\frac{1}{\sqrt{4\pi k}}\left(\frac{ez}{4k}\right)^{2k},\quad I_{2k}(1)\sim\frac{1}{\sqrt{4\pi k}}\left(\frac{e}{4k}\right)^{2k}\\ J_{2k}(z)I_{2k}(1)\sim\frac{1}{4\pi k}\left(\frac{e}{4k}\right)^{4k}z^{2k}\sim\frac{1}{k^k}$$ which is convergent. Here we have made use of asymptotic expansions $(10.19.1)$ and $(10.14.1)$ as suggested in the comments.
Neumann's addition formula states that $$J_{0} \left(\sqrt{\alpha^{2}+\beta^{2}-2\alpha \beta \cos \phi} \right) = J_{0}(\alpha)J_{0}(\beta) + 2 \sum_{k=1}^{\infty} J_{k}(\alpha) J_{k}(\beta) \cos(k \phi), $$ which holds for complex values of the parameters.
A proof can be found in Chapter XI, section 11.2, of A Treatise on the Theory of Bessel Functions.
(The formula is written in shorthand notation in the textbook.)
We can use this formula to show that indeed $$ I(z) = \pi J_0(z)I_0(1)+2\pi\sum_{k=1}^\infty J_{2k}(z)I_{2k}(1) = \pi J_{0} \left(\sqrt{z^{2}-1} \right)$$
Letting $\alpha =z$, $\beta =i$, and $\phi = \frac{\pi}{2}$, we have
$$ \begin{align} J_{0} \left( \sqrt{z^{2}-1} \right) &= J_{0}(z) J_{0}(i) + 2 \sum_{k=1}^{\infty}J_{k}(z) J_{k}(i) \cos \left(\frac{k\pi}{2} \right) \\ &=J_{0}(z) I_{0}(1) + 2 \sum_{k=1}^{\infty}J_{k}(z) \, i^{k}I_{k}(1) \cos \left(\frac{k\pi}{2} \right) \\ &= J_{0}(z) I_{0}(1) + 2 \sum_{k=1}^{\infty} J_{2k}(z) \, i^{2k} I_{2k}(1) (-1)^{k} \\ &=J_{0}(z) I_{0}(1) + 2 \sum_{k=1}^{\infty}J_{2k}(z) I_{2k}(1). \end{align}$$
Therefore, $I(z) = \pi J_{0}\left(\sqrt{z^{2}-1} \right).$