Given a quadratic number field $K$, let $w$ be the roots of unity, $d_K$ the discriminant, $h$ the class number and let $\varepsilon$ be the fundamental unit of $O_K$. We have that Dirichlet's Class Number formula is given by \begin{equation} L(1,\left(\frac{d_K}{n}\right))= \begin{cases} \frac{2\pi h}{w\sqrt{|d_K|}} & \text{ if $d_K<0$} \\ \frac{2h\log \varepsilon}{\sqrt{|d_K|}} & \text{ if $d_K>0$}. \end{cases} \end{equation}
I'm now wondering how this expression is well defined, as the definition of the $L$-function is:
Given a character $\chi$ (mod $q$) and for $\Re(s) >1$ we define: \begin{equation} L(s, \chi)= \sum _{n=1}^\infty \frac{\chi (n)}{n^s}. \end{equation}
Is it because we can make an analytic continuation of the $L$-function to $s=1$? And is it tricky to show that the $L$-function with $s=1$ is well defined? How could one show this? Or where should one look to read about this? Can't find much answer as I find most books just don't write explicitly why this holds.