A federal appeals court has ruled against an Obama-era policy shielding hundreds of thousands of immigrants who have long lived in the United States from deportation.