Skip to content

Commit 6b0b574

Browse files
fix for disable local auth issues
1 parent 51c2d70 commit 6b0b574

File tree

3 files changed

+31
-14
lines changed

3 files changed

+31
-14
lines changed

infra/deploy_ai_foundry.bicep

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ param gptModelName string
66
param gptModelVersion string
77
param managedIdentityObjectId string
88
param aiServicesEndpoint string
9-
param aiServices object
9+
param aiServicesKey string
1010
param aiServicesId string
1111

1212
var storageName = '${solutionName}hubstorage'
@@ -133,11 +133,8 @@ resource aiHub 'Microsoft.MachineLearningServices/workspaces@2023-08-01-preview'
133133
properties: {
134134
category: 'AIServices'
135135
target: aiServicesEndpoint
136-
authType: 'ApiKey'
136+
authType: 'AAD'
137137
isSharedToAll: true
138-
credentials: {
139-
key: aiServices.Key.key1
140-
}
141138
metadata: {
142139
ApiType: 'Azure'
143140
ResourceId: aiServicesId
@@ -187,7 +184,7 @@ resource azureOpenAIApiKeyEntry 'Microsoft.KeyVault/vaults/secrets@2021-11-01-pr
187184
parent: keyVault
188185
name: 'AZURE-OPENAI-KEY'
189186
properties: {
190-
value: aiServices.Key.key1 //aiServices_m.listKeys().key1
187+
value: aiServicesKey //aiServices_m.listKeys().key1
191188
}
192189
}
193190

@@ -251,7 +248,7 @@ resource cogServiceKeyEntry 'Microsoft.KeyVault/vaults/secrets@2021-11-01-previe
251248
parent: keyVault
252249
name: 'COG-SERVICES-KEY'
253250
properties: {
254-
value: aiServices.Key.key1
251+
value: aiServicesKey
255252
}
256253
}
257254

infra/main.bicep

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ module aifoundry 'deploy_ai_foundry.bicep' = {
168168
gptModelVersion: gptModelVersion
169169
managedIdentityObjectId: managedIdentityModule.outputs.managedIdentityOutput.objectId
170170
aiServicesEndpoint: aiServices.properties.endpoint
171-
aiServices: aiServices
171+
aiServicesKey: aiServices.listKeys().key1
172172
aiServicesId: aiServices.id
173173
}
174174
scope: resourceGroup(resourceGroup().name)
@@ -462,6 +462,15 @@ resource aiDeveloperAccessProj 'Microsoft.Authorization/roleAssignments@2022-04-
462462
}
463463
}
464464

465+
resource aiDevelopertoAIProject 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
466+
name: guid(aiServices.name, aiHubProject.id, aiDeveloper.id)
467+
scope: aiServices
468+
properties: {
469+
roleDefinitionId: aiDeveloper.id
470+
principalId: aiHubProject.identity.principalId
471+
}
472+
}
473+
465474
var cosmosAssignCli = 'az cosmosdb sql role assignment create --resource-group "${resourceGroup().name}" --account-name "${cosmos.name}" --role-definition-id "${cosmos::contributorRoleDefinition.id}" --scope "${cosmos.id}" --principal-id "${containerApp.identity.principalId}"'
466475

467476
module managedIdentityModule 'deploy_managed_identity.bicep' = {

infra/main.json

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"_generator": {
77
"name": "bicep",
88
"version": "0.35.1.17967",
9-
"templateHash": "18228555099764132241"
9+
"templateHash": "8798142813454376636"
1010
}
1111
},
1212
"parameters": {
@@ -546,6 +546,20 @@
546546
"containerApp"
547547
]
548548
},
549+
"aiDevelopertoAIProject": {
550+
"type": "Microsoft.Authorization/roleAssignments",
551+
"apiVersion": "2022-04-01",
552+
"scope": "[format('Microsoft.CognitiveServices/accounts/{0}', variables('aiServicesName'))]",
553+
"name": "[guid(variables('aiServicesName'), resourceId('Microsoft.MachineLearningServices/workspaces', format('{0}-aiproject', parameters('prefix'))), resourceId('Microsoft.Authorization/roleDefinitions', '64702f94-c441-49e6-a78b-ef80e0188fee'))]",
554+
"properties": {
555+
"roleDefinitionId": "[resourceId('Microsoft.Authorization/roleDefinitions', '64702f94-c441-49e6-a78b-ef80e0188fee')]",
556+
"principalId": "[reference('aiHubProject', '2024-01-01-preview', 'full').identity.principalId]"
557+
},
558+
"dependsOn": [
559+
"aiHubProject",
560+
"aiServices"
561+
]
562+
},
549563
"kvault": {
550564
"type": "Microsoft.Resources/deployments",
551565
"apiVersion": "2022-09-01",
@@ -712,7 +726,7 @@
712726
"_generator": {
713727
"name": "bicep",
714728
"version": "0.35.1.17967",
715-
"templateHash": "9490638595753234802"
729+
"templateHash": "12578060348489775267"
716730
}
717731
},
718732
"parameters": {
@@ -767,11 +781,8 @@
767781
"properties": {
768782
"category": "AIServices",
769783
"target": "[parameters('aiServicesEndpoint')]",
770-
"authType": "ApiKey",
784+
"authType": "AAD",
771785
"isSharedToAll": true,
772-
"credentials": {
773-
"key": "[parameters('aiServicesKey')]"
774-
},
775786
"metadata": {
776787
"ApiType": "Azure",
777788
"ResourceId": "[parameters('aiServicesId')]"

0 commit comments

Comments
 (0)