Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Principal ID: 5db0aa5d-f281-47a3-9720-04727dec61e8\n",
"Principal ID: 00000000-0000-0000-0000-000000000000\n",
"Deploying ACR infrastructure (~1-2 min)...\n",
"\u001b[?1h\u001b=\u001b[93mA new Bicep release is available: v0.43.8. Upgrade now by running \"az bicep upgrade\".\u001b[0m\n",
"\u001b[?1h\u001b=\u001b[93m<repo-root>/08-agents/08-03-hosted-agents/main.bicep(41,9) : Warning BCP334: The provided value can have a length as small as 3 and may be too short to assign to a target with a configured minimum length of 5. [https://aka.ms/bicep/core-diagnostics#BCP334]\n",
Expand Down Expand Up @@ -511,7 +511,7 @@
"\u001b[93mWaiting for an agent...\u001b[0m\n",
"2026/05/10 13:05:26 Downloading source code...\n",
"2026/05/10 13:05:27 Finished downloading source code\n",
"2026/05/10 13:05:27 Using acb_vol_def3c675-dcb8-438a-b726-37b613e7a5aa as the home volume\n",
"2026/05/10 13:05:27 Using acb_vol_00000000-0000-0000-0000-000000000000 as the home volume\n",
"2026/05/10 13:05:27 Setting up Docker configuration...\n",
"2026/05/10 13:05:28 Successfully set up Docker configuration\n",
"2026/05/10 13:05:28 Logging in to registry: acralphac2676f.azurecr.io\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@
" ERROR: Cannot change the site func-contoso-pmo-mcp-d55074 to the App Service Plan ASP-rgfoundrycontosopmomcp-e6cf due to hosting constraints.\n",
" … waiting 30 s for managed identity to initialize...\n",
"Assigning storage roles to managed identity...\n",
" ✓ managed identity principal: 187581c6-b580-42c9-a030-01de0e898f4d\n",
" ✓ managed identity principal: 00000000-0000-0000-0000-000000000000\n",
" ✓ Storage Blob Data Owner\n",
" ✓ Storage Queue Data Contributor\n",
" ✓ Storage Table Data Contributor\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@
" ERROR: Cannot change the site func-private-banking-mcp-97aab2 to the App Service Plan ASP-rgfoundryprivatebankingmcp-c0e3 due to hosting constraints.\n",
" … waiting 30 s for managed identity to initialize...\n",
"Assigning storage roles to managed identity...\n",
" ✓ managed identity principal: 67bc2a77-6ab1-4d78-b03a-16ccc0529bdd\n",
" ✓ managed identity principal: 00000000-0000-0000-0000-000000000000\n",
" ✓ Storage Blob Data Owner\n",
" ✓ Storage Queue Data Contributor\n",
" ✓ Storage Table Data Contributor\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@
"output_type": "stream",
"text": [
"View evaluation results in Foundry portal:\n",
"https://ai.azure.com/resource/build/evaluation/3e864d4f-d92d-4182-a49f-f1118878762c?wsid=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-foundry-core-c2676f/providers/Microsoft.CognitiveServices/accounts/aif-core-c2676f/projects/project-admin-c2676f&tid=b845d325-6786-435a-bc28-b326d9fcbe16\n"
"https://ai.azure.com/resource/build/evaluation/00000000-0000-0000-0000-000000000000?wsid=/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/rg-foundry-core-c2676f/providers/Microsoft.CognitiveServices/accounts/aif-core-c2676f/projects/project-admin-c2676f&tid=00000000-0000-0000-0000-000000000000\n"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Principal ID: 5db0aa5d-f281-47a3-9720-04727dec61e8\n"
"Principal ID: 00000000-0000-0000-0000-000000000000\n"
]
}
],
Expand Down
160 changes: 144 additions & 16 deletions 12-foundry-iq-deep-research/12-01-deploy-o3-backend.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,19 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"id": "12010001-0000-0000-0000-000000000003",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Gateway URL : https://apim-foundry-c2676f.azure-api.net/openai\n",
"Chat model : gpt-4.1-mini\n"
]
}
],
"source": [
"import json\n",
"import os\n",
Expand Down Expand Up @@ -81,11 +90,52 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"id": "12010001-0000-0000-0000-000000000005",
"metadata": {},
"outputs": [],
"source": "# Derive APIM name and suffix from GATEWAY_URL\n# e.g. https://apim-foundry-{suffix}.azure-api.net/openai -> apim-foundry-{suffix}\nAPIM_NAME = GATEWAY_URL.split('//')[1].split('.')[0]\nSUFFIX = APIM_NAME.split('-')[-1] # e.g. {suffix}\nCORE_RG = f'rg-foundry-core-{SUFFIX}'\n\n# Subscription ID + ARM base URI used by Steps 3 and 5 to call APIM management\n# endpoints directly via `az rest`. This avoids requiring the `az apim` CLI\n# extension, which is not bundled with the base Azure CLI.\nSUB_ID = subprocess.run(\n 'az account show --query id -o tsv', shell=True, capture_output=True, text=True\n).stdout.strip()\nAPIM_BASE_URI = (\n f'https://management.azure.com/subscriptions/{SUB_ID}'\n f'/resourceGroups/{CORE_RG}/providers/Microsoft.ApiManagement/service/{APIM_NAME}'\n)\n\n# Get deployer principal ID from cached JWT\ntoken = subprocess.run(\n 'az account get-access-token --query accessToken -o tsv',\n shell=True, capture_output=True, text=True\n).stdout.strip()\npadding = '=' * (4 - len(token.split('.')[1]) % 4)\nPRINCIPAL_ID = json.loads(base64.b64decode(token.split('.')[1] + padding))['oid']\n\nprint(f'APIM service : {APIM_NAME}')\nprint(f'Core RG : {CORE_RG}')\nprint(f'Subscription : {SUB_ID}')\nprint(f'Principal ID : {PRINCIPAL_ID}')"
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"APIM service : apim-foundry-c2676f\n",
"Core RG : rg-foundry-core-c2676f\n",
"Subscription : 00000000-0000-0000-0000-000000000000\n",
"Principal ID : 00000000-0000-0000-0000-000000000000\n"
]
}
],
"source": [
"# Derive APIM name and suffix from GATEWAY_URL\n",
"# e.g. https://apim-foundry-{suffix}.azure-api.net/openai -> apim-foundry-{suffix}\n",
"APIM_NAME = GATEWAY_URL.split('//')[1].split('.')[0]\n",
"SUFFIX = APIM_NAME.split('-')[-1] # e.g. {suffix}\n",
"CORE_RG = f'rg-foundry-core-{SUFFIX}'\n",
"\n",
"# Subscription ID + ARM base URI used by Steps 3 and 5 to call APIM management\n",
"# endpoints directly via `az rest`. This avoids requiring the `az apim` CLI\n",
"# extension, which is not bundled with the base Azure CLI.\n",
"SUB_ID = subprocess.run(\n",
" 'az account show --query id -o tsv', shell=True, capture_output=True, text=True\n",
").stdout.strip()\n",
"APIM_BASE_URI = (\n",
" f'https://management.azure.com/subscriptions/{SUB_ID}'\n",
" f'/resourceGroups/{CORE_RG}/providers/Microsoft.ApiManagement/service/{APIM_NAME}'\n",
")\n",
"\n",
"# Get deployer principal ID from cached JWT\n",
"token = subprocess.run(\n",
" 'az account get-access-token --query accessToken -o tsv',\n",
" shell=True, capture_output=True, text=True\n",
").stdout.strip()\n",
"padding = '=' * (4 - len(token.split('.')[1]) % 4)\n",
"PRINCIPAL_ID = json.loads(base64.b64decode(token.split('.')[1] + padding))['oid']\n",
"\n",
"print(f'APIM service : {APIM_NAME}')\n",
"print(f'Core RG : {CORE_RG}')\n",
"print(f'Subscription : {SUB_ID}')\n",
"print(f'Principal ID : {PRINCIPAL_ID}')"
]
},
{
"cell_type": "markdown",
Expand All @@ -97,11 +147,34 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"id": "12010001-0000-0000-0000-000000000007",
"metadata": {},
"outputs": [],
"source": "check = subprocess.run(\n f'az rest --method GET'\n f' --uri \"{APIM_BASE_URI}/backends/openai-research?api-version=2024-06-01-preview\"'\n f' -o none',\n shell=True, capture_output=True, text=True\n)\nBACKEND_EXISTS = check.returncode == 0\n\nif BACKEND_EXISTS:\n print('✅ openai-research APIM backend already exists - skipping Bicep deployment.')\n print(' Proceeding to read existing resources.')\nelse:\n print('ℹ️ openai-research backend not found - will deploy main.bicep.')"
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"✅ openai-research APIM backend already exists - skipping Bicep deployment.\n",
" Proceeding to read existing resources.\n"
]
}
],
"source": [
"check = subprocess.run(\n",
" f'az rest --method GET'\n",
" f' --uri \"{APIM_BASE_URI}/backends/openai-research?api-version=2024-06-01-preview\"'\n",
" f' -o none',\n",
" shell=True, capture_output=True, text=True\n",
")\n",
"BACKEND_EXISTS = check.returncode == 0\n",
"\n",
"if BACKEND_EXISTS:\n",
" print('✅ openai-research APIM backend already exists - skipping Bicep deployment.')\n",
" print(' Proceeding to read existing resources.')\n",
"else:\n",
" print('ℹ️ openai-research backend not found - will deploy main.bicep.')"
]
},
{
"cell_type": "markdown",
Expand All @@ -115,10 +188,18 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"id": "12010001-0000-0000-0000-000000000009",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ℹ️ Skipped (backend already exists)\n"
]
}
],
"source": [
"if not BACKEND_EXISTS:\n",
" result = subprocess.run(\n",
Expand Down Expand Up @@ -152,11 +233,48 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 5,
"id": "12010001-0000-0000-0000-000000000011",
"metadata": {},
"outputs": [],
"source": "# Try the dedicated deep research subscription first; fall back to the alpha\n# subscription if it doesn't exist yet. Uses `az rest` against ARM directly,\n# matching the pattern in 10-01 and 11-01, so the `az apim` extension is not needed.\ndef _list_apim_subscription_key(sub_name: str) -> str | None:\n r = subprocess.run(\n f'az rest --method POST'\n f' --uri \"{APIM_BASE_URI}/subscriptions/{sub_name}/listSecrets?api-version=2024-06-01-preview\"'\n f' --query primaryKey -o tsv',\n shell=True, capture_output=True, text=True\n )\n return r.stdout.strip() if r.returncode == 0 and r.stdout.strip() else None\n\nDR_GATEWAY_KEY = _list_apim_subscription_key('foundry-gateway-dr')\nif DR_GATEWAY_KEY:\n print('✅ Using foundry-gateway-dr subscription key')\nelse:\n DR_GATEWAY_KEY = _list_apim_subscription_key('foundry-gateway-alpha')\n if DR_GATEWAY_KEY:\n print('ℹ️ Using foundry-gateway-alpha subscription key (fallback)')\n else:\n raise RuntimeError('Could not retrieve APIM subscription key. Check az login and core RG.')\n\nDR_MODEL = 'o3-deep-research'\n\nprint(f'DR model : {DR_MODEL}')\nprint(f'DR key : {DR_GATEWAY_KEY[:4]}... (hidden)')"
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ℹ️ Using foundry-gateway-alpha subscription key (fallback)\n",
"DR model : o3-deep-research\n",
"DR key : 8382... (hidden)\n"
]
}
],
"source": [
"# Try the dedicated deep research subscription first; fall back to the alpha\n",
"# subscription if it doesn't exist yet. Uses `az rest` against ARM directly,\n",
"# matching the pattern in 10-01 and 11-01, so the `az apim` extension is not needed.\n",
"def _list_apim_subscription_key(sub_name: str) -> str | None:\n",
" r = subprocess.run(\n",
" f'az rest --method POST'\n",
" f' --uri \"{APIM_BASE_URI}/subscriptions/{sub_name}/listSecrets?api-version=2024-06-01-preview\"'\n",
" f' --query primaryKey -o tsv',\n",
" shell=True, capture_output=True, text=True\n",
" )\n",
" return r.stdout.strip() if r.returncode == 0 and r.stdout.strip() else None\n",
"\n",
"DR_GATEWAY_KEY = _list_apim_subscription_key('foundry-gateway-dr')\n",
"if DR_GATEWAY_KEY:\n",
" print('✅ Using foundry-gateway-dr subscription key')\n",
"else:\n",
" DR_GATEWAY_KEY = _list_apim_subscription_key('foundry-gateway-alpha')\n",
" if DR_GATEWAY_KEY:\n",
" print('ℹ️ Using foundry-gateway-alpha subscription key (fallback)')\n",
" else:\n",
" raise RuntimeError('Could not retrieve APIM subscription key. Check az login and core RG.')\n",
"\n",
"DR_MODEL = 'o3-deep-research'\n",
"\n",
"print(f'DR model : {DR_MODEL}')\n",
"print(f'DR key : {DR_GATEWAY_KEY[:4]}... (hidden)')"
]
},
{
"cell_type": "markdown",
Expand All @@ -168,10 +286,20 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"id": "12010001-0000-0000-0000-000000000013",
"metadata": {},
"outputs": [],
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"✅ .env updated:\n",
" DR_MODEL=o3-deep-research\n",
" DR_GATEWAY_KEY=8382...\n"
]
}
],
"source": [
"lines = env_file.read_text().splitlines() if env_file.exists() else []\n",
"\n",
Expand Down Expand Up @@ -225,4 +353,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
Loading
Loading