1. 安装python3
Azure CLI 已放弃对 Python 2.7 的支持。新版本不再保证在 Python 2.7 环境中正常运行。需要python3.x环境。
python3.8安装
2. 安装azure-cli
# 导入 Microsoft 存储库密钥 rpm --import https://packages.microsoft.com/keys/microsoft.asc # 创建本地azure-cli存储库信息 sh -c 'echo -e "[azure-cli] name=Azure CLI baseurl=https://packages.microsoft.com/yumrepos/azure-cli enabled=1 gpgcheck=1 gpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo' # yum安装azure-cli yum install azure-cli
3. 使用azure-cli
# 选择中国地区登录 az cloud set --name Azurechinacloud # Switched active cloud to 'AzureChinaCloud'. # Use 'az login' to log in to this cloud. # Use 'az account set' to set the active subscription. # 登录到azure的账户 az login # To sign in, use a web browser to open the page https://microsoft.com/deviceloginchina and enter the code F5KA6CFJZ to authenticate.
vim azure_update_password.sh
#/bin/bash
HOST="
host01
host02
"
for host in $HOST
do
az cloud set -n AzureChinaCloud && az login -u username -p password && az account set -s "CLCC.Prod" && az vm user update -u username -p password -g group -n $host
done
# 执行脚本
bash azure_update_password.sh
拉取每日备份巡检数据
##########获取Dev环境的备份列表#################
切换订阅: az account set -s 87f226a5-a980-4b0d-81a7-7a07abd87ed5
拉取表单: az backup item list -g infra-n2 -v backupdevn2 --query '[].{Name:name,healthStatus:properties.healthStatus,lastBackupStatus:properties.lastBackupStatus,protectionState:properties.protectionState,policyName:properties.policyName,lastBackupTime:properties.lastBackupTime}' -o table | grep -v ProtectionStopped
##########获取Uat环境的备份列表#################
切换订阅: az account set -s 20c5948d-b207-49df-91e7-a2ac566fb8a4
拉取表单: az backup item list -g infra -v backupuatn2 --query '[].{Name:name,healthStatus:properties.healthStatus,lastBackupStatus:properties.lastBackupStatus,protectionState:properties.protectionState,policyName:properties.policyName,lastBackupTime:properties.lastBackupTime}' -o table
拉取表单: az backup item list -g infra -v vault521 --query '[].{Name:name,healthStatus:properties.healthStatus,lastBackupStatus:properties.lastBackupStatus,protectionState:properties.protectionState,policyName:properties.policyName,lastBackupTime:properties.lastBackupTime}' -o table | grep -v ProtectionStopped
##########获取Prod环境的备份列表#################
切换订阅: az account set -s 97deefb2-9571-41a1-826d-54d23b044ac0
拉取表单: az backup item list -g KubernetesPlatform -v vault354 --query '[].{Name:name,healthStatus:properties.healthStatus,lastBackupStatus:properties.lastBackupStatus,protectionState:properties.protectionState,policyName:properties.policyName,lastBackupTime:properties.lastBackupTime}' -o table | grep -v ProtectionStopped
VM巡检备份失败处理
如果portal上查看到代理状态unknown,先登录机器查看代理服务是否正常。
如果 Windows Azure Guest Agent 服务未启动,则开启服务。



