-
Notifications
You must be signed in to change notification settings - Fork 95
Update SRE Agent scripts to stable ARM APIs #312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -97,7 +97,7 @@ if (-not (Test-Path $ExtrasFile)) { | |
| # many optional keys on $extras that may be absent for minimal recipes. | ||
| Set-StrictMode -Off | ||
|
|
||
| $ApiVersion = "2025-05-01-preview" | ||
| $ApiVersion = "2026-01-01" | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could Add one file next to the scripts: # versions.ps1
$ApiVersion = "2026-01-01"Then in each script, replace the local assignment with: . "$PSScriptRoot\versions.ps1"The rest of the script stays as it is: The leading dot is the whole trick: it runs the file in the current scope. Without it, After that a version bump is one edit instead of one per script, and the scripts can't drift onto different API versions without anyone noticing. |
||
| $ArmBase = "https://management.azure.com/subscriptions/$Subscription/resourceGroups/$ResourceGroup/providers/Microsoft.App/agents/$AgentName" | ||
|
|
||
| # ── Resolve agent endpoint and UAMI ──────────────────────────────────────── | ||
|
|
@@ -156,29 +156,6 @@ function Get-DpToken { | |
| return $tok | ||
| } | ||
|
|
||
| # ── Helper: ARM PUT sub-resource with base64-encoded value envelope ───────── | ||
| # Used for incidentFilters, scheduledTasks, commonPrompts. | ||
| function Arm-PutSubresource { | ||
| param([string]$Type, [string]$Name, [string]$SpecJson) | ||
| $url = "$ArmBase/$Type/$Name`?api-version=$ApiVersion" | ||
| $encoded = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($SpecJson)) | ||
| $body = @{ properties = @{ value = $encoded } } | ConvertTo-Json -Compress -Depth 10 | ||
| $tmp = [System.IO.Path]::GetTempFileName() | ||
| try { | ||
| Set-Content -Path $tmp -Value $body -NoNewline | ||
| Write-Host " ARM PUT $Type/$Name" | ||
| $result = az rest -m PUT --url $url --body "@$tmp" --headers "Content-Type=application/json" -o json 2>&1 | ||
| if ($LASTEXITCODE -eq 0) { | ||
| Write-Host " ok" | ||
| } else { | ||
| $msg = ($result | Out-String) -replace '(?s).*"message":"([^"]*)".*', '$1' | ||
| Write-Host " FAILED - $msg" | ||
| } | ||
| } finally { | ||
| Remove-Item $tmp -ErrorAction SilentlyContinue | ||
| } | ||
| } | ||
|
|
||
| # ── Helper: ARM PUT connector sub-resource (native properties, no base64) ── | ||
| function Arm-PutConnector { | ||
| param([string]$Name, [string]$BodyJson) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could
API_VERSIONmove into a shared file that every script sources?Add one file next to the scripts:
Then in
apply-extras.shand anywhere else that needs it, replace the local assignment with:ARM_BASEand the rest of the script stay as they are:$API_VERSIONresolves the same way.Two notes on the syntax. Use the dot form rather than
sourceso it works under#!/bin/sh. And keep the$(dirname "$0")— a bare. ./versions.shresolves against whatever directory the caller happens to be in, not the script's own.After that a version bump is one edit instead of one per script, and the scripts can't drift onto different API versions without anyone noticing.