Convex analysis is the branch of mathematics devoted to the study of properties of convex functions and convex sets which are always discussed in the real vector spaces, applied to convex optimization, a subdomain of optimization theory, and has an influence on nonlinear analysis and nonlinear DE. In this paper, the concept of convexity is introduced in metric spaces instead of real vector spaces. Basic properties of convex sets in metric spaces are investigated and some interesting properties of convex functions on metric spaces are established.