Skip to content

Commit 5608c38

Browse files
committed
fix: ajouter le chemin de l'API MCP et mettre à jour les paramètres de déploiement
1 parent 8b46bfc commit 5608c38

4 files changed

Lines changed: 17 additions & 7 deletions

File tree

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
"encryption_iv = base64.b64encode(os.urandom(16)).decode('utf-8')\n",
8383
"encryption_key = base64.b64encode(os.urandom(16)).decode('utf-8')\n",
8484
"oauth_scopes = 'openid https://graph.microsoft.com/.default'\n",
85+
"mcpApiPath = \"profile\" # path to the MCP API in the APIM service\n",
8586
"\n",
8687
"utils.print_ok('Notebook initialized')\n"
8788
]
@@ -147,6 +148,7 @@
147148
" \"inferenceAPIType\": { \"value\": inference_api_type },\n",
148149
" \"foundryProjectName\": { \"value\": foundry_project_name },\n",
149150
" \"oauthScopes\": { \"value\": oauth_scopes },\n",
151+
" \"mcpApiPath\": { \"value\": mcpApiPath },\n",
150152
" \"encryptionIV\": { \"value\": encryption_iv },\n",
151153
" \"encryptionKey\": { \"value\": encryption_key },\n",
152154
" }\n",

labs/mcp-prm-oauth/src/bicep/apim-mcp/mcp-api.bicep

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,15 @@ resource mcpApiPathNamedValue 'Microsoft.ApiManagement/service/namedValues@2021-
7878

7979
resource mcpBackendServerUrl 'Microsoft.ApiManagement/service/backends@2025-09-01-preview' = {
8080
parent: apimService
81-
name: 'GraphProfileBackend'
81+
name: '${webAppName}-mcp-backend'
8282
properties: {
8383
url: 'https://${containerApp.properties.configuration.ingress.fqdn}'
8484
protocol: 'http'
85+
tls: {
86+
validateCertificateChain: true
87+
validateCertificateName: true
88+
}
89+
type: 'Single'
8590
}
8691
}
8792

@@ -93,9 +98,9 @@ resource mcpApi 'Microsoft.ApiManagement/service/apis@2025-09-01-preview' = {
9398
displayName: '${webAppName} MCP Server'
9499
type: 'mcp'
95100
subscriptionRequired: false
96-
description: 'MCP API for ${webAppName} showing authenticated user profile info'
97-
path: mcpApiPath
98101
backendId: mcpBackendServerUrl.name
102+
description: 'MCP API for ${webAppName} showing authenticated user profile info'
103+
path: mcpApiPath
99104
protocols: ['https']
100105
mcpProperties: {
101106
endpoints : {
@@ -104,6 +109,10 @@ resource mcpApi 'Microsoft.ApiManagement/service/apis@2025-09-01-preview' = {
104109
}
105110
}
106111
}
112+
authenticationSettings: {
113+
oAuth2AuthenticationSettings: []
114+
openidAuthenticationSettings: []
115+
}
107116
isCurrent: true
108117
}
109118
}

labs/mcp-prm-oauth/src/bicep/apim-mcp/mcp-api.policy.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<policies>
77
<inbound>
88
<base />
9+
<!-- Validate Azure AD JWT Token -->
10+
911
<validate-azure-ad-token tenant-id="{{McpTenantId}}" failed-validation-httpcode="401" failed-validation-error-message="Unauthorized">
1012
<audiences>
1113
<audience>{{McpClientId}}</audience>

labs/mcp-prm-oauth/src/bicep/identity/mcp-entra-app.bicep

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ resource mcpEntraApp 'Microsoft.Graph/applications@v1.0' = {
4747
requestedAccessTokenVersion: 2
4848
preAuthorizedApplications: [
4949
{
50-
appId: 'aebc6443-996d-45c2-90f0-388ff96faa56' // visual studio code well known client id for OAuth2.0 authorization code flow
50+
appId: 'aebc6443-996d-45c2-90f0-388ff96faa56' // Visual studio code well known client id for OAuth2.0 authorization code flow
5151
delegatedPermissionIds: [
5252
guid(mcpAppUniqueName, 'user_impersonate')
5353
]
@@ -90,9 +90,6 @@ resource mcpEntraApp 'Microsoft.Graph/applications@v1.0' = {
9090
}
9191
}
9292

93-
// Service principal for the MCP application.
94-
// Referencing mcpEntraApp.appId here also forces the Graph extension to resolve the
95-
// read-only 'appId' property so the mcpAppId output below can be evaluated.
9693
resource mcpServicePrincipal 'Microsoft.Graph/servicePrincipals@v1.0' = {
9794
appId: mcpEntraApp.appId
9895
}

0 commit comments

Comments
 (0)