Remove Boot Diagnostics from Storage: mudanças entre as edições

De Wiki Clusterlab.com.br
Ir para navegação Ir para pesquisar
 
(Sem diferença)

Edição atual tal como às 18h37min de 10 de outubro de 2017

#!/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