Skip to content

Commit 4113db3

Browse files
chore: dev to main merge
2 parents 8033e01 + fea3ac8 commit 4113db3

34 files changed

Lines changed: 2207 additions & 2006 deletions

infra/main.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"metadata": {
66
"_generator": {
77
"name": "bicep",
8-
"version": "0.42.1.51946",
9-
"templateHash": "5885652317352749587"
8+
"version": "0.43.8.12551",
9+
"templateHash": "12545195410241248179"
1010
},
1111
"name": "Content Processing Solution Accelerator",
1212
"description": "Bicep template to deploy the Content Processing Solution Accelerator with AVM compliance."
@@ -337,8 +337,8 @@
337337
"metadata": {
338338
"_generator": {
339339
"name": "bicep",
340-
"version": "0.42.1.51946",
341-
"templateHash": "10219602196309243204"
340+
"version": "0.43.8.12551",
341+
"templateHash": "13206959925771644022"
342342
}
343343
},
344344
"definitions": {
@@ -19306,8 +19306,8 @@
1930619306
"metadata": {
1930719307
"_generator": {
1930819308
"name": "bicep",
19309-
"version": "0.42.1.51946",
19310-
"templateHash": "15098611015028470375"
19309+
"version": "0.43.8.12551",
19310+
"templateHash": "13200482898648544945"
1931119311
}
1931219312
},
1931319313
"parameters": {
@@ -23332,8 +23332,8 @@
2333223332
"metadata": {
2333323333
"_generator": {
2333423334
"name": "bicep",
23335-
"version": "0.42.1.51946",
23336-
"templateHash": "18123481228095028530"
23335+
"version": "0.43.8.12551",
23336+
"templateHash": "15729887991536611208"
2333723337
}
2333823338
},
2333923339
"parameters": {
@@ -23936,8 +23936,8 @@
2393623936
"metadata": {
2393723937
"_generator": {
2393823938
"name": "bicep",
23939-
"version": "0.42.1.51946",
23940-
"templateHash": "1869938830611166930"
23939+
"version": "0.43.8.12551",
23940+
"templateHash": "8672669912945312056"
2394123941
},
2394223942
"name": "Container Registry Module"
2394323943
},
@@ -36183,8 +36183,8 @@
3618336183
"avmContainerApp_API",
3618436184
"avmContainerApp_Workflow",
3618536185
"avmManagedIdentity",
36186-
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageQueue)]",
3618736186
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageBlob)]",
36187+
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').storageQueue)]",
3618836188
"virtualNetwork"
3618936189
]
3619036190
},
@@ -36314,8 +36314,8 @@
3631436314
"metadata": {
3631536315
"_generator": {
3631636316
"name": "bicep",
36317-
"version": "0.42.1.51946",
36318-
"templateHash": "18336251851332975005"
36317+
"version": "0.43.8.12551",
36318+
"templateHash": "9621562991003135575"
3631936319
},
3632036320
"name": "Cognitive Services",
3632136321
"description": "This module deploys a Cognitive Service."
@@ -37574,8 +37574,8 @@
3757437574
"metadata": {
3757537575
"_generator": {
3757637576
"name": "bicep",
37577-
"version": "0.42.1.51946",
37578-
"templateHash": "8883353547455396972"
37577+
"version": "0.43.8.12551",
37578+
"templateHash": "8864856500234357706"
3757937579
}
3758037580
},
3758137581
"definitions": {
@@ -39307,8 +39307,8 @@
3930739307
"metadata": {
3930839308
"_generator": {
3930939309
"name": "bicep",
39310-
"version": "0.42.1.51946",
39311-
"templateHash": "13560950051680758953"
39310+
"version": "0.43.8.12551",
39311+
"templateHash": "312284397710022090"
3931239312
}
3931339313
},
3931439314
"definitions": {
@@ -39461,8 +39461,8 @@
3946139461
"metadata": {
3946239462
"_generator": {
3946339463
"name": "bicep",
39464-
"version": "0.42.1.51946",
39465-
"templateHash": "2020223351407601593"
39464+
"version": "0.43.8.12551",
39465+
"templateHash": "276675105610077046"
3946639466
}
3946739467
},
3946839468
"definitions": {
@@ -39679,8 +39679,8 @@
3967939679
"metadata": {
3968039680
"_generator": {
3968139681
"name": "bicep",
39682-
"version": "0.42.1.51946",
39683-
"templateHash": "8883353547455396972"
39682+
"version": "0.43.8.12551",
39683+
"templateHash": "8864856500234357706"
3968439684
}
3968539685
},
3968639686
"definitions": {
@@ -41412,8 +41412,8 @@
4141241412
"metadata": {
4141341413
"_generator": {
4141441414
"name": "bicep",
41415-
"version": "0.42.1.51946",
41416-
"templateHash": "13560950051680758953"
41415+
"version": "0.43.8.12551",
41416+
"templateHash": "312284397710022090"
4141741417
}
4141841418
},
4141941419
"definitions": {
@@ -41566,8 +41566,8 @@
4156641566
"metadata": {
4156741567
"_generator": {
4156841568
"name": "bicep",
41569-
"version": "0.42.1.51946",
41570-
"templateHash": "2020223351407601593"
41569+
"version": "0.43.8.12551",
41570+
"templateHash": "276675105610077046"
4157141571
}
4157241572
},
4157341573
"definitions": {
@@ -42487,9 +42487,9 @@
4248742487
},
4248842488
"dependsOn": [
4248942489
"avmAiServices",
42490+
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]",
4249042491
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').contentUnderstanding)]",
4249142492
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').openAI)]",
42492-
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').aiServices)]",
4249342493
"[format('avmPrivateDnsZones[{0}]', variables('dnsZoneIndex').cognitiveServices)]",
4249442494
"virtualNetwork"
4249542495
]

infra/scripts/post_deployment.ps1

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,74 @@ if (-not $ApiReady) {
239239
Write-Host " Schemas registered: $($Registered.Count)"
240240
Write-Host ("=" * 60)
241241
}
242+
243+
# --- Refresh Content Understanding Cognitive Services account ---
244+
Write-Host ""
245+
Write-Host ("=" * 60)
246+
Write-Host "Refreshing Content Understanding Cognitive Services account..."
247+
Write-Host ("=" * 60)
248+
249+
$CU_ACCOUNT_NAME = ""
250+
try {
251+
$CU_ACCOUNT_NAME = (azd env get-value CONTENT_UNDERSTANDING_ACCOUNT_NAME 2>$null)
252+
if (-not $CU_ACCOUNT_NAME) { $CU_ACCOUNT_NAME = "" }
253+
} catch {
254+
$CU_ACCOUNT_NAME = ""
255+
}
256+
257+
# Verify the account from the env value still exists; if not, fall back to discovering
258+
# the AIServices account in the resource group. This protects against stale .env values
259+
# left over from prior deployments (different template/fork) and against the env value
260+
# pointing to a resource that no longer exists.
261+
if ($CU_ACCOUNT_NAME) {
262+
# Capture stderr so we can distinguish a real "not found" response from a
263+
# transient/auth/CLI failure. Only treat the env value as stale when Azure
264+
# actually reports the resource is missing; for any other error keep the
265+
# env value untouched and log the underlying error for diagnosability.
266+
$ShowOutput = az cognitiveservices account show -g $RESOURCE_GROUP -n $CU_ACCOUNT_NAME --output none 2>&1
267+
if ($LASTEXITCODE -ne 0) {
268+
$ShowOutputStr = ($ShowOutput | Out-String).Trim()
269+
if ($ShowOutputStr -match '(?i)ResourceNotFound|was not found|could not be found') {
270+
Write-Host " [Warn] Cognitive Services account '$CU_ACCOUNT_NAME' from azd env was not found in resource group '$RESOURCE_GROUP'."
271+
Write-Host " The azd env value may be stale. Attempting to discover the AIServices account in the resource group..."
272+
$CU_ACCOUNT_NAME = ""
273+
} else {
274+
Write-Host " [Warn] Could not verify Cognitive Services account '$CU_ACCOUNT_NAME' (transient or CLI error). Keeping env value and skipping discovery."
275+
Write-Host " az error: $ShowOutputStr"
276+
}
277+
}
278+
}
279+
280+
if (-not $CU_ACCOUNT_NAME) {
281+
# Enumerate ALL AIServices accounts (not just the first). When the resource
282+
# group contains exactly one we auto-recover; when it contains more than one
283+
# we refuse to guess and ask the user to set the env value explicitly, to
284+
# avoid persisting the wrong account name into azd env.
285+
$CuAccounts = @(az cognitiveservices account list -g $RESOURCE_GROUP --query "[?kind=='AIServices'].name" -o tsv 2>$null)
286+
$CuAccounts = @($CuAccounts | Where-Object { $_ -and $_.Trim() -ne "" })
287+
if ($CuAccounts.Count -eq 1) {
288+
$CU_ACCOUNT_NAME = $CuAccounts[0]
289+
Write-Host " Discovered AIServices account in resource group: $CU_ACCOUNT_NAME"
290+
# Refresh the azd env so subsequent runs use the correct value.
291+
try { azd env set CONTENT_UNDERSTANDING_ACCOUNT_NAME $CU_ACCOUNT_NAME 2>$null | Out-Null } catch { }
292+
} elseif ($CuAccounts.Count -gt 1) {
293+
Write-Host " [Warn] Multiple AIServices accounts found in resource group '$RESOURCE_GROUP': $($CuAccounts -join ', ')"
294+
Write-Host " Please set CONTENT_UNDERSTANDING_ACCOUNT_NAME in azd env to the correct account name. Skipping refresh."
295+
} else {
296+
Write-Host " [Warn] No Content Understanding (AIServices) account found in resource group '$RESOURCE_GROUP'. Skipping refresh."
297+
}
298+
}
299+
300+
if ($CU_ACCOUNT_NAME) {
301+
Write-Host " Refreshing account: $CU_ACCOUNT_NAME in resource group: $RESOURCE_GROUP"
302+
# Capture stderr so that any Azure CLI error is preserved in deployment
303+
# logs even though this refresh step is non-fatal.
304+
$UpdateOutput = az cognitiveservices account update -g $RESOURCE_GROUP -n $CU_ACCOUNT_NAME --tags refresh=true --output none 2>&1
305+
if ($LASTEXITCODE -eq 0) {
306+
Write-Host " [OK] Successfully refreshed Cognitive Services account '$CU_ACCOUNT_NAME'."
307+
} else {
308+
$UpdateOutputStr = ($UpdateOutput | Out-String).Trim()
309+
Write-Host " [Warn] Could not refresh Cognitive Services account '$CU_ACCOUNT_NAME'. Continuing - this step is non-fatal."
310+
Write-Host " az error: $UpdateOutputStr"
311+
}
312+
}

infra/scripts/post_deployment.sh

Lines changed: 72 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,17 +256,84 @@ echo "============================================================"
256256

257257
CU_ACCOUNT_NAME=$(azd env get-value CONTENT_UNDERSTANDING_ACCOUNT_NAME 2>/dev/null || echo "")
258258

259+
# Verify the account from the env value still exists; if not, fall back to discovering
260+
# the AIServices account in the resource group. This protects against stale .env values
261+
# left over from prior deployments (different template/fork) and against the env value
262+
# pointing to a resource that no longer exists.
263+
if [ -n "$CU_ACCOUNT_NAME" ]; then
264+
# Capture stderr so we can distinguish a real "not found" response from a
265+
# transient/auth/CLI failure. Only treat the env value as stale when Azure
266+
# actually reports the resource is missing; for any other error keep the
267+
# env value untouched and log the underlying error for diagnosability.
268+
# `set +e` is required because `set -e` (enabled at the top of the script)
269+
# would otherwise exit the script as soon as `az ... show` returns non-zero,
270+
# before we can inspect $? and decide whether to fall back to discovery.
271+
set +e
272+
CU_SHOW_ERR=$(az cognitiveservices account show \
273+
-g "$RESOURCE_GROUP" \
274+
-n "$CU_ACCOUNT_NAME" \
275+
--output none 2>&1)
276+
CU_SHOW_EC=$?
277+
set -e
278+
if [ $CU_SHOW_EC -ne 0 ]; then
279+
if echo "$CU_SHOW_ERR" | grep -qiE "ResourceNotFound|was not found|could not be found"; then
280+
echo " ⚠️ Cognitive Services account '$CU_ACCOUNT_NAME' from azd env was not found in resource group '$RESOURCE_GROUP'."
281+
echo " The azd env value may be stale. Attempting to discover the AIServices account in the resource group..."
282+
CU_ACCOUNT_NAME=""
283+
else
284+
echo " ⚠️ Could not verify Cognitive Services account '$CU_ACCOUNT_NAME' (transient or CLI error). Keeping env value and skipping discovery."
285+
echo " az error: $CU_SHOW_ERR"
286+
fi
287+
fi
288+
fi
289+
259290
if [ -z "$CU_ACCOUNT_NAME" ]; then
260-
echo " ⚠️ CONTENT_UNDERSTANDING_ACCOUNT_NAME not found in azd env. Skipping refresh."
261-
else
291+
# Enumerate ALL AIServices accounts (not just the first). When the resource
292+
# group contains exactly one we auto-recover; when it contains more than one
293+
# we refuse to guess and ask the user to set the env value explicitly, to
294+
# avoid persisting the wrong account name into azd env.
295+
# Use a portable `while read` loop instead of `mapfile`, because `mapfile`
296+
# requires bash 4+ and the azd postprovision hook also runs on macOS where
297+
# the default shell is still bash 3.2.
298+
CU_ACCOUNTS=()
299+
while IFS= read -r _cu_acct; do
300+
[ -n "$_cu_acct" ] && CU_ACCOUNTS+=("$_cu_acct")
301+
done < <(az cognitiveservices account list \
302+
-g "$RESOURCE_GROUP" \
303+
--query "[?kind=='AIServices'].name" \
304+
-o tsv 2>/dev/null || true)
305+
if [ "${#CU_ACCOUNTS[@]}" -eq 1 ]; then
306+
CU_ACCOUNT_NAME="${CU_ACCOUNTS[0]}"
307+
echo " Discovered AIServices account in resource group: $CU_ACCOUNT_NAME"
308+
# Refresh the azd env so subsequent runs use the correct value.
309+
azd env set CONTENT_UNDERSTANDING_ACCOUNT_NAME "$CU_ACCOUNT_NAME" >/dev/null 2>&1 || true
310+
elif [ "${#CU_ACCOUNTS[@]}" -gt 1 ]; then
311+
echo " ⚠️ Multiple AIServices accounts found in resource group '$RESOURCE_GROUP': ${CU_ACCOUNTS[*]}"
312+
echo " Please set CONTENT_UNDERSTANDING_ACCOUNT_NAME in azd env to the correct account name. Skipping refresh."
313+
else
314+
echo " ⚠️ No Content Understanding (AIServices) account found in resource group '$RESOURCE_GROUP'. Skipping refresh."
315+
fi
316+
fi
317+
318+
if [ -n "$CU_ACCOUNT_NAME" ]; then
262319
echo " Refreshing account: $CU_ACCOUNT_NAME in resource group: $RESOURCE_GROUP"
263-
if az cognitiveservices account update \
320+
# Capture stderr so that any Azure CLI error is preserved in deployment
321+
# logs even though this refresh step is non-fatal.
322+
# `set +e` is required because `set -e` (enabled at the top of the script)
323+
# would otherwise exit the script as soon as `az ... update` returns
324+
# non-zero, defeating the explicit "non-fatal" handling below.
325+
set +e
326+
CU_UPDATE_ERR=$(az cognitiveservices account update \
264327
-g "$RESOURCE_GROUP" \
265328
-n "$CU_ACCOUNT_NAME" \
266329
--tags refresh=true \
267-
--output none; then
330+
--output none 2>&1)
331+
CU_UPDATE_EC=$?
332+
set -e
333+
if [ $CU_UPDATE_EC -eq 0 ]; then
268334
echo " ✅ Successfully refreshed Cognitive Services account '$CU_ACCOUNT_NAME'."
269335
else
270-
echo " ❌ Failed to refresh Cognitive Services account '$CU_ACCOUNT_NAME'."
336+
echo " ⚠️ Could not refresh Cognitive Services account '$CU_ACCOUNT_NAME'. Continuing — this step is non-fatal."
337+
echo " az error: $CU_UPDATE_ERR"
271338
fi
272339
fi

infra/vscode_web/codeSample.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
11
from azure.ai.projects import AIProjectClient
22
from azure.identity import DefaultAzureCredential
3+
from azure.ai.agents.models import ListSortOrder
34

45
project_client = AIProjectClient.from_connection_string(
56
credential=DefaultAzureCredential(),
67
conn_str="<%= connectionString %>")
78

89
agent = project_client.agents.get_agent("<%= agentId %>")
910

10-
thread = project_client.agents.create_thread()
11+
thread = project_client.agents.threads.create()
1112
print(f"Created thread, ID: {thread.id}")
1213

13-
message = project_client.agents.create_message(
14+
message = project_client.agents.messages.create(
1415
thread_id=thread.id,
1516
role="user",
1617
content="<%= userMessage %>"
1718
)
1819

19-
run = project_client.agents.create_and_process_run(
20+
run = project_client.agents.runs.create_and_process(
2021
thread_id=thread.id,
2122
agent_id=agent.id)
22-
messages = project_client.agents.list_messages(thread_id=thread.id)
2323

24-
for text_message in messages.text_messages:
25-
print(text_message.as_dict())
24+
if run.status == "failed":
25+
print(f"Run failed: {run.last_error}")
26+
else:
27+
messages = project_client.agents.messages.list(
28+
thread_id=thread.id, order=ListSortOrder.ASCENDING)
29+
30+
for message in messages:
31+
if message.text_messages:
32+
print(f"{message.role}: {message.text_messages[-1].text.value}")

infra/vscode_web/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
azure-ai-projects==1.0.0b12
1+
azure-ai-projects==2.1.0
22
azure-identity==1.20.0
33
ansible-core~=2.17.0

src/ContentProcessor/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description = "Content Process Gold Standard Solution Accelerator - Content Proc
55
readme = "README.md"
66
requires-python = ">=3.12"
77
dependencies = [
8-
"agent-framework==1.0.0b260127",
8+
"agent-framework==1.3.0",
99
"azure-ai-inference==1.0.0b9",
1010
"azure-appconfiguration==1.8.0",
1111
"azure-identity==1.26.0b1",

0 commit comments

Comments
 (0)