De Wiki Clusterlab.com.br
(dif) ← Edição anterior | Revisão atual (dif) | Versão posterior → (dif)
Ir para navegação
Ir para pesquisar
#!/bin/bash
az vm list --query "[?diagnosticsProfile.bootDiagnostics!=null].[name,vmId,diagnosticsProfile.bootDiagnostics.storageUri]" -o table | \
while read vmid vmname vmstorageuri
do
export AZURE_STORAGE_ACCOUNT=$(echo $vmstorageuri | awk -F . '{print $1}' | awk -F \/ '{print $3}')
case $AZURE_STORAGE_ACCOUNT in
stor01)
export AZURE_STORAGE_ACCESS_KEY=xxxxxxxxxxxxxxxxxxx
;;
stor02)
export AZURE_STORAGE_ACCESS_KEY=xxxxxxxxxxxxxxxxxxx
;;
stor03)
export AZURE_STORAGE_ACCESS_KEY=xxxxxxxxxxxxxxxxxxx
;;
*)
continue
;;
esac
export containername=$(echo bootdiagnostics-$(echo $vmname|sed -e "s/-//g" -e "s/^\(.\{9\}\).*/\1/")-$vmid)
export result=$(az storage container exists -n $containername -o table | tail -n 1 )
#echo $vmid $vmname $containername $resultado
#continue
if [ $result == True ]
then
echo vmstorageuri\;az storage container delete --name $containername
else
echo No Storage account $storageAccountName on $containername
fi
done