Skip to content

Commit 0380748

Browse files
committed
ci: fix role assignements
1 parent d91297c commit 0380748

File tree

3 files changed

+31
-19
lines changed

3 files changed

+31
-19
lines changed

infra/app/llama-index-nextjs.bicep

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ param containerRegistryName string
77
param containerAppsEnvironmentName string
88
param applicationInsightsName string
99
param exists bool
10+
11+
@description('Whether the deployment is running on GitHub Actions')
12+
param runningOnGh string = ''
13+
1014
@secure()
1115
param appDefinition object
1216

@@ -42,17 +46,31 @@ resource acrPullRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
4246
scope: containerRegistry
4347
name: guid(subscription().id, resourceGroup().id, identity.id, 'acrPullRole')
4448
properties: {
45-
roleDefinitionId: subscriptionResourceId(
46-
'Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d')
49+
roleDefinitionId: '7f951dda-4ed3-4680-a7ca-43fe172d538d'
4750
principalType: 'ServicePrincipal'
4851
principalId: identity.properties.principalId
4952
}
5053
}
5154

55+
56+
// Roles
57+
58+
// User roles
59+
module openAiRoleUser '../shared/role.bicep' = if (empty(runningOnGh)) {
60+
scope: resourceGroup()
61+
name: guid(subscription().id, resourceGroup().id, identity.id, 'openaiUserRole')
62+
params: {
63+
principalId: app.identity.principalId
64+
// Cognitive Services OpenAI User
65+
roleDefinitionId: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
66+
principalType: 'User'
67+
}
68+
}
69+
5270
// System roles
5371
module openAiRole '../shared/role.bicep' = {
5472
scope: resourceGroup()
55-
name: guid(subscription().id, resourceGroup().id, identity.id, 'openaiUserRole')
73+
name: guid(subscription().id, resourceGroup().id, identity.id, 'openaiServicePrincipalRole')
5674
params: {
5775
principalId: app.identity.principalId
5876
// Cognitive Services OpenAI User

infra/main.bicep

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ param environmentName string
99
@description('Primary location for all resources')
1010
param location string
1111

12+
@description('Whether the deployment is running on GitHub Actions')
13+
param runningOnGh string = ''
14+
1215
param llamaIndexNextjsExists bool
1316
@secure()
1417
param llamaIndexNextjsDefinition object
@@ -154,26 +157,13 @@ module openAi './shared/cognitiveservices.bicep' = if (empty(openAiUrl)) {
154157
}
155158
}
156159

157-
// Roles
158-
159-
// User roles
160-
module openAiRoleUser './shared/role.bicep' = {
161-
scope: rg
162-
name: 'openai-role-user'
163-
params: {
164-
principalId: principalId
165-
// Cognitive Services OpenAI User
166-
roleDefinitionId: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
167-
principalType: 'User'
168-
}
169-
}
170-
171160
module llamaIndexNextjs './app/llama-index-nextjs.bicep' = {
172161
name: 'llama-index-nextjs'
173162
params: {
174163
name: '${abbrs.appContainerApps}llama-index-${resourceToken}'
175164
location: location
176165
tags: tags
166+
runningOnGh: runningOnGh
177167
identityName: '${abbrs.managedIdentityUserAssignedIdentities}llama-index-${resourceToken}'
178168
applicationInsightsName: monitoring.outputs.applicationInsightsName
179169
containerAppsEnvironmentName: appsEnv.outputs.name
@@ -237,6 +227,10 @@ module llamaIndexNextjs './app/llama-index-nextjs.bicep' = {
237227
name: 'SYSTEM_PROMPT'
238228
value: llamaIndexConfig.system_prompt
239229
}
230+
{
231+
name: 'OPENAI_API_TYPE'
232+
value: 'AzureOpenAI'
233+
}
240234
]
241235
})
242236
}

infra/main.parameters.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
"openAiApiVersion": {
2626
"value": "${AZURE_OPENAI_API_VERSION=2024-02-15-preview}"
2727
},
28-
"isContinuousDeployment": {
29-
"value": "${CI=false}"
28+
"runningOnGh": {
29+
"value": "${GITHUB_ACTIONS}"
3030
},
3131
"azureDeploymentName": {
3232
"value": "${AZURE_DEPLOYMENT_NAME=gpt-35-turbo}"

0 commit comments

Comments
 (0)