The large amount of energy consumed by Internet services represents significant and fast-growing financial and environmental costs. Increasingly, services are exploring dynamic methods to minimize energy costs while respecting their service-level agreements (SLAs). Furthermore, it will soon be important for these services to manage their usage of "brown energy" (produced via carbon-intensive means) relative to renewable or "green" energy. This paper introduces a general, optimization-based framework for enabling multi-data-center services to manage their brown energy consumption and leverage green energy, while respecting their SLAs and minimizing energy costs. Based on the framework, we propose policies for request distribution across the data centers. Our policies can be used to abide by caps on brown energy consumption, such as those that might arise from Kyotostyle carbon limits, from corporate pledges on carbon-neutrality, or from limits imposed on services to encourage brown energy conservation. We evaluate our framework and policies extensively through simulations and real experiments. Our results show how our policies allow a service to trade off consumption and cost. For example, using our policies, the service can reduce brown energy consumption by 24% for only a 10% increase in cost, while still abiding by SLAs.