Skip to content

Commit 52025d3

Browse files
committed
ci: fix role assignements
1 parent f684ff6 commit 52025d3

File tree

3 files changed

+36
-21
lines changed

3 files changed

+36
-21
lines changed

infra/app/llama-index-nextjs.bicep

+26-5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ 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+
14+
@description('Id of the user or app to assign application roles')
15+
param principalId string = ''
16+
1017
@secure()
1118
param appDefinition object
1219

@@ -42,17 +49,31 @@ resource acrPullRole 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
4249
scope: containerRegistry
4350
name: guid(subscription().id, resourceGroup().id, identity.id, 'acrPullRole')
4451
properties: {
45-
roleDefinitionId: subscriptionResourceId(
46-
'Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d')
47-
principalType: 'ServicePrincipal'
4852
principalId: identity.properties.principalId
53+
roleDefinitionId: '7f951dda-4ed3-4680-a7ca-43fe172d538d'
54+
principalType: 'ServicePrincipal'
4955
}
5056
}
5157

52-
// System roles
53-
module openAiRole '../shared/role.bicep' = {
58+
59+
// Roles
60+
61+
// User roles
62+
module openAiRoleUser '../shared/role.bicep' = if (empty(runningOnGh)) {
5463
scope: resourceGroup()
5564
name: guid(subscription().id, resourceGroup().id, identity.id, 'openaiUserRole')
65+
params: {
66+
principalId: principalId
67+
// Cognitive Services OpenAI User
68+
roleDefinitionId: '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd'
69+
principalType: 'User'
70+
}
71+
}
72+
73+
// System roles
74+
module openAiRoleBackend '../shared/role.bicep' = {
75+
scope: resourceGroup()
76+
name: guid(subscription().id, resourceGroup().id, identity.id, 'openaiServicePrincipalRole')
5677
params: {
5778
principalId: app.identity.principalId
5879
// Cognitive Services OpenAI User

infra/main.bicep

+8-14
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

+2-2
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)