Skip to content

Commit

Permalink
Merge pull request #438 from microsoft/ryonsteele/6373-aoai-kv-hf
Browse files Browse the repository at this point in the history
Resolve issue with aoai key reference when not using existing deployment
  • Loading branch information
ryonsteele authored Jan 9, 2024
2 parents 45a02ea + d9b0d90 commit ce90232
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
13 changes: 13 additions & 0 deletions infra/core/ai/cognitiveservices.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ param customSubDomainName string = name
param deployments array = []
param kind string = 'OpenAI'
param publicNetworkAccess string = 'Enabled'
param keyVaultName string
param sku object = {
name: 'S0'
}
Expand Down Expand Up @@ -36,6 +37,18 @@ resource deployment 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01
}
}]

resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' existing = if (!(empty(keyVaultName))) {
name: keyVaultName
}

resource openaiServiceKeySecret 'Microsoft.KeyVault/vaults/secrets@2019-09-01' = {
parent: keyVault
name: 'AZURE-OPENAI-SERVICE-KEY'
properties: {
value: account.listKeys().key1
}
}

output endpoint string = account.properties.endpoint
output id string = account.id
output name string = account.name
3 changes: 2 additions & 1 deletion infra/core/security/keyvault.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ param kvAccessObjectId string
param openaiServiceKey string
@secure()
param spClientSecret string
param useExistingAOAIService bool



Expand Down Expand Up @@ -33,7 +34,7 @@ resource kv 'Microsoft.KeyVault/vaults@2019-09-01' = {
}
}

resource openaiServiceKeySecret 'Microsoft.KeyVault/vaults/secrets@2019-09-01' = {
resource openaiServiceKeySecret 'Microsoft.KeyVault/vaults/secrets@2019-09-01' = if (useExistingAOAIService){
parent: kv
name: 'AZURE-OPENAI-SERVICE-KEY'
properties: {
Expand Down
2 changes: 2 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ module cognitiveServices 'core/ai/cognitiveservices.bicep' = if (!useExistingAOA
name: !empty(openAiServiceName) ? openAiServiceName : '${prefix}-${abbrs.openAIServices}${randomString}'
location: location
tags: tags
keyVaultName: kvModule.outputs.keyVaultName
sku: {
name: openAiSkuName
}
Expand Down Expand Up @@ -711,6 +712,7 @@ module kvModule 'core/security/keyvault.bicep' = {
kvAccessObjectId: kvAccessObjectId
openaiServiceKey: azureOpenAIServiceKey
spClientSecret: aadMgmtClientSecret
useExistingAOAIService: useExistingAOAIService
}
}

Expand Down

0 comments on commit ce90232

Please sign in to comment.