From c5e0855338268998452584fea0ae256ba960a370 Mon Sep 17 00:00:00 2001 From: Paul Yuknewicz Date: Tue, 3 Nov 2026 19:08:16 -0800 Subject: [PATCH] fix(infra): omit default AI Gateway SKU so RP applies Standard - Omit sku from Microsoft.ApiManagement/aigateways in infra/ai-gateway/main.bicep so the resource provider applies its default SKU (Standard). - Remove hardcoded Premium SKU filters from manage-ai-gateway-lifecycle.sh and manage-ai-gateway-lifecycle.ps1. - Update model registration and lifecycle tests and documentation. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 4448b1aa-1ea5-4c5f-af63-7ec98b7acb9e --- IMPLEMENTATION_NOTES.md | 2 +- infra/ai-gateway/README.md | 2 +- infra/ai-gateway/main.bicep | 3 --- infra/scripts/manage-ai-gateway-lifecycle.ps1 | 5 +---- infra/scripts/manage-ai-gateway-lifecycle.sh | 4 +--- tests/test-ai-gateway-model-registration.sh | 6 +++--- tests/test-apim-lifecycle.sh | 8 ++++---- 7 files changed, 11 insertions(+), 19 deletions(-) diff --git a/IMPLEMENTATION_NOTES.md b/IMPLEMENTATION_NOTES.md index 89dffba..083e722 100644 --- a/IMPLEMENTATION_NOTES.md +++ b/IMPLEMENTATION_NOTES.md @@ -279,7 +279,7 @@ role-definition ID used by the template is The AI Gateway module uses the live `2025-09-01-preview` contracts: -- `Microsoft.ApiManagement/aigateways` with SKU `Premium` +- `Microsoft.ApiManagement/aigateways` (`sku` omitted so the RP defaults to `Standard`) - `Microsoft.ApiManagement/aigateways/workspaces` - `Microsoft.ApiManagement/aigateways/workspaces/modelProviders` - `Microsoft.ApiManagement/aigateways/workspaces/modelProviders/models` diff --git a/infra/ai-gateway/README.md b/infra/ai-gateway/README.md index f63e242..cb3a7a8 100644 --- a/infra/ai-gateway/README.md +++ b/infra/ai-gateway/README.md @@ -3,7 +3,7 @@ Run the commands in this README from the `infra/ai-gateway/` directory. [`main.bicep`](main.bicep) is a resource-group-scoped module for an AI Gateway -with Premium SKU. With the default `deployApimGatewayViaBicep: true`, it +(`sku` omitted so the resource provider defaults to `Standard`). With the default `deployApimGatewayViaBicep: true`, it creates `Microsoft.ApiManagement/aigateways` and `apiKeys/default`. When monitoring is enabled, it also provisions Log Analytics and a workspace-based Application Insights component (`AzureMonitorWorkspaceIngestionMode: Enabled`). diff --git a/infra/ai-gateway/main.bicep b/infra/ai-gateway/main.bicep index e7b0b94..8678604 100644 --- a/infra/ai-gateway/main.bicep +++ b/infra/ai-gateway/main.bicep @@ -55,9 +55,6 @@ resource aiGateway 'Microsoft.ApiManagement/aigateways@2025-09-01-preview' = if identity: { type: 'SystemAssigned' } - sku: { - name: 'Premium' - } properties: empty(backendSubnetResourceId) ? {} : { diff --git a/infra/scripts/manage-ai-gateway-lifecycle.ps1 b/infra/scripts/manage-ai-gateway-lifecycle.ps1 index a0e1748..5d06468 100644 --- a/infra/scripts/manage-ai-gateway-lifecycle.ps1 +++ b/infra/scripts/manage-ai-gateway-lifecycle.ps1 @@ -145,7 +145,7 @@ function Find-LiveGateway { $candidateLines = & az resource list ` --subscription $subscriptionId ` --resource-type Microsoft.ApiManagement/aigateways ` - --query "[?tags.`"azd-env-name`"=='$environmentName' && sku.name=='Premium'].[name,resourceGroup,location]" ` + --query "[?tags.`"azd-env-name`"=='$environmentName'].[name,resourceGroup,location]" ` -o tsv if ($LASTEXITCODE -ne 0) { throw "AI Gateway lifecycle error: could not discover AI Gateway resources for azd environment $environmentName." @@ -274,9 +274,6 @@ function Test-LiveDeleting($Record) { } function Assert-LiveOwnership($Record) { - if ($Record.Sku -ne "Premium") { - throw "AI Gateway lifecycle error: refusing $resourceGroup/$gatewayName; expected SKU Premium but found $($Record.Sku)." - } if ($Record.Owner -ne $environmentName) { throw "AI Gateway lifecycle error: refusing $resourceGroup/$gatewayName; expected azd-env-name=$environmentName but found $($Record.Owner)." } diff --git a/infra/scripts/manage-ai-gateway-lifecycle.sh b/infra/scripts/manage-ai-gateway-lifecycle.sh index 5c4fdca..9dfd8c9 100755 --- a/infra/scripts/manage-ai-gateway-lifecycle.sh +++ b/infra/scripts/manage-ai-gateway-lifecycle.sh @@ -215,7 +215,7 @@ discover_live_gateway() { if ! candidates="$(az resource list \ --subscription "$subscription_id" \ --resource-type Microsoft.ApiManagement/aigateways \ - --query "[?tags.\"azd-env-name\"=='${environment_name}' && sku.name=='Premium'].[name,resourceGroup,location]" \ + --query "[?tags.\"azd-env-name\"=='${environment_name}'].[name,resourceGroup,location]" \ -o tsv)"; then fail "could not discover AI Gateway resources for azd environment ${environment_name}." fi @@ -354,8 +354,6 @@ live_is_deleting() { } validate_live_ownership() { - [ "$live_sku" = "Premium" ] || - fail "refusing ${resource_group}/${gateway_name}; expected SKU Premium but found ${live_sku:-unknown}." [ "$live_owner" = "$environment_name" ] || fail "refusing ${resource_group}/${gateway_name}; expected azd-env-name=${environment_name} but found ${live_owner:-missing}." if [ -n "$live_location" ] && [ "$live_location" != "null" ]; then diff --git a/tests/test-ai-gateway-model-registration.sh b/tests/test-ai-gateway-model-registration.sh index e7722f3..7a7ec94 100755 --- a/tests/test-ai-gateway-model-registration.sh +++ b/tests/test-ai-gateway-model-registration.sh @@ -56,10 +56,10 @@ done gateway_sku="$(jq -r ' .resources[] | select(.type == "Microsoft.ApiManagement/aigateways") - | .sku.name + | .sku ' "$compiled_template")" -if [ "$gateway_sku" != "Premium" ]; then - echo "AI Gateway must use the live RP Premium SKU." >&2 +if [ "$gateway_sku" != "null" ]; then + echo "AI Gateway must omit sku so the RP applies its default SKU." >&2 echo "Actual: $gateway_sku" >&2 exit 1 fi diff --git a/tests/test-apim-lifecycle.sh b/tests/test-apim-lifecycle.sh index 8b7963a..5653be0 100755 --- a/tests/test-apim-lifecycle.sh +++ b/tests/test-apim-lifecycle.sh @@ -162,7 +162,7 @@ case "$uri" in if [ -n "$query" ]; then printf '%s|%s|%s|%s|%s\n' \ "$(read_state provisioning_state Succeeded)" \ - "$(read_state sku Premium)" \ + "$(read_state sku Standard)" \ "$(read_state owner "$environment_name")" \ "$location" \ "$(read_state target_state null)" @@ -197,7 +197,7 @@ new_case() { case_dir="$temp_root/$name" mkdir -p "$case_dir" printf '0' > "$case_dir/live" - printf 'Premium' > "$case_dir/sku" + printf 'Standard' > "$case_dir/sku" printf 'tues' > "$case_dir/owner" printf 'Succeeded' > "$case_dir/provisioning_state" output_file="$case_dir/output" @@ -389,7 +389,6 @@ assert_contains "$marker_file" "state=pending" for token in \ "2025-09-01-preview" \ "Microsoft.ApiManagement/aigateways" \ - "Premium" \ "azd-env-name" \ "FailedIdentityOperation" \ "ActivationFailed" \ @@ -402,7 +401,8 @@ done for legacy_contract in \ "Microsoft.ApiManagement/service" \ "deletedservices" \ - "AIGateway"; do + "AIGateway" \ + "Premium"; do assert_not_contains "$lifecycle_script" "$legacy_contract" assert_not_contains "$powershell_script" "$legacy_contract" done