Skip to content

Commit 3956e36

Browse files
add apim connection project managed identity (#461)
* chnages for pmi * add mi * update * update * update * update azure ai url --------- Co-authored-by: vtomar <vtomar@microsoft.com>
1 parent 49cafb3 commit 3956e36

File tree

7 files changed

+21
-17
lines changed

7 files changed

+21
-17
lines changed

infrastructure/infrastructure-setup-bicep/01-connections/apim/connection-apim.bicep

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ param connectionName string = ''
4343
@description('APIM subscription name for API key auth')
4444
param apimSubscriptionName string = 'master'
4545

46-
@allowed(['ApiKey'])
46+
@allowed(['ApiKey', 'ProjectManagedIdentity'])
4747
@description('Authentication type')
4848
param authType string = 'ApiKey'
4949

infrastructure/infrastructure-setup-bicep/01-connections/apim/modules/apim-connection-common.bicep

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,23 @@ resource connectionApiKey 'Microsoft.CognitiveServices/accounts/projects/connect
7474
}
7575
}
7676

77-
// TODO: Future AAD connection (when role assignments are implemented)
78-
// resource connectionAAD 'Microsoft.CognitiveServices/accounts/projects/connections@2025-04-01-preview' = if (authType == 'AAD') {
79-
// name: connectionName
80-
// parent: aiProject
81-
// properties: {
82-
// category: 'ApiManagement'
83-
// target: '${existingApim.properties.gatewayUrl}/${apimApi.properties.path}'
84-
// authType: 'AAD'
85-
// isSharedToAll: isSharedToAll
86-
// credentials: {}
87-
// metadata: metadata
88-
// }
89-
// }
77+
resource connectionAAD 'Microsoft.CognitiveServices/accounts/projects/connections@2025-04-01-preview' = if (authType == 'ProjectManagedIdentity') {
78+
name: connectionName
79+
parent: aiProject
80+
properties: {
81+
category: 'ApiManagement'
82+
target: '${existingApim.properties.gatewayUrl}/${apimApi.properties.path}'
83+
authType: 'ProjectManagedIdentity'
84+
audience: 'https://cognitiveservices.azure.com'
85+
isSharedToAll: isSharedToAll
86+
credentials: {}
87+
metadata: metadata
88+
}
89+
}
9090

9191
// Outputs (only from the created connection)
92-
output connectionName string = authType == 'ApiKey' ? connectionApiKey.name : ''
93-
output connectionId string = authType == 'ApiKey' ? connectionApiKey.id : ''
92+
output connectionName string = authType == 'ApiKey' ? connectionApiKey.name : connectionAAD.name
93+
output connectionId string = authType == 'ApiKey' ? connectionApiKey.id : connectionApiKey.name
9494
output targetUrl string = '${existingApim.properties.gatewayUrl}/${apimApi.properties.path}'
9595
output authType string = authType
9696
output metadata object = metadata

infrastructure/infrastructure-setup-bicep/01-connections/apim/samples/parameters-custom-auth-config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"value": "YOUR-CONNECTION-NAME"
1616
},
1717
"authType": {
18+
"_comment": "Set to ApiKey or ProjectManagedIdentity",
1819
"value": "ApiKey"
1920
},
2021
"isSharedToAll": {

infrastructure/infrastructure-setup-bicep/01-connections/apim/samples/parameters-custom-headers.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"value": "YOUR-CONNECTION-NAME"
1616
},
1717
"authType": {
18+
"_comment": "Set to ApiKey or ProjectManagedIdentity",
1819
"value": "ApiKey"
1920
},
2021
"isSharedToAll": {

infrastructure/infrastructure-setup-bicep/01-connections/apim/samples/parameters-dynamic-discovery.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"value": "YOUR-CONNECTION-NAME"
1616
},
1717
"authType": {
18+
"_comment": "Set to ApiKey or ProjectManagedIdentity",
1819
"value": "ApiKey"
1920
},
2021
"isSharedToAll": {

infrastructure/infrastructure-setup-bicep/01-connections/apim/samples/parameters-static-models.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"value": "YOUR-CONNECTION-NAME"
1616
},
1717
"authType": {
18+
"_comment": "Set to ApiKey or ProjectManagedIdentity",
1819
"value": "ApiKey"
1920
},
2021
"isSharedToAll": {

infrastructure/infrastructure-setup-bicep/01-connections/model-gateway/samples/parameters-foundryazureai.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"value": "/subscriptions/YOUR-SUBSCRIPTION-ID/resourceGroups/YOUR-RG/providers/Microsoft.CognitiveServices/accounts/YOUR-AI-FOUNDRY-ACCOUNT/projects/YOUR-PROJECT"
77
},
88
"targetUrl": {
9-
"value": "https://<your-foundry-resource>.openai.azure.com/openai"
9+
"value": "https://<your-foundry-resource>.services.ai.azure.com/models"
1010
},
1111
"gatewayName": {
1212
"value": "YOUR-GATEWAY-NAME"

0 commit comments

Comments
 (0)