Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/CI-TOPOLOGY.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ AZURE <tenant>
│ Key Vault deploy secrets and CI database secrets
│ Storage account manifests that Flux applies to the cluster
│ HorizonDB cluster the environment's database
│ Foundry account models and embeddings
│ Foundry account models and embeddings. The deploy leaves the
│ account itself as it is
│ (`FOUNDRY_ACCOUNT_EXISTING=true`) and manages
│ only its model deployments and key secret
│
├─ CI DATABASE
│ HorizonDB cluster used by live tests only, separate from the
Expand Down
14 changes: 8 additions & 6 deletions .github/DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,15 @@ ignored directory and cleans it up.
| `CI_TEST_ENV_JSON` | Live test credentials, including a Copilot-enabled token |
| `MODEL_PROVIDERS_JSON` | CI catalog, separate from the portal catalog |

Four plain switches can also be variables of the `azure-deploy` environment:
`WORKSPACES_ENABLED`, `USER_POOL_MIN_COUNT`, `PILOTSWARM_NATIVE_SUBAGENTS` and
`AKS_ENTRA_ID_AUTH`. A set variable wins over the same key in
`AZURE_DEPLOY_ENV`. `AKS_ENTRA_ID_AUTH=true` turns on Microsoft Entra ID
sign-in for the cluster's API; see
Five plain switches can also be variables of the `azure-deploy` environment:
`WORKSPACES_ENABLED`, `USER_POOL_MIN_COUNT`, `PILOTSWARM_NATIVE_SUBAGENTS`,
`AKS_ENTRA_ID_AUTH` and `FOUNDRY_ACCOUNT_EXISTING`. A set variable wins over
the same key in `AZURE_DEPLOY_ENV`. `AKS_ENTRA_ID_AUTH=true` turns on Microsoft
Entra ID sign-in for the cluster's API; see
[cluster sign-in](../deploy/providers/azure/README.md#cluster-sign-in-with-microsoft-entra-id).
It cannot be turned off again on a cluster.
It cannot be turned off again on a cluster. `FOUNDRY_ACCOUNT_EXISTING=true`
makes the deploy leave the Foundry account as it is; see
[a Foundry account that already exists](../deploy/providers/azure/README.md#a-foundry-account-that-already-exists).

Key Vault holds generated database passwords/URLs and the Foundry key. Kubernetes
consumes runtime credentials through CSI/Secret projections. The CI cluster is
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,5 @@ jobs:
WORKSPACES_ENABLED: ${{ vars.WORKSPACES_ENABLED }}
USER_POOL_MIN_COUNT: ${{ vars.USER_POOL_MIN_COUNT }}
AKS_ENTRA_ID_AUTH: ${{ vars.AKS_ENTRA_ID_AUTH }}
FOUNDRY_ACCOUNT_EXISTING: ${{ vars.FOUNDRY_ACCOUNT_EXISTING }}
PILOTSWARM_NATIVE_SUBAGENTS: ${{ vars.PILOTSWARM_NATIVE_SUBAGENTS }}
1 change: 1 addition & 0 deletions .github/workflows/release-tarballs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,5 @@ jobs:
WORKSPACES_ENABLED: ${{ vars.WORKSPACES_ENABLED }}
USER_POOL_MIN_COUNT: ${{ vars.USER_POOL_MIN_COUNT }}
AKS_ENTRA_ID_AUTH: ${{ vars.AKS_ENTRA_ID_AUTH }}
FOUNDRY_ACCOUNT_EXISTING: ${{ vars.FOUNDRY_ACCOUNT_EXISTING }}
PILOTSWARM_NATIVE_SUBAGENTS: ${{ vars.PILOTSWARM_NATIVE_SUBAGENTS }}
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Changelog

## Unreleased

**Upgrade: nothing to do.** Deploy scripts only: no package change, no
migration and no orchestration version.

- **Azure deploy: use a Foundry account that already exists
(`FOUNDRY_ACCOUNT_EXISTING`):** With `FOUNDRY_ACCOUNT_EXISTING=true` the
stamp no longer creates or updates its Foundry account
(`<RESOURCE_PREFIX>-aif`). It still manages the model deployments, the
`azure-oai-key` secret and the data-plane role. Use it for an account the
stamp does not own, or one whose settings must not be sent again, for
example when a subscription policy refuses an account that allows key
sign-in while the HorizonDB embedding loop still needs the key. The default
(`false`) keeps the stamp-owned account. The account's definition moved from
`foundry.bicep` to the new `foundry-account.bicep`; a stamp that leaves the
switch off sends the same account as before. The deploy workflows read the
switch from a variable of the `azure-deploy` environment.
- **Azure deploy: a policy denial names what was refused:** The deploy
Action's one-line diagnostic now says whether Azure Policy refused the
Foundry account or the AKS cluster, and names the settings to look at. It
still prints no resource or policy name.
- **Azure deploy: a person can name their own identity
(`DEPLOY_PRINCIPAL_TYPE=User`):** `DEPLOY_PRINCIPAL_ID` was read as a
service principal only. With `DEPLOY_PRINCIPAL_TYPE=User` a person can give
their own object ID when the Azure CLI cannot look it up
(`az ad signed-in-user show` blocked by a sign-in policy), so `base-infra`
still grants them the deployer roles. The default stays `ServicePrincipal`.

## 0.8.21 — 2026-11-30

**Upgrade: rolling deploy from 0.8.20 is safe once no session older than
Expand Down
40 changes: 40 additions & 0 deletions deploy/providers/azure/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,46 @@ the app URL, then worker and portal mount the versioned URL. Database
password authentication is independent of Blob managed identity, which
remains enabled.

## A Foundry account that already exists

By default the stamp owns its Foundry account: every `base-infra` deploy sends
the account's full definition, and Azure creates or updates it.

Set `FOUNDRY_ACCOUNT_EXISTING=true` when the stamp must not do that. Two
cases:

- The account belongs to someone else, or was made by hand.
- The account must stay as it is. Example: a subscription policy now refuses
an account that allows key sign-in, but something still uses the key (the
HorizonDB embedding loop sends it on every call). A deploy that sends the
account again is refused. A deploy that leaves the account alone is not.

```
FOUNDRY_ACCOUNT_EXISTING=false (default)
1. base-infra creates or updates the account <RESOURCE_PREFIX>-aif
2. base-infra creates the model deployments, the key secret, the role

FOUNDRY_ACCOUNT_EXISTING=true
1. base-infra does not send the account at all
2. base-infra creates the model deployments, the key secret, the role
```

With the switch on:

- The account `<RESOURCE_PREFIX>-aif` must exist in the stamp's resource
group. The deploy fails with "resource was not found" when it does not.
- `FOUNDRY_SKU` and `FOUNDRY_LOCATION` do nothing. The account keeps its SKU,
region and network settings.
- `FOUNDRY_AUTH_MODE` no longer turns key sign-in on or off on the account.
It still decides what the stamp uses: `key` copies the account key to the
`azure-oai-key` secret (the account must allow keys), `entra` gives the
worker identity the Cognitive Services OpenAI User role.
- Model deployments still follow the stamp's Foundry deployments JSON.

In Actions, set it as a variable of the `azure-deploy` environment. The
switch can be turned off again: the next deploy then sends the account's
definition as before.

## Cluster sign-in with Microsoft Entra ID

`AKS_ENTRA_ID_AUTH=true` turns on Microsoft Entra ID sign-in for the cluster's
Expand Down
10 changes: 10 additions & 0 deletions deploy/providers/azure/envs/template.env
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@ FOUNDRY_AUTH_MODE=key
# stamp; set this when the stamp region lacks the required model deployments.
FOUNDRY_LOCATION=

# true: the account `${RESOURCE_PREFIX}-aif` already exists and the stamp
# never creates or updates it. Its SKU, region, network and local-auth
# settings stay as they are, so FOUNDRY_SKU, FOUNDRY_LOCATION and the
# local-auth part of FOUNDRY_AUTH_MODE do nothing. The stamp still manages the
# model deployments, the `azure-oai-key` secret and the data-plane role. Use
# it for an account the stamp does not own, or one whose settings must not be
# sent again. A GitHub variable of the deploy environment with this name wins
# over this line.
FOUNDRY_ACCOUNT_EXISTING=false

# Path (relative to repo root or absolute) to a JSON array file describing
# the model deployments to create under the Foundry account. Threaded into
# the bicep deploy as `--parameters foundryDeployments=@<file>`. The
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@
"foundryLocation": {
"value": "${FOUNDRY_LOCATION}"
},
"foundryAccountExisting": {
"value": ${FOUNDRY_ACCOUNT_EXISTING}
},
"vpnGatewayEnabled": {
"value": ${VPN_GATEWAY_ENABLED}
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// ==============================================================================
// PilotSwarm BaseInfra — the Azure AI Foundry account (Cognitive Services).
//
// main.bicep deploys this file only when the stamp owns the account
// (`foundryAccountExisting = false`, the default). With
// `foundryAccountExisting = true` this file is skipped: the account must
// already exist, and the stamp does not create or update it.
//
// What lives inside the account (model deployments, the Key Vault key secret,
// the data-plane role) is in foundry.bicep. That file reads the account as an
// existing resource in both cases.
//
// Per-region: a single Foundry account lives in this RG with a custom
// subdomain matching the resource name.
// ==============================================================================

@description('Azure region. Foundry resources are zonal-ish (data-plane lands in this region).')
param location string

@description('Foundry account name. Globally unique within Cognitive Services. Drives the customSubdomainName so the data-plane URL is `https://<name>.openai.azure.com` / `https://<name>.cognitiveservices.azure.com`.')
param accountName string

@description('SKU name. S0 is the only generally-available SKU for AIServices accounts; F0 is preview/free-tier and not supported for paid model deployments.')
@allowed([
'S0'
])
param sku string = 'S0'

@description('Data-plane auth mode. `entra` disables local auth on the account. `key` keeps the legacy account-key path.')
@allowed([
'key'
'entra'
])
param authMode string = 'key'

resource account 'Microsoft.CognitiveServices/accounts@2024-10-01' = {
name: accountName
location: location
kind: 'AIServices'
sku: {
name: sku
}
identity: {
type: 'SystemAssigned'
}
properties: {
customSubDomainName: accountName
publicNetworkAccess: 'Enabled'
networkAcls: {
defaultAction: 'Allow'
}
disableLocalAuth: authMode == 'entra'
}
}

output accountName string = account.name
63 changes: 22 additions & 41 deletions deploy/providers/azure/services/base-infra/bicep/foundry.bicep
Original file line number Diff line number Diff line change
@@ -1,46 +1,43 @@
// ==============================================================================
// PilotSwarm BaseInfra — Azure AI Foundry (Cognitive Services account).
// PilotSwarm BaseInfra — what lives inside the Azure AI Foundry account.
//
// Optional, gated by `foundryEnabled` in main.bicep. Provisions a single
// `Microsoft.CognitiveServices/accounts` (kind=AIServices) plus N model
// deployments under it, all sharing one endpoint and auth surface.
// Optional, gated by `foundryEnabled` in main.bicep. Provisions N model
// deployments under one `Microsoft.CognitiveServices/accounts`
// (kind=AIServices), all sharing one endpoint and auth surface, plus the Key
// Vault key secret and the data-plane role.
//
// Per-region: a single Foundry account lives in this RG with a custom
// subdomain matching the resource name. All deployments are siblings; the
// base `model_providers.json` is rewritten at manifest-staging time to
// point each catalog provider at this one endpoint via the
// `__FOUNDRY_ENDPOINT__` placeholder.
// The account itself is NOT declared here. This file reads it as an existing
// resource:
// - the stamp owns the account (default): main.bicep deploys
// foundry-account.bicep first, then this file.
// - `foundryAccountExisting = true`: the account already exists and the
// stamp never creates or updates it. main.bicep deploys only this file.
//
// All deployments are siblings; the base `model_providers.json` is rewritten
// at manifest-staging time to point each catalog provider at the account's
// endpoint via the `__FOUNDRY_ENDPOINT__` placeholder.
//
// Deployments are operator-controlled: the deploy.mjs orchestrator threads
// a per-stamp JSON file (deploy/envs/local/<env>/foundry-deployments.json)
// in via `--parameters foundryDeployments=@<file>`. An empty array is
// valid (provisions an account with no deployments) so a stamp can opt
// into Foundry incrementally.
// valid (no deployments) so a stamp can opt into Foundry incrementally.
//
// `key` is the compatibility default. `entra` is an explicit opt-in that
// disables local auth, grants the worker UAMI the Foundry data-plane role,
// and selects the staged catalog's `foundry-wif` provider.
// grants the worker UAMI the Foundry data-plane role and selects the staged
// catalog's `foundry-wif` provider. It also disables local auth on an account
// the stamp owns (foundry-account.bicep).
// ==============================================================================

@description('Azure region. Foundry resources are zonal-ish (data-plane lands in this region).')
param location string

@description('Foundry account name. Globally unique within Cognitive Services. Drives the customSubdomainName so the data-plane URL is `https://<name>.openai.azure.com` / `https://<name>.cognitiveservices.azure.com`.')
@description('Foundry account name. The account must exist when this file is deployed.')
param accountName string

@description('SKU name. S0 is the only generally-available SKU for AIServices accounts; F0 is preview/free-tier and not supported for paid model deployments.')
@allowed([
'S0'
])
param sku string = 'S0'

@description('Array of model deployments to provision under this account. Each entry: { name: <deployment-name>, model: { format: <vendor>, name: <model>, version: <version> }, sku: { name: <sku>, capacity: <int> } }. Loaded from a per-stamp JSON file by the deploy orchestrator. Empty array → no deployments (account-only provisioning).')
param deployments array = []

@description('Key Vault name. `azure-oai-key` receives the account key in key mode or the standard unset sentinel in Entra mode. Co-located with the account resource so listKeys() remains in the same template scope.')
param keyVaultName string

@description('Data-plane auth mode. `entra` disables local auth and grants the worker workload identity access to the Foundry data plane. `key` keeps the legacy account-key path.')
@description('Data-plane auth mode. `entra` grants the worker workload identity access to the Foundry data plane and writes no key. `key` keeps the legacy account-key path.')
@allowed([
'key'
'entra'
Expand All @@ -53,24 +50,8 @@ param workloadIdentityPrincipalId string = ''
var cognitiveServicesOpenAiUserRoleId = '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
var keyVaultUnsetSentinel = '__PS_UNSET__'

resource account 'Microsoft.CognitiveServices/accounts@2024-10-01' = {
resource account 'Microsoft.CognitiveServices/accounts@2024-10-01' existing = {
name: accountName
location: location
kind: 'AIServices'
sku: {
name: sku
}
identity: {
type: 'SystemAssigned'
}
properties: {
customSubDomainName: accountName
publicNetworkAccess: 'Enabled'
networkAcls: {
defaultAction: 'Allow'
}
disableLocalAuth: authMode == 'entra'
}
}

// One deployment per entry in `deployments`. Foundry-side concurrency-control
Expand Down
25 changes: 23 additions & 2 deletions deploy/providers/azure/services/base-infra/bicep/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ param foundryAuthMode string = 'key'
@description('Optional Azure region for the Foundry account, decoupled from the stamp region. Empty keeps the account co-located with the stamp.')
param foundryLocation string = ''

@description('Use a Foundry account that already exists instead of creating one. When true, the stamp never creates or updates the account named `<resourceNamePrefix>-aif`: its SKU, region, network and local-auth settings stay as they are (foundrySku, foundryLocation and the local-auth part of foundryAuthMode are ignored). The stamp still manages the model deployments, the Key Vault key secret and the data-plane role. Ignored when foundryEnabled=false.')
param foundryAccountExisting bool = false

// ----- VPN P2S ingress (additive, optional) ---------------------------------
// All defaults preserve byte-equivalent param shape for non-VPN stamps.

Expand Down Expand Up @@ -554,13 +557,31 @@ module KeyVault './keyvault.bicep' = {
// below. The endpoint flows out via the `foundryEndpoint` output, which
// the OSS deploy orchestrator aliases to FOUNDRY_ENDPOINT and substitutes
// into the worker base `model_providers.json` at manifest-staging time.
//
// Two files, so that a stamp can use an account it does not own:
// foundry-account.bicep the account itself. Skipped when
// foundryAccountExisting=true, so the stamp sends
// no create or update for the account.
// foundry.bicep what lives inside it. Reads the account as an
// existing resource in both cases.

module FoundryAccount './foundry-account.bicep' = if (foundryEnabled && !foundryAccountExisting) {
name: '${resourceNamePrefix}-foundry-account-${dTime}'
params: {
location: empty(foundryLocation) ? location : toLower(foundryLocation)
accountName: foundryAccountName
sku: foundrySku
authMode: foundryAuthMode
}
}

module Foundry './foundry.bicep' = if (foundryEnabled) {
name: '${resourceNamePrefix}-foundry-${dTime}'
dependsOn: [
FoundryAccount
]
params: {
location: empty(foundryLocation) ? location : toLower(foundryLocation)
accountName: foundryAccountName
sku: foundrySku
deployments: foundryDeployments
keyVaultName: KeyVault.outputs.keyVaultName
authMode: foundryAuthMode
Expand Down
Loading
Loading