I will present recent results about supersymmetric partition functions of 3d N=2 and 4d N=1 supersymmetric gauge theories with an R-symmetry. Many partition function functions on half-BPS geometric backgrounds can be viewed as expectation values of codimension-2 half-BPS defect operators on CS^1 (in 3d) or CT^2 (in 4d), with C a Riemann surface. This approach greatly simplifies previous computations, and leads to new results.