@@ -71,13 +71,100 @@ module fetchLatestImage '../modules/fetch-container-image.bicep' = {
71
71
}
72
72
}
73
73
74
- resource app 'Microsoft.App/containerApps@2023-04-01-preview' = {
74
+ resource keyVault 'Microsoft.KeyVault/vaults@2021-06-01-preview' = {
75
+ name : '${substring (name , 0 , 15 )}-keyvault'
76
+ location : location
77
+ properties : {
78
+ sku : {
79
+ family : 'A'
80
+ name : 'standard'
81
+ }
82
+ tenantId : subscription ().tenantId
83
+ accessPolicies : [
84
+ {
85
+ tenantId : subscription ().tenantId
86
+ objectId : app .identity .principalId
87
+ permissions : {
88
+ secrets : [
89
+ 'get'
90
+ ]
91
+ }
92
+ }
93
+ ]
94
+ }
95
+ }
96
+
97
+ resource applicationinsights__connectionstring 'Microsoft.KeyVault/vaults/secrets@2021-06-01-preview' = {
98
+ parent : keyVault
99
+ name : 'applicationinsights--connectionstring'
100
+ properties : {
101
+ value : applicationInsights .properties .ConnectionString
102
+ }
103
+ }
104
+
105
+ resource apiKey 'Microsoft.KeyVault/vaults/secrets@2021-06-01-preview' = {
106
+ parent : keyVault
107
+ name : 'apiKey'
108
+ properties :{
109
+ value : cognitiveAccount .listKeys ().key1
110
+ }
111
+ }
112
+
113
+ resource azure__openai__endpoint 'Microsoft.KeyVault/vaults/secrets@2021-06-01-preview' = {
114
+ parent : keyVault
115
+ name : 'azure--openai--endpoint'
116
+ properties :{
117
+ value : cognitiveAccount .properties .endpoint
118
+ }
119
+ }
120
+
121
+ resource aoai__resourcename 'Microsoft.KeyVault/vaults/secrets@2021-06-01-preview' = {
122
+ parent : keyVault
123
+ name : 'aoai--resourcename'
124
+ properties :{
125
+ value : cognitiveAccount .name
126
+ }
127
+ }
128
+
129
+ resource aoai__embedding__deploymentname 'Microsoft.KeyVault/vaults/secrets@2021-06-01-preview' = {
130
+ parent : keyVault
131
+ name : 'aoai--embedding--deploymentname'
132
+ properties : {
133
+ value : '${name }-textembedding'
134
+ }
135
+ }
136
+
137
+ resource api__url 'Microsoft.KeyVault/vaults/secrets@2021-06-01-preview' = {
138
+ parent : keyVault
139
+ name : 'api--url'
140
+ properties :{
141
+ value : '${cognitiveAccount .properties .endpoint }openai/deployments/Dalle3/images/generations?api-version=2024-02-01'
142
+ }
143
+ }
144
+
145
+ resource redis__cache__connection 'Microsoft.KeyVault/vaults/secrets@2021-06-01-preview' = {
146
+ parent : keyVault
147
+ name : 'redis--cache--connection'
148
+ properties : {
149
+ value : '${redisCache .properties .hostName }:10000,password=${redisdatabase .listKeys ().primaryKey },ssl=True,abortConnect=False'
150
+ }
151
+ }
152
+
153
+ resource semantic__cache__azure__provider 'Microsoft.KeyVault/vaults/secrets@2021-06-01-preview' = {
154
+ parent : keyVault
155
+ name : 'semantic--cache--azure--provider'
156
+ properties : {
157
+ value : 'rediss://:${redisdatabase .listKeys ().primaryKey }@${redisCache .properties .hostName }:10000'
158
+ }
159
+ }
160
+
161
+ resource app 'Microsoft.App/containerApps@2024-03-01' = {
75
162
name : name
76
163
location : location
77
164
tags : union (tags , {'azd-service-name' : 'OutputCacheDallESample' })
78
165
dependsOn : [ acrPullRole ]
79
166
identity : {
80
- type : 'UserAssigned'
167
+ type : 'UserAssigned, SystemAssigned '
81
168
userAssignedIdentities : { '${identity .id }' : {} }
82
169
}
83
170
properties : {
@@ -95,6 +182,38 @@ resource app 'Microsoft.App/containerApps@2023-04-01-preview' = {
95
182
}
96
183
]
97
184
secrets : [
185
+ {
186
+ name : 'applicationinsights--connectionstring'
187
+ value : applicationInsights .properties .ConnectionString
188
+ }
189
+ {
190
+ name : 'api--key'
191
+ value : cognitiveAccount .listKeys ().key1
192
+ }
193
+ {
194
+ name : 'azure--openai--endpoint'
195
+ value : cognitiveAccount .properties .endpoint
196
+ }
197
+ {
198
+ name : 'aoai--resourcename'
199
+ value : cognitiveAccount .name
200
+ }
201
+ {
202
+ name : 'aoai--embedding--deploymentname'
203
+ value : '${name }-textembedding'
204
+ }
205
+ {
206
+ name : 'api--url'
207
+ value : '${cognitiveAccount .properties .endpoint }openai/deployments/Dalle3/images/generations?api-version=2024-02-01'
208
+ }
209
+ {
210
+ name : 'redis--cache--connection'
211
+ value : '${redisCache .properties .hostName }:10000,password=${redisdatabase .listKeys ().primaryKey },ssl=True,abortConnect=False'
212
+ }
213
+ {
214
+ name : 'semantic--cache--azure--provider'
215
+ value : 'rediss://:${redisdatabase .listKeys ().primaryKey }@${redisCache .properties .hostName }:10000'
216
+ }
98
217
]
99
218
}
100
219
template : {
@@ -105,39 +224,39 @@ resource app 'Microsoft.App/containerApps@2023-04-01-preview' = {
105
224
env : [
106
225
{
107
226
name : 'APPLICATIONINSIGHTS_CONNECTION_STRING'
108
- value : applicationInsights . properties . ConnectionString
227
+ secretRef : 'applicationinsights--connectionstring'
109
228
}
110
229
{
111
230
name : 'PORT'
112
231
value : '8080'
113
232
}
114
233
{
115
234
name : 'apiKey'
116
- value : cognitiveAccount . listKeys (). key1
235
+ secretRef : 'api--key'
117
236
}
118
237
{
119
238
name : 'AZURE_OPENAI_ENDPOINT'
120
- value : cognitiveAccount . properties . endpoint
239
+ secretRef : 'azure--openai-- endpoint'
121
240
}
122
241
{
123
242
name : 'AOAIResourceName'
124
- value : cognitiveAccount . name
243
+ secretRef : 'aoai--resourcename'
125
244
}
126
245
{
127
246
name : 'AOAIEmbeddingDeploymentName'
128
- value : '${ name }-textembedding '
247
+ secretRef : 'aoai--embedding--deploymentname '
129
248
}
130
249
{
131
250
name : 'apiUrl'
132
- value : '${ cognitiveAccount . properties . endpoint }openai/deployments/Dalle3/images/generations? api-version=2024-02-01 '
251
+ secretRef : 'api--url '
133
252
}
134
253
{
135
254
name : 'RedisCacheConnection'
136
- value : '${ redisCache . properties . hostName }:10000,password=${ redisdatabase . listKeys (). primaryKey },ssl=True,abortConnect=False '
255
+ secretRef : 'redis--cache--connection '
137
256
}
138
257
{
139
258
name :'SemanticCacheAzureProvider'
140
- value : 'rediss://:${ redisdatabase . listKeys (). primaryKey }@${ redisCache . properties . hostName }:10000 '
259
+ secretRef : 'semantic--cache--azure--provider '
141
260
}
142
261
]
143
262
resources : {
@@ -188,13 +307,33 @@ resource model 'Microsoft.CognitiveServices/accounts/deployments@2023-05-01' = [
188
307
}
189
308
}]
190
309
310
+ resource openai_CognitiveServicesOpenAIUser 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
311
+ name : guid (cognitiveAccount .id , identity .id , subscriptionResourceId ('Microsoft.Authorization/roleDefinitions' , '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd' ))
312
+ properties : {
313
+ principalId : identity .properties .principalId
314
+ roleDefinitionId : subscriptionResourceId ('Microsoft.Authorization/roleDefinitions' , '5e0bd9bd-7b93-4f28-af87-19fc36ad61bd' )
315
+ principalType : 'ServicePrincipal'
316
+ }
317
+ scope : cognitiveAccount
318
+ }
319
+
320
+ resource openai_CognitiveServicesOpenAIContributor 'Microsoft.Authorization/roleAssignments@2022-04-01' = {
321
+ name : guid (cognitiveAccount .id , app .id , subscriptionResourceId ('Microsoft.Authorization/roleDefinitions' , 'a001fd3d-188f-4b5d-821b-7da978bf7442' ))
322
+ properties : {
323
+ principalId : app .identity .principalId
324
+ roleDefinitionId : subscriptionResourceId ('Microsoft.Authorization/roleDefinitions' , 'a001fd3d-188f-4b5d-821b-7da978bf7442' )
325
+ principalType : 'ServicePrincipal'
326
+ }
327
+ scope : cognitiveAccount
328
+ }
329
+
191
330
//azure cache for redis resource
192
331
resource redisCache 'Microsoft.Cache/redisEnterprise@2024-02-01' = {
193
332
location :location
194
333
name : '${name }-rediscache'
195
334
sku :{
196
335
capacity :2
197
- name : 'Enterprise_E10 '
336
+ name : 'Enterprise_E1 '
198
337
}
199
338
}
200
339
resource redisdatabase 'Microsoft.Cache/redisEnterprise/databases@2024-02-01' = {
0 commit comments