Skip to content

Commit 77b1ef2

Browse files
committed
fix: renommer le paramètre mcpPrmPath en mcpApiPath et mettre à jour les références dans le code
1 parent 09ce16f commit 77b1ef2

2 files changed

Lines changed: 87 additions & 13 deletions

File tree

labs/mcp-prm-oauth/main.bicep

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ param tags object = {}
3232

3333
param location string = resourceGroup().location
3434

35-
param mcpPrmPath string = 'profile'
35+
param mcpApiPath string = 'mcp'
3636

3737
// ------------------
3838
// VARIABLES
@@ -223,7 +223,7 @@ module mcpEntraAppModule 'src/bicep/identity/mcp-entra-app.bicep' = if (empty(mc
223223
tenantId: subscription().tenantId
224224
webAppName: mcpServerContainerApp.name
225225
userAssignedIdentityPrincipleId: managedIdentityModule.outputs.identityPrincipalId
226-
applicationIdUri: '${apimModule.outputs.gatewayUrl}/${mcpPrmPath}/mcp'
226+
applicationIdUri: '${apimModule.outputs.gatewayUrl}/${mcpApiPath}/mcp'
227227
}
228228
}
229229

@@ -235,7 +235,7 @@ module mcpApiModule 'src/bicep/apim-mcp/mcp-api.bicep' = {
235235
webAppName: mcpServerContainerApp.name
236236
mcpAppId: !empty(mcpClientId) ? mcpClientId : (mcpEntraAppModule.?outputs.mcpAppId ?? '')
237237
mcpAppTenantId: subscription().tenantId
238-
mcpApiPath: mcpPrmPath
238+
mcpApiPath: mcpApiPath
239239
}
240240
}
241241

@@ -287,5 +287,5 @@ output mcpServerURL string = 'https://${mcpServerContainerApp.properties.configu
287287
// MCP Configuration
288288
output mcpAppId string = !empty(mcpClientId) ? mcpClientId : (mcpEntraAppModule.?outputs.mcpAppId ?? 'Not created - provide mcpClientId parameter')
289289
output mcpAppTenantId string = subscription().tenantId
290-
output mcpApiEndpoint string = '${apimModule.outputs.gatewayUrl}/${mcpPrmPath}/mcp'
291-
output mcpPrmEndpoint string = '${apimModule.outputs.gatewayUrl}/${mcpPrmPath}/.well-known/oauth-protected-resource'
290+
output mcpApiEndpoint string = '${apimModule.outputs.gatewayUrl}/${mcpApiPath}/mcp'
291+
output mcpPrmEndpoint string = '${apimModule.outputs.gatewayUrl}/.well-known/oauth-protected-resource/${mcpApiPath}'

labs/mcp-prm-oauth/mcp-prm-oauth.ipynb

Lines changed: 82 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,24 @@
4949
"metadata": {
5050
"metadata": {}
5151
},
52-
"outputs": [],
52+
"outputs": [
53+
{
54+
"name": "stdout",
55+
"output_type": "stream",
56+
"text": [
57+
"\u001b[1;32mNotebook initialized\u001b[0m ⌚ 17:41:29.961075 \n"
58+
]
59+
}
60+
],
5361
"source": [
5462
"import os, sys, json, base64, random, string\n",
5563
"sys.path.insert(1, '../../shared') # add the shared directory to the Python path\n",
5664
"import utils\n",
5765
"\n",
5866
"deployment_name = os.path.basename(os.path.dirname(globals()['__vsc_ipynb_file__']))\n",
59-
"resource_group_name = f\"lab-{deployment_name}\" # change the name to match your naming style\n",
67+
"resource_group_name = f\"lab-{deployment_name}-2\" # change the name to match your naming style\n",
6068
"resource_group_location = \"ukwest\"\n",
69+
"resource_suffix = ''.join(random.choices(string.ascii_letters + string.digits, k=8)).lower()\n",
6170
"\n",
6271
"aiservices_config = []\n",
6372
"\n",
@@ -71,7 +80,7 @@
7180
"inference_api_version = \"2025-03-01-preview\"\n",
7281
"foundry_project_name = deployment_name\n",
7382
"\n",
74-
"app_registration_name = f\"lab-{deployment_name}-app\"\n",
83+
"app_registration_name = f\"lab-{deployment_name}-{resource_suffix}-app\"\n",
7584
"\n",
7685
"build = 0\n",
7786
"prm_mcp_server_image = \"mcp-prm-server\"\n",
@@ -99,9 +108,21 @@
99108
},
100109
{
101110
"cell_type": "code",
102-
"execution_count": null,
111+
"execution_count": 2,
103112
"metadata": {},
104-
"outputs": [],
113+
"outputs": [
114+
{
115+
"name": "stdout",
116+
"output_type": "stream",
117+
"text": [
118+
"⚙️ \u001b[1;34mRunning: az account show \u001b[0m\n",
119+
"\u001b[1;32mRetrieved az account\u001b[0m ⌚ 17:41:34.969378 [0m:4s]\n",
120+
"👉🏽 \u001b[1;34mCurrent user: admin@MngEnvMCAP597089.onmicrosoft.com\u001b[0m\n",
121+
"👉🏽 \u001b[1;34mTenant ID: cef7fc0f-a52f-4e91-8198-e00530d523b6\u001b[0m\n",
122+
"👉🏽 \u001b[1;34mSubscription ID: c15de093-adb5-498b-beda-73764e08f7a9\u001b[0m\n"
123+
]
124+
}
125+
],
105126
"source": [
106127
"output = utils.run(\"az account show\", \"Retrieved az account\", \"Failed to get the current az account\")\n",
107128
"\n",
@@ -129,7 +150,32 @@
129150
"cell_type": "code",
130151
"execution_count": null,
131152
"metadata": {},
132-
"outputs": [],
153+
"outputs": [
154+
{
155+
"name": "stdout",
156+
"output_type": "stream",
157+
"text": [
158+
"⚙️ \u001b[1;34mRunning: az group show --name lab-mcp-prm-oauth \u001b[0m\n",
159+
"👉🏽 \u001b[1;34mUsing existing resource group 'lab-mcp-prm-oauth'\u001b[0m\n",
160+
"⚙️ \u001b[1;34mRunning: az deployment group create --name mcp-prm-oauth --resource-group lab-mcp-prm-oauth --template-file main.bicep --parameters params.json \u001b[0m\n",
161+
"\u001b[1;33mDeployment 'mcp-prm-oauth' failed\u001b[0m ⌚ 17:45:31.396062 [3m:47s] WARNING: A new Bicep release is available: v0.45.15. Upgrade now by running \"az bicep upgrade\".\n",
162+
"WARNING: /workspaces/AI-Gateway/labs/mcp-prm-oauth/src/bicep/apim-mcp/mcp-api.bicep(96,5) : Warning BCP037: The property \"backendId\" is not allowed on objects of type \"ApiCreateOrUpdatePropertiesOrApiContractProperties\". Permissible properties include \"apiRevision\", \"apiRevisionDescription\", \"apiType\", \"apiVersion\", \"apiVersionDescription\", \"apiVersionSet\", \"apiVersionSetId\", \"contact\", \"format\", \"license\", \"serviceUrl\", \"sourceApiId\", \"subscriptionKeyParameterNames\", \"termsOfServiceUrl\", \"translateRequiredQueryParameters\", \"value\", \"wsdlSelector\". If this is a resource type definition inaccuracy, report it using https://aka.ms/bicep-type-issues. [https://aka.ms/bicep/core-diagnostics#BCP037]\n",
163+
"/workspaces/AI-Gateway/labs/mcp-prm-oauth/src/bicep/apim-mcp/mcp-api.bicep(101,19) : Warning BCP036: The property \"endpoints\" expected a value of type \"McpEndpoint[] | null\" but the provided value is of type \"object\". If this is a resource type definition inaccuracy, report it using https://aka.ms/bicep-type-issues. [https://aka.ms/bicep/core-diagnostics#BCP036]\n",
164+
"/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(5,7) : Warning no-unused-params: Parameter \"aiServicesConfig\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n",
165+
"/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(6,7) : Warning no-unused-params: Parameter \"modelsConfig\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n",
166+
"/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(9,7) : Warning no-unused-params: Parameter \"inferenceAPIType\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n",
167+
"/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(10,7) : Warning no-unused-params: Parameter \"inferenceAPIPath\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n",
168+
"/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(11,7) : Warning no-unused-params: Parameter \"foundryProjectName\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n",
169+
"/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(15,7) : Warning no-unused-params: Parameter \"encryptionIV\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n",
170+
"/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(19,7) : Warning no-unused-params: Parameter \"encryptionKey\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n",
171+
"/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(22,7) : Warning no-unused-params: Parameter \"oauthScopes\" is declared but never used. [https://aka.ms/bicep/linter-diagnostics#no-unused-params]\n",
172+
"/workspaces/AI-Gateway/labs/mcp-prm-oauth/main.bicep(103,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",
173+
"\n",
174+
"ERROR: {\"status\":\"Failed\",\"error\":{\"code\":\"DeploymentFailed\",\"target\":\"/subscriptions/c15de093-adb5-498b-beda-73764e08f7a9/resourceGroups/lab-mcp-prm-oauth/providers/Microsoft.Resources/deployments/mcp-prm-oauth\",\"message\":\"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.\",\"details\":[{\"code\":\"ResourceDeploymentFailure\",\"target\":\"/subscriptions/c15de093-adb5-498b-beda-73764e08f7a9/resourceGroups/lab-mcp-prm-oauth/providers/Microsoft.Resources/deployments/apimModule\",\"message\":\"The resource write operation failed to complete successfully, because it reached terminal provisioning state 'Failed'.\",\"details\":[{\"code\":\"DeploymentFailed\",\"target\":\"/subscriptions/c15de093-adb5-498b-beda-73764e08f7a9/resourceGroups/lab-mcp-prm-oauth/providers/Microsoft.Resources/deployments/apimModule\",\"message\":\"At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-deployment-operations for usage details.\",\"details\":[{\"code\":\"ServiceAlreadyExistsInSoftDeletedState\",\"message\":\"Api service apim-zarnuffqegamc was soft-deleted. In order to create the new service with the same name, you have to either undelete the service or purge it. See https://aka.ms/apimsoftdelete.\"}]}]}]}}\n",
175+
"\n"
176+
]
177+
}
178+
],
133179
"source": [
134180
"# Create the resource group if doesn't exist\n",
135181
"utils.create_resource_group(resource_group_name, resource_group_location)\n",
@@ -141,6 +187,7 @@
141187
" \"parameters\": {\n",
142188
" \"mcpEntraAppName\": { \"value\": app_registration_name },\n",
143189
" \"apimSku\": { \"value\": apim_sku },\n",
190+
" # \"resourceSuffix\": { \"value\": resource_suffix },\n",
144191
" \"aiServicesConfig\": { \"value\": aiservices_config },\n",
145192
" \"modelsConfig\": { \"value\": models_config },\n",
146193
" \"apimSubscriptionsConfig\": { \"value\": apim_subscriptions_config },\n",
@@ -175,9 +222,36 @@
175222
},
176223
{
177224
"cell_type": "code",
178-
"execution_count": null,
225+
"execution_count": 4,
179226
"metadata": {},
180-
"outputs": [],
227+
"outputs": [
228+
{
229+
"name": "stdout",
230+
"output_type": "stream",
231+
"text": [
232+
"⚙️ \u001b[1;34mRunning: az deployment group show --name mcp-prm-oauth -g lab-mcp-prm-oauth \u001b[0m\n",
233+
"\u001b[1;32mRetrieved deployment: mcp-prm-oauth\u001b[0m ⌚ 17:45:39.954978 [0m:8s]\n",
234+
"\u001b[1;33mFailed to retrieve output property: 'logAnalyticsWorkspaceId'\n",
235+
"Error: 'NoneType' object is not subscriptable\u001b[0m ⌚ 17:45:39.955559 \n"
236+
]
237+
},
238+
{
239+
"ename": "Exception",
240+
"evalue": "Failed to retrieve output property: 'logAnalyticsWorkspaceId'\nError: 'NoneType' object is not subscriptable",
241+
"output_type": "error",
242+
"traceback": [
243+
"\u001b[31m---------------------------------------------------------------------------\u001b[39m",
244+
"\u001b[31mTypeError\u001b[39m Traceback (most recent call last)",
245+
"\u001b[36mFile \u001b[39m\u001b[32m/workspaces/AI-Gateway/labs/mcp-prm-oauth/../../shared/utils.py:197\u001b[39m, in \u001b[36mget_deployment_output\u001b[39m\u001b[34m(output, output_property, output_label, secure)\u001b[39m\n\u001b[32m 196\u001b[39m \u001b[38;5;28;01mtry\u001b[39;00m:\n\u001b[32m--> \u001b[39m\u001b[32m197\u001b[39m deployment_output = \u001b[30;43moutput\u001b[39;49m\u001b[30;43m.\u001b[39;49m\u001b[30;43mjson_data\u001b[39;49m\u001b[30;43m[\u001b[39;49m\u001b[30;43m'\u001b[39;49m\u001b[30;43mproperties\u001b[39;49m\u001b[30;43m'\u001b[39;49m\u001b[30;43m]\u001b[39;49m\u001b[30;43m[\u001b[39;49m\u001b[30;43m'\u001b[39;49m\u001b[30;43moutputs\u001b[39;49m\u001b[30;43m'\u001b[39;49m\u001b[30;43m]\u001b[39;49m\u001b[30;43m[\u001b[39;49m\u001b[30;43moutput_property\u001b[39;49m\u001b[30;43m]\u001b[39;49m[\u001b[33m'\u001b[39m\u001b[33mvalue\u001b[39m\u001b[33m'\u001b[39m]\n\u001b[32m 199\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m output_label:\n",
246+
"\u001b[31mTypeError\u001b[39m: 'NoneType' object is not subscriptable",
247+
"\nDuring handling of the above exception, another exception occurred:\n",
248+
"\u001b[31mException\u001b[39m Traceback (most recent call last)",
249+
"\u001b[36mCell\u001b[39m\u001b[36m \u001b[39m\u001b[32mIn[4]\u001b[39m\u001b[32m, line 6\u001b[39m\n\u001b[32m 2\u001b[39m output = utils.run(f\"az deployment group show --name {deployment_name} -g {resource_group_name}\", f\"Retrieved deployment: {deployment_name}\", f\"Failed to retrieve deployment: {deployment_name}\")\n\u001b[32m 3\u001b[39m \n\u001b[32m 4\u001b[39m \u001b[38;5;28;01mif\u001b[39;00m output.success \u001b[38;5;28;01mand\u001b[39;00m output.json_data:\n\u001b[32m 5\u001b[39m \u001b[38;5;66;03m# Monitoring\u001b[39;00m\n\u001b[32m----> \u001b[39m\u001b[32m6\u001b[39m log_analytics_id = utils.get_deployment_output(output, \u001b[33m'logAnalyticsWorkspaceId'\u001b[39m, \u001b[33m'Log Analytics Id'\u001b[39m)\n\u001b[32m 7\u001b[39m app_insights_name = utils.get_deployment_output(output, \u001b[33m'applicationInsightsName'\u001b[39m, \u001b[33m'Application Insights Name'\u001b[39m)\n\u001b[32m 8\u001b[39m app_insights_app_id = utils.get_deployment_output(output, \u001b[33m'applicationInsightsAppId'\u001b[39m, \u001b[33m'Application Insights App Id'\u001b[39m)\n\u001b[32m 9\u001b[39m \n",
250+
"\u001b[36mFile \u001b[39m\u001b[32m/workspaces/AI-Gateway/labs/mcp-prm-oauth/../../shared/utils.py:209\u001b[39m, in \u001b[36mget_deployment_output\u001b[39m\u001b[34m(output, output_property, output_label, secure)\u001b[39m\n\u001b[32m 207\u001b[39m error = \u001b[33mf\u001b[39m\u001b[33m\"\u001b[39m\u001b[33mFailed to retrieve output property: \u001b[39m\u001b[33m'\u001b[39m\u001b[38;5;132;01m{\u001b[39;00moutput_property\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m'\u001b[39m\u001b[38;5;130;01m\\n\u001b[39;00m\u001b[33mError: \u001b[39m\u001b[38;5;132;01m{\u001b[39;00me\u001b[38;5;132;01m}\u001b[39;00m\u001b[33m\"\u001b[39m\n\u001b[32m 208\u001b[39m print_error(error)\n\u001b[32m--> \u001b[39m\u001b[32m209\u001b[39m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mException\u001b[39;00m(error)\n",
251+
"\u001b[31mException\u001b[39m: Failed to retrieve output property: 'logAnalyticsWorkspaceId'\nError: 'NoneType' object is not subscriptable"
252+
]
253+
}
254+
],
181255
"source": [
182256
"# Obtain all of the outputs from the deployment\n",
183257
"output = utils.run(f\"az deployment group show --name {deployment_name} -g {resource_group_name}\", f\"Retrieved deployment: {deployment_name}\", f\"Failed to retrieve deployment: {deployment_name}\")\n",

0 commit comments

Comments
 (0)