forked from Azure-Samples/azure-sql-db-session-recommender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.bicep
137 lines (124 loc) · 3.3 KB
/
main.bicep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
@description('Location for all resources.')
param location string = resourceGroup().location
param repositoryUrl string
@secure()
param repositoryToken string
@secure()
param sqlConnectionString string
@secure()
param openAIKey string
@secure()
param openAIEndpoint string
@description('Tags to assign to the resources, if needed')
param resourceTags object
var appName = 'session-recommender'
var appId = uniqueString(resourceGroup().id)
var staticWebAppName = '${appName}-${appId}'
var functionAppName = '${appName}-api-${appId}'
var hostingPlanName = '${appName}-plan-${appId}'
var applicationInsightsName = '${appName}-ai-${appId}'
var storageAccountName = '${appId}storage'
resource staticWebApp 'Microsoft.Web/staticSites@2022-09-01' = {
name: staticWebAppName
location: location
tags: resourceTags
properties: {
repositoryUrl: repositoryUrl
branch: 'main'
repositoryToken: repositoryToken
buildProperties: {
appLocation: '/client'
apiLocation: '/api'
appArtifactLocation: '/dist'
}
}
sku: {
tier: 'Free'
name: 'Free'
}
}
resource storageAccount 'Microsoft.Storage/storageAccounts@2022-05-01' = {
name: storageAccountName
location: location
sku: {
name: 'Standard_LRS'
}
kind: 'Storage'
properties: {
supportsHttpsTrafficOnly: true
defaultToOAuthAuthentication: true
}
}
resource hostingPlan 'Microsoft.Web/serverfarms@2021-03-01' = {
name: hostingPlanName
location: location
sku: {
name: 'Y1'
tier: 'Dynamic'
}
properties: {}
}
resource functionApp 'Microsoft.Web/sites@2021-03-01' = {
name: functionAppName
location: location
kind: 'functionapp'
identity: {
type: 'SystemAssigned'
}
properties: {
serverFarmId: hostingPlan.id
siteConfig: {
netFrameworkVersion: 'v6.0'
appSettings: [
{
name: 'AzureWebJobsStorage'
value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
}
{
name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'
value: 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};EndpointSuffix=${environment().suffixes.storage};AccountKey=${storageAccount.listKeys().keys[0].value}'
}
{
name: 'WEBSITE_CONTENTSHARE'
value: toLower(functionAppName)
}
{
name: 'FUNCTIONS_EXTENSION_VERSION'
value: '~4'
}
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: applicationInsights.properties.InstrumentationKey
}
{
name: 'FUNCTIONS_WORKER_RUNTIME'
value: 'dotnet'
}
{
name: 'AzureSQL.ConnectionString'
value: sqlConnectionString
}
{
name: 'AzureOpenAI.Endpoint'
value: openAIEndpoint
}
{
name: 'AzureOpenAI.Key'
value: openAIKey
}
]
ftpsState: 'FtpsOnly'
minTlsVersion: '1.2'
}
httpsOnly: true
}
}
resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
name: applicationInsightsName
location: location
kind: 'web'
properties: {
Application_Type: 'web'
Request_Source: 'rest'
}
}