环境清理
实验课程结束后,销毁所有 Azure 资源以停止计费。
Terraform 销毁
Section titled “Terraform 销毁”在包含 Terraform 配置的目录中执行以下操作:
# 查看将被销毁的资源terraform plan -destroy
# 销毁所有资源terraform destroyTerraform 将提示确认操作。输入 yes 以继续。
验证清理结果
Section titled “验证清理结果”确认所有资源已被删除:
# 检查资源组是否已消失az group show --name "$(terraform output -raw resource_group_name)" 2>&1 \ | grep -q "ResourceGroupNotFound" \ && echo "Resource group deleted" \ || echo "Resource group still exists"清理本地状态
Section titled “清理本地状态”删除 Terraform 状态文件及缓存文件:
rm -rf .terraform .terraform.lock.hcl terraform.tfstate terraform.tfstate.backup还原 DNS/Hosts 更改
Section titled “还原 DNS/Hosts 更改”如果您在集成过程中修改了 DNS 或 hosts 文件,请还原这些更改:
# 删除 hosts 文件条目(Linux/macOS)sudo sed -i '/<CDN_EDGE_PUBLIC_IP>/d' /etc/hosts如果您创建了 DNS A 记录,请通过您的 DNS 提供商将其删除。