Showing posts with label AI. Show all posts
Showing posts with label AI. Show all posts

Friday, June 20, 2025

AgentCon Perth - 20-06-2025

I had the privilege of helping organize the AgentCon Perth event, which drew an impressive turnout of over 300 AI enthusiasts.

We had an outstanding lineup of speakers who shared insights on Agentic AI and how the Microsoft ecosystem can be leveraged to harness AI capabilities



Thursday, June 19, 2025

Azure Savings Plans vs Reservations: When to Use Which

Commitment-based discounts are among the most impactful cost optimisation levers available in Azure. Both Azure Savings Plans and Azure Reservations offer significant discounts over pay-as-you-go pricing, but they serve different scenarios and the distinction is not always obvious.

This post outlines what each commitment type offers, their key differences, and a practical framework for deciding which to use.

1. What Is an Azure Reservation

An Azure Reservation is a commitment to a specific resource type, size, and region for one or three years. In exchange, Azure offers discounts of up to 72% compared to pay-as-you-go.

Reservations are available for a wide range of services including:

  • Virtual Machines (e.g., Standard_D4s_v5 in Australia East)
  • Azure SQL Database and Managed Instance
  • Azure Cosmos DB
  • Azure Blob Storage (reserved capacity)
  • Azure Machine Learning compute clusters

The key characteristic of a reservation is its specificity. A reservation for a Standard_D4s_v5 in Australia East applies only to that VM size in that region. It does not apply to a Standard_D8s_v5 or a VM in Southeast Asia.

2. What Is an Azure Savings Plan

Azure Savings Plans, introduced in 2022, offer a more flexible commitment model. Rather than committing to a specific resource, you commit to a fixed hourly spend (for example, $5/hour) across eligible compute services for one or three years.

The savings plan discount applies automatically to any eligible compute usage across VM sizes, regions, and even across Azure services such as AKS, Azure Functions, and App Service.

Savings Plan discounts are slightly lower than equivalent reservation discounts (typically 15–65% depending on the term and service), in exchange for the flexibility.

3. Key Differences

DimensionReservationSavings Plan
CommitmentSpecific resource, size, regionHourly spend amount
FlexibilityFixed to a specific resource and regionApplies across VM sizes, regions, and services
DiscountUp to 72%Up to 65%
Best forStable, predictable workloadsDynamic or diverse compute workloads
Exchange/RefundAllowed with limitsNot exchangeable

Use a Reservation when:

  • The workload has run at consistent size and scale for at least 60 days
  • The resource is tied to a specific region due to latency or data residency requirements
  • The service is reservation-eligible and you can accurately forecast utilisation above 80%

Use a Savings Plan when:

  • The workload spans multiple VM sizes or regions (common with autoscaling environments)
  • The team is early in cloud maturity and forecasting specific resource consumption is not yet reliable
  • You need a simpler commitment model that covers future architectural changes

5. Reviewing Recommendations Before Purchasing

Azure Advisor provides reservation and savings plan recommendations based on your actual usage history. I recommend reviewing these before making any commitment.

Navigate to Azure Advisor > Cost to see recommendations including estimated annual savings, recommended term, and utilisation confidence based on the past 30 days of usage.

Summary

Reservations deliver the highest discount for stable, well-understood workloads. Savings Plans offer flexibility for environments that change frequently. In practice, a combination of both often yields the best outcome: reservations for core infrastructure and savings plans for dynamic compute. Azure Advisor removes much of the guesswork by surfacing recommendations backed by actual usage data.

Thursday, May 8, 2025

Setting Up Azure Monitor Alerts for AI Workload Anomalies

As organizations adopt AI workloads on Azure, the need for targeted monitoring becomes critical. Unlike traditional applications, AI services such as Azure OpenAI and Azure Machine Learning can generate significant cost spikes from a single misconfigured request or an idle compute cluster left running overnight.

Azure Monitor provides the tooling to detect and respond to these anomalies before they appear on the monthly invoice. This post walks through configuring alerts specifically for Azure OpenAI and Azure Machine Learning workloads.

1. Metric Alerts for Azure OpenAI Service

Azure OpenAI exposes several platform metrics that are useful for anomaly detection. The most relevant for cost monitoring are Processed Prompt Tokens and Processed Completion Tokens.

To create a metric alert:

  1. Navigate to your Azure OpenAI resource > Monitoring > Alerts > + Create > Alert rule
  2. Under Condition, select Add condition and search for Processed Completion Tokens
  3. Set Threshold type to Dynamic to allow Azure to learn the baseline from historical traffic
  4. Set Aggregation to Total over a 5-minute evaluation window
  5. Configure Alert sensitivity to Medium as a starting point

Dynamic thresholds are preferable for AI workloads because token consumption varies naturally with legitimate traffic. Static thresholds tend to generate excessive false positives during expected peak periods.

2. Log Alerts for Azure Machine Learning Compute

Metric alerts cover throughput anomalies, but log-based alerts can detect issues such as a compute cluster that failed to scale down after a training job completed.

Following is a KQL query that detects compute clusters that have been in a running state without an active job for more than two hours:

AmlComputeClusterEvent
| where TimeGenerated > ago(2h)
| where EventType == "ClusterStateChanged"
| where NewState == "Steady"
| summarize LastEvent = max(TimeGenerated) by ClusterName
| where LastEvent < ago(2h)

Navigate to Log Analytics workspace > Logs, validate the query, then select + New alert rule from the query toolbar to convert it into a scheduled log alert.

3. Configuring Action Groups

Action Groups define who gets notified when an alert fires. A well-configured action group ensures the right person can respond promptly.

Navigate to Azure Monitor > Alerts > Action groups > + Create and configure the following notification types:

  • Email/SMS — for the owning engineering team
  • Azure Function — for automated remediation such as scaling down an idle cluster
  • Webhook — for integration with Microsoft Teams channels or third-party incident tools

Once created, assign the action group to both the metric alert and the log alert rule configured in the previous steps.

4. Using Alert Processing Rules to Reduce Noise

As the number of alert rules grows, Alert Processing Rules help manage notification fatigue. These rules can suppress alerts during scheduled maintenance windows or route different alert severities to different action groups.

Navigate to Azure Monitor > Alerts > Alert processing rules > + Create to define suppression schedules and routing logic based on resource tags or subscription scope.

Summary

Standard monitoring configurations are not sufficient for AI workloads. Configuring dynamic metric alerts for Azure OpenAI token consumption and log-based alerts for Azure ML compute idle time ensures that anomalies are caught early, before they translate into an unexpected billing outcome.

Sunday, April 27, 2025

Presentation - Designing AI-Powered APIs on Azure: Best Practices& Considerations

I had the privilege of delivering a session at the Perth Global AI Bootcamp at Microsoft. My topic was Designing AI-Powered APIs on Azure: Best Practices& Considerations

We explored various aspects of the AI solution design, aligning closely with the principles of the Azure Well-Architected Framework.

Following is the presentation I conducted

Following are few snaps from the event










Wednesday, April 2, 2025

Managing Azure Costs in an AI-Adopted Organization

As organizations increasingly adopt AI workloads on Azure, cost management becomes a critical concern. Unlike traditional cloud workloads, AI services introduce unique cost drivers that can lead to unexpected expenses if not properly governed.

Cost optimization is a key pillar of the Azure Well-Architected Framework. This post outlines a structured approach to managing Azure costs specifically for organizations running AI workloads.

1. Understanding AI-Specific Cost Drivers

Before applying any cost controls, it is important to understand what makes AI workloads different from standard cloud resources.

Azure OpenAI Service charges per token; input and output tokens are billed separately. Output tokens are non-deterministic, meaning a single user prompt can generate significantly more output than anticipated, especially at scale. I have seen organizations underestimate this by 2–3x during initial deployments.

Azure Machine Learning compute (particularly GPU-backed clusters) is billed by the hour regardless of whether a training job is actively running. A cluster left idle overnight can accumulate hundreds of dollars in unnecessary spend before anyone notices.

Following is a summary of the primary cost drivers to monitor:

  • Azure OpenAI Service – token consumption (input/output)
  • Azure Machine Learning – compute clusters (GPU/CPU), storage
  • Azure Kubernetes Service – node pools running AI inference workloads
  • Azure Monitor / Log Analytics – ingestion costs from AI application telemetry

2. Instrument Token Usage from Day One

The most effective way to control Azure OpenAI costs is to capture usage data before optimizing it. The Azure OpenAI API response includes token counts for every request. These should be logged alongside the calling service, user context, and model version.

Following is the relevant fields to capture from each API response:

{
  "usage": {
    "prompt_tokens": 120,
    "completion_tokens": 340,
    "total_tokens": 460
  }
}

Once this data is flowing into Azure Log Analytics or Application Insights, you can build cost attribution reports per feature, per team, or per user segment. This is a prerequisite for any meaningful cost governance conversation.

3. Right-Size Compute for AI Workloads

Not every AI workload requires GPU compute. This is one of the most common and costly misconfigurations I have encountered.

For model training, GPU clusters are appropriate. However, for inference workloads, particularly with smaller models, Standard_D or Standard_F series CPU instances are often sufficient and cost significantly less than GPU-backed VMs.

For Azure Machine Learning compute clusters, ensure the following settings are configured:

  • Set min_instances = 0 to allow clusters to scale to zero when idle
  • Configure idle shutdown on compute instances (15–30 minutes for development workloads)
  • Use low-priority (spot) compute for training jobs that are restartable, reducing compute costs by 60–80%

For organizations with predictable, sustained inference workloads, Azure Reservations and Provisioned Throughput Units (PTUs) for Azure OpenAI can provide significant savings compared to pay-as-you-go pricing.

4. Implement a Tagging Strategy for Cost Attribution

Without consistent resource tagging, it is impossible to attribute AI costs to the correct team, product, or cost center. This becomes a governance problem quickly in larger organizations.

I recommend enforcing the following tags on all AI-related resources using Azure Policy:

TagPurpose
workloadThe product or feature the resource supports
environmentprodstaging, or dev
teamOwning team for chargeback
cost-centerFinance reference for billing

Azure Policy can be configured to audit or deny resource deployments that are missing required tags. Without this enforcement, tagging coverage will be inconsistent: complete for resources created carefully, and absent for those created under pressure.

5. Configure Budgets and Anomaly Alerts

Azure Cost Management supports budget alerts at the subscription, resource group, and resource level. For AI workloads, I recommend setting alerts at 50%, 80%, and 100% of the monthly budget rather than relying on a single threshold.

Following is the recommended alert configuration for an AI workload resource group:

  • 50% alert – informational, sent to the engineering team
  • 80% alert – actionable, triggers a review of current spend trends
  • 100% alert – escalation, sent to both engineering and management

In addition to budget alerts, enable Cost anomaly alerts under Azure Cost Management. This feature detects unusual spend patterns. For example, a misconfigured retry loop hammering an Azure OpenAI endpoint will trigger an alert before the monthly total is significantly impacted.

Summary

AI workloads introduce cost patterns that are fundamentally different from traditional cloud resources. Token-based billing, GPU compute, and high-volume telemetry all require specific governance controls to prevent cost overruns.

By instrumenting usage data early, right-sizing compute, enforcing tagging through Azure Policy, and configuring meaningful budget alerts, organizations can maintain visibility and control over their AI spend, with no surprises when the invoice arrives.