1+
2+ /* *************************************************************** */
3+ /* Parameters */
4+ /* *************************************************************** */
5+
16@description ('Location where all resources will be deployed. This value defaults to the **East US** region.' )
27@allowed ([
38 'eastus'
@@ -18,6 +23,13 @@ The name defaults to a unique string generated from the resource group identifie
1823@maxLength (15 )
1924param name string = uniqueString (resourceGroup ().id )
2025
26+ @description ('Specifies the SKU for the Azure App Service plan. Defaults to **B1**' )
27+ @allowed ([
28+ 'B1'
29+ 'S1'
30+ ])
31+ param appServiceSku string = 'B1'
32+
2133@description ('Specifies the SKU for the Azure OpenAI resource. Defaults to **S0**' )
2234@allowed ([
2335 'S0'
@@ -33,6 +45,20 @@ param mongoDbUserName string
3345@secure ()
3446param mongoDbPassword string
3547
48+
49+
50+ /*
51+ @description('Git repository URL for the application source. This defaults to the [`solliancenet/cosmos-db-openai-python-dev-guide-labs`](https://github.com/solliancenet/cosmos-db-openai-python-dev-guide-labs.git) repository.')
52+ param appGitRepository string = 'https://github.com/solliancenet/cosmos-db-openai-python-dev-guide-labs.git'
53+
54+ @description('Git repository branch for the application source. This defaults to the [**main** branch of the `solliancenet/cosmos-db-openai-python-dev-guide-labs`](https://github.com/solliancenet/cosmos-db-openai-python-dev-guide-labs/tree/main) repository.')
55+ param appGetRepositoryBranch string = 'main'
56+ */
57+
58+ /* *************************************************************** */
59+ /* Variables */
60+ /* *************************************************************** */
61+
3662var openAiSettings = {
3763 name : '${name }-openai'
3864 sku : openAiSku
@@ -60,6 +86,33 @@ var mongovCoreSettings = {
6086 mongoClusterPassword : mongoDbPassword
6187}
6288
89+ var appServiceSettings = {
90+ plan : {
91+ name : '${name }-web-plan'
92+ sku : appServiceSku
93+ }
94+ web : {
95+ name : '${name }-web'
96+ git : {
97+ repo : appGitRepository
98+ branch : appGetRepositoryBranch
99+ }
100+ }
101+ function : {
102+ name : '${name }-function'
103+ git : {
104+ repo : appGitRepository
105+ branch : appGetRepositoryBranch
106+ }
107+ }
108+ }
109+
110+
111+
112+ /* *************************************************************** */
113+ /* Azure Cosmos DB for MongoDB vCore */
114+ /* *************************************************************** */
115+
63116resource mongoCluster 'Microsoft.DocumentDB/mongoClusters@2023-03-01-preview' = {
64117 name : mongovCoreSettings .mongoClusterName
65118 location : location
@@ -97,6 +150,11 @@ resource mongoFirewallRulesAllowAll 'Microsoft.DocumentDB/mongoClusters/firewall
97150 }
98151}
99152
153+
154+ /* *************************************************************** */
155+ /* Azure OpenAI */
156+ /* *************************************************************** */
157+
100158resource openAiAccount 'Microsoft.CognitiveServices/accounts@2022-12-01' = {
101159 name : openAiSettings .name
102160 location : location
@@ -142,3 +200,151 @@ resource openAiCompletionsModelDeployment 'Microsoft.CognitiveServices/accounts/
142200 openAiEmbeddingsModelDeployment
143201 ]
144202}
203+
204+
205+
206+
207+ /* *************************************************************** */
208+ /* App Hosting - Azure App Service */
209+ /* *************************************************************** */
210+
211+ resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
212+ name : appServiceSettings .plan .name
213+ location : location
214+ sku : {
215+ name : appServiceSettings .plan .sku
216+ }
217+ }
218+
219+ resource appServiceWeb 'Microsoft.Web/sites@2022-03-01' = {
220+ name : appServiceSettings .web .name
221+ location : location
222+ properties : {
223+ serverFarmId : appServicePlan .id
224+ httpsOnly : true
225+ }
226+ }
227+
228+ resource storageAccount 'Microsoft.Storage/storageAccounts@2021-09-01' = {
229+ name : '${name }fnstorage'
230+ location : location
231+ kind : 'Storage'
232+ sku : {
233+ name : 'Standard_LRS'
234+ }
235+ }
236+
237+ resource appServiceWebSettings 'Microsoft.Web/sites/config@2022-03-01' = {
238+ parent : appServiceWeb
239+ name : 'appsettings'
240+ kind : 'string'
241+ properties : {
242+ APPINSIGHTS_INSTRUMENTATIONKEY : appServiceWebInsights .properties .InstrumentationKey
243+ OPENAI__ENDPOINT : openAiAccount .properties .endpoint
244+ OPENAI__KEY : openAiAccount .listKeys ().key1
245+ OPENAI__EMBEDDINGSDEPLOYMENT : openAiEmbeddingsModelDeployment .name
246+ OPENAI__COMPLETIONSDEPLOYMENT : openAiCompletionsModelDeployment .name
247+ OPENAI__MAXCONVERSATIONTOKENS : openAiSettings .maxConversationTokens
248+ OPENAI__MAXCOMPLETIONTOKENS : openAiSettings .maxCompletionTokens
249+ MONGODB__CONNECTION : 'mongodb+srv://${mongovCoreSettings .mongoClusterLogin }:${mongovCoreSettings .mongoClusterPassword }@${mongovCoreSettings .mongoClusterName }.mongocluster.cosmos.azure.com/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000'
250+ MONGODB__DATABASENAME : 'retaildb'
251+ MONGODB__COLLECTIONNAMES : 'product,customer,vectors,completions'
252+ MONGODB__MAXVECTORSEARCHRESULTS : '10'
253+ }
254+ }
255+
256+ resource appServiceWebInsights 'Microsoft.Insights/components@2020-02-02' = {
257+ name : appServiceWeb .name
258+ location : location
259+ kind : 'web'
260+ properties : {
261+ Application_Type : 'web'
262+ }
263+ }
264+
265+ /*
266+ resource appServiceWebDeployment 'Microsoft.Web/sites/sourcecontrols@2021-03-01' = {
267+ parent: appServiceWeb
268+ name: 'web'
269+ properties: {
270+ repoUrl: appServiceSettings.web.git.repo
271+ branch: appServiceSettings.web.git.branch
272+ isManualIntegration: true
273+ }
274+ dependsOn: [
275+ appServiceWebSettings
276+ ]
277+ }
278+ */
279+
280+ /* *************************************************************** */
281+ /* API Hosting - Azure Functions */
282+ /* *************************************************************** */
283+
284+ resource appServiceFunction 'Microsoft.Web/sites@2022-03-01' = {
285+ name : appServiceSettings .function .name
286+ location : location
287+ kind : 'functionapp'
288+ properties : {
289+ serverFarmId : appServicePlan .id
290+ httpsOnly : true
291+ siteConfig : {
292+ alwaysOn : true
293+ }
294+ }
295+ dependsOn : [
296+ storageAccount
297+ ]
298+ }
299+
300+ resource appServiceFunctionSettings 'Microsoft.Web/sites/config@2022-03-01' = {
301+ parent : appServiceFunction
302+ name : 'appsettings'
303+ kind : 'string'
304+ properties : {
305+ AzureWebJobsStorage : 'DefaultEndpointsProtocol=https;AccountName=${name }fnstorage;EndpointSuffix=core.windows.net;AccountKey=${storageAccount .listKeys ().keys [0 ].value }'
306+ APPLICATIONINSIGHTS_CONNECTION_STRING : appServiceFunctionsInsights .properties .ConnectionString
307+ FUNCTIONS_EXTENSION_VERSION : '~4'
308+ FUNCTIONS_WORKER_RUNTIME : 'dotnet-isolated'
309+ OPENAI__ENDPOINT : openAiAccount .properties .endpoint
310+ OPENAI__KEY : openAiAccount .listKeys ().key1
311+ OPENAI__EMBEDDINGSDEPLOYMENT : openAiEmbeddingsModelDeployment .name
312+ OPENAI__MAXTOKENS : '8191'
313+ MONGODB__CONNECTION : 'mongodb+srv://${mongovCoreSettings .mongoClusterLogin }:${mongovCoreSettings .mongoClusterPassword }@${mongovCoreSettings .mongoClusterName }.mongocluster.cosmos.azure.com/?tls=true&authMechanism=SCRAM-SHA-256&retrywrites=false&maxIdleTimeMS=120000'
314+ MONGODB__DATABASENAME : 'retaildb'
315+ MONGODB__COLLECTIONNAMES : 'product,customer,vectors,completions'
316+ }
317+ }
318+
319+ resource appServiceFunctionsInsights 'Microsoft.Insights/components@2020-02-02' = {
320+ name : appServiceFunction .name
321+ location : location
322+ kind : 'web'
323+ properties : {
324+ Application_Type : 'web'
325+ }
326+ }
327+
328+ /*
329+ resource appServiceFunctionsDeployment 'Microsoft.Web/sites/sourcecontrols@2021-03-01' = {
330+ parent: appServiceFunction
331+ name: 'web'
332+ properties: {
333+ repoUrl: appServiceSettings.web.git.repo
334+ branch: appServiceSettings.web.git.branch
335+ isManualIntegration: true
336+ }
337+ dependsOn: [
338+ appServiceFunctionSettings
339+ ]
340+ }
341+ */
342+
343+
344+
345+
346+ /* *************************************************************** */
347+ /* Outputs */
348+ /* *************************************************************** */
349+
350+ output deployedUrl string = appServiceWeb .properties .defaultHostName
0 commit comments