Southern and coastal areas of California can grow blue agave. Those in mountainous areas cannot grow blue agave (at least, not outside). According to Plantality, the plant lives in hardiness zones 9 to 12. Both Northern California cities like San Francisco (zone 10a) support this plant, as do all of southern California.
Like most members of the cactus family, this plant prefers full sun. Avoid planting in the shade; your plant will not do well there. Agave requires well-draining soil, so avoid planting near a boggy location (like beside a pond).
If you're growing blue agave in a transitional zone in California---near the outer limits of its preferred planting range---you may need to protect it from winter frosts. Cover your agave plant with burlap if temperatures fall below 20 F so your plant does not die.