Skip to content

Commit c002b17

Browse files
committed
fix: mettre à jour le chemin de l'API PRM et ajuster les sorties du notebook
1 parent 77b1ef2 commit c002b17

2 files changed

Lines changed: 8 additions & 81 deletions

File tree

labs/mcp-prm-oauth/main.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,4 +288,4 @@ output mcpServerURL string = 'https://${mcpServerContainerApp.properties.configu
288288
output mcpAppId string = !empty(mcpClientId) ? mcpClientId : (mcpEntraAppModule.?outputs.mcpAppId ?? 'Not created - provide mcpClientId parameter')
289289
output mcpAppTenantId string = subscription().tenantId
290290
output mcpApiEndpoint string = '${apimModule.outputs.gatewayUrl}/${mcpApiPath}/mcp'
291-
output mcpPrmEndpoint string = '${apimModule.outputs.gatewayUrl}/.well-known/oauth-protected-resource/${mcpApiPath}'
291+
output mcpPrmEndpoint string = '${apimModule.outputs.gatewayUrl}/.well-known/oauth-protected-resource/${mcpApiPath}/mcp'

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

Lines changed: 7 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -49,22 +49,14 @@
4949
"metadata": {
5050
"metadata": {}
5151
},
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-
],
52+
"outputs": [],
6153
"source": [
6254
"import os, sys, json, base64, random, string\n",
6355
"sys.path.insert(1, '../../shared') # add the shared directory to the Python path\n",
6456
"import utils\n",
6557
"\n",
6658
"deployment_name = os.path.basename(os.path.dirname(globals()['__vsc_ipynb_file__']))\n",
67-
"resource_group_name = f\"lab-{deployment_name}-2\" # change the name to match your naming style\n",
59+
"resource_group_name = f\"lab-{deployment_name}-4\" # change the name to match your naming style\n",
6860
"resource_group_location = \"ukwest\"\n",
6961
"resource_suffix = ''.join(random.choices(string.ascii_letters + string.digits, k=8)).lower()\n",
7062
"\n",
@@ -108,21 +100,9 @@
108100
},
109101
{
110102
"cell_type": "code",
111-
"execution_count": 2,
103+
"execution_count": null,
112104
"metadata": {},
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-
],
105+
"outputs": [],
126106
"source": [
127107
"output = utils.run(\"az account show\", \"Retrieved az account\", \"Failed to get the current az account\")\n",
128108
"\n",
@@ -150,32 +130,7 @@
150130
"cell_type": "code",
151131
"execution_count": null,
152132
"metadata": {},
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-
],
133+
"outputs": [],
179134
"source": [
180135
"# Create the resource group if doesn't exist\n",
181136
"utils.create_resource_group(resource_group_name, resource_group_location)\n",
@@ -187,7 +142,6 @@
187142
" \"parameters\": {\n",
188143
" \"mcpEntraAppName\": { \"value\": app_registration_name },\n",
189144
" \"apimSku\": { \"value\": apim_sku },\n",
190-
" # \"resourceSuffix\": { \"value\": resource_suffix },\n",
191145
" \"aiServicesConfig\": { \"value\": aiservices_config },\n",
192146
" \"modelsConfig\": { \"value\": models_config },\n",
193147
" \"apimSubscriptionsConfig\": { \"value\": apim_subscriptions_config },\n",
@@ -222,36 +176,9 @@
222176
},
223177
{
224178
"cell_type": "code",
225-
"execution_count": 4,
179+
"execution_count": null,
226180
"metadata": {},
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-
],
181+
"outputs": [],
255182
"source": [
256183
"# Obtain all of the outputs from the deployment\n",
257184
"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)