This question already has an answer here:
Credits to Martin.
Fix $a\in A$. Since $d(x,a)\leq d(x,y)+d(y,a)$, taking $\inf\limits_{a\in A}$ we have that $$d(x,A)\leq d(x,y)+d(y,A)$$
By symmetry (i.e. $d(y,x)=d(x,y)$) $$d(y,A)\leq d(x,y)+d(x,A)$$ which gives that $$|f(x)-f(y)|\leq d(x,y)$$Thus $f$ is $1-$Lipschitz continuous, whence it is continuous.$\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\;\blacktriangle$