Skip to content

Commit

Permalink
Added power state check to aks stop script
Browse files Browse the repository at this point in the history
  • Loading branch information
adamrushuk committed Nov 7, 2020
1 parent 6d47f6b commit 93c126a
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions scripts/stop_aks_cluster.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ az extension add --name aks-preview
# Update the extension to make sure you have the latest version installed
az extension update --name aks-preview

# Stop AKS Cluster
message="Stopping AKS Cluster: [$AKS_CLUSTER_NAME]"
echo -e "\nSTARTED: $message..."
az aks stop --name "$AKS_CLUSTER_NAME" --resource-group "$AKS_RG_NAME"
echo -e "FINISHED: $message."
# Check AKS power state
aks_power_state=$(az aks show --name "$AKS_CLUSTER_NAME" --resource-group "$AKS_RG_NAME" --output tsv --query 'powerState.code')
echo -e "\n[$AKS_CLUSTER_NAME] AKS Cluster power state is [$aks_power_state]."

if [ "$aks_power_state" == "Stopped" ]; then
echo -e "\nSKIPPING: $AKS_CLUSTER_NAME AKS Cluster is already stopped."
else
# Stop AKS Cluster
message="Stopping AKS Cluster: [$AKS_CLUSTER_NAME]"
echo -e "\nSTARTED: $message..."
az aks stop --name "$AKS_CLUSTER_NAME" --resource-group "$AKS_RG_NAME"
echo -e "FINISHED: $message."
fi

0 comments on commit 93c126a

Please sign in to comment.