Azure AI Foundry

The services_ai_foundry module (asc.core) deploys a self-contained Azure AI Foundry environment: an AI Services account and a project, your model deployments, a dedicated resource group and virtual network, and — by default — a private endpoint so the environment reaches the account privately. This page covers choosing models, controlling their spend (a monthly cost ceiling with a key-rotation kill-switch), network access, and what the deploy hands back.

The full list of options and their defaults is on the role page under the Collections index; this guide is the how-to that sits alongside it.

Finding deployable models

The model, version and sku for each entry under services_ai_foundry.models come from the Azure model catalog. List everything deployable in your region with the Azure CLI (no account required):

az cognitiveservices model list --location westeurope \
  --query "[].{model:model.name, version:model.version, skus:join(',', model.skus[].name)}" \
  -o table

Map the output straight onto the config: model → the model field, version → the version field (omit it to take the model’s current default), and pick one of the listed skus for the sku field. name is your own deployment name — how the model is addressed in API calls.

Important

A model/version can appear in the catalog yet still be blocked for new deployments (the deploy fails with ServiceModelDeprecating) once Azure starts retiring that version. Prefer the current/default version of a model. To confirm a specific combination is deployable before committing it to the config, dry-run it against an existing account:

az cognitiveservices account deployment create -g <rg> -n <account> \
  --deployment-name probe --model-format OpenAI \
  --model-name gpt-4o --model-version 2024-11-20 \
  --sku-name GlobalStandard --sku-capacity 1
# then delete the probe:
az cognitiveservices account deployment delete -g <rg> -n <account> --deployment-name probe

Once an account is deployed, az cognitiveservices account list-models -g <rg> -n <account> shows exactly what that account can deploy.

Deployment SKUs

The sku chooses where a model’s tokens are processed and how it is billed. The common options (availability varies per model — use whatever az ... model list reports):

SKU

Meaning

GlobalStandard

Processed in Microsoft’s global capacity. Cheapest and most widely available; one flat price regardless of region.

DataZoneStandard

Processing stays within a data zone (EU or US). Priced slightly higher and varies by region.

Standard

Processing pinned to the deployment’s single region. Priced per region.

Controlling spend

Spend is governed by one number, cost_ceiling_usd — a monthly USD ceiling for the whole account — with two percentages acting on it:

  • alert_at_percent (default 80) emails the ai_alert users — a heads-up, no enforcement.

  • kill_at_percent (default 90) is the hard stop: the account’s API keys are regenerated, which immediately cuts off every agent still using the old key. Logs, data and config are left intact — a hard stop, not a teardown.

services_ai_foundry:
  enabled: true
  cost_ceiling_usd: 100        # monthly USD ceiling for the account
  alert_at_percent: 80         # email heads-up
  kill_at_percent: 90          # rotate the keys (hard stop)
  guardian_interval_minutes: 1 # how often the kill-switch checks spend
  models:
    - name: gpt-4o
      model: gpt-4o
      version: "2024-11-20"
      sku: GlobalStandard

A model’s optional capacity (tokens-per-minute, in thousands) bounds throughput only and defaults high; monthly spend is capped by the kill-switch below, not by capacity.

How the kill is enforced

Two independent mechanisms:

  • Near-real-time (primary). A per-account guardian Logic App runs every guardian_interval_minutes minutes (default 1). Using a shared read-only managed identity it reads each model’s output tokens from the metrics API, multiplies by that model’s output-token price, sums the account total, and at kill_at_percent of the ceiling triggers the pipeline that rotates the keys. A read error fails the run safely without firing.

  • Budget backstop (fallback). An Azure cost budget on the same ceiling posts the same kill at 100 % of the ceiling — price-independent (real billed USD), so it catches anything the token math misses. It lags by hours, which is why it sits above the near-real-time kill.

Because month-to-date spend stays above the threshold after a kill, the guardian stamps a guardianResetAt tag when it fires and the Logic App only counts tokens since max(start-of-month, guardianResetAt) — so the window empties and the switch goes quiet instead of re-firing. Recovery is deliberate: an operator regenerates (re-issues) the keys; the counter is already reset, so the Logic App needs no attention. Raise guardian_interval_minutes to cut Logic App run cost in exchange for a slower reaction. Alert and budget emails go to the users tagged ai_alert in Users and access (files/users.csv).

Output-token pricing

The kill-switch turns token counts into USD, so it needs each model’s output-token price. It is pulled automatically from the Azure Retail Prices API using the model and version you configured, and resolves for most current OpenAI, Meta Llama, Microsoft Phi and xAI Grok models.

Some models cannot be priced automatically: a few are billed under a name that differs from their deployment id (for example DeepSeek), and some are not published in the retail catalog at all (for example Anthropic Claude). In those cases the deploy stops with a clear error naming the model; set price_per_1k_tokens_usd (USD per 1,000 output tokens) on that model. Take the output-token price from the Azure OpenAI or Microsoft Foundry models pricing page — both quote per 1,000,000 tokens, so divide by 1000.

Change detection

The module also adds an activity-log alert that emails the ai_alert users on administrative changes to the Foundry account and its model deployments — a new or changed deployment, a public-access or network change, or a delete. It is scoped to the account, not the whole resource group, so routine networking and budget writes a deploy makes do not generate mail.

Network access

By default (private_endpoint: true) the account is reached over a private endpoint in the module’s own vnet, peered to the core services vnet, with the matching private DNS zones — nothing is exposed publicly. Set public_access: true to additionally expose the public endpoint; it is default-deny, restricted to the CIDRs in ip_allowlist and still protected by the account API key.

Deploy output

At the end of a deploy the summary prints the account endpoint, the API key (shown only when passwords are revealed), the deployed models, and a direct portal link to the project in ai.azure.com so you can open it without hunting through the Azure portal.