Azure — alert when approaching a subscription quota
An Azure subscription approaches a quota (vCPU per region, public IPs, storage accounts) — the next terraform apply fails with 429/ItemNotFound. Quota raises go via a support ticket, you need a head start.
Recipe
#!/usr/bin/env bash
# /etc/cron.d/az-quota
# 0 */6 * * * root /opt/az-quota.sh
REGION=${REGION:-westeurope}
WARN_PCT=${WARN_PCT:-80}
# Compute quota only — extend with network/storage as needed
HOTSPOTS=$(az vm list-usage --location "$REGION" -o json \
| jq --argjson w "$WARN_PCT" '
[.[] | select(.limit > 0 and (.currentValue / .limit * 100) > $w) |
{name: .localName.value, used: .currentValue, limit: .limit,
pct: ((.currentValue / .limit * 100) | floor)}]')
COUNT=$(echo "$HOTSPOTS" | jq 'length')
if [ "${COUNT:-0}" -gt 0 ]; then
SUMMARY=$(echo "$HOTSPOTS" | jq -r '.[] | "\(.name)=\(.pct)%"' | head -5 | tr '\n' ',')
curl -fsS "$HEARTBEAT_URL" --data-urlencode "quota_warn=$COUNT,examples=$SUMMARY"
exit 2
fi
echo "OK (no quotas above ${WARN_PCT}%)"
Same thing in Enterno.io
Wire to an Enterno heartbeat — catch 80 % quota a week or two before the hard stop, with time to open the Azure ticket.
Related recipes
A GCP project quota (CPU, IPs, persistent disks) creeps toward the limit. The next terraform plan fails with RESOURCE_EXHAUSTED. Quota requests take 1–2 days — needs head start.
Ensure your site returns 2xx every minute, alert to Slack/Telegram on failure.
Minimal script that checks an SSL certificate and alerts 14 days before expiry.