Skip to content

Commit dbdfaa4

Browse files
authored
Merge pull request #17 from ahmedsza/redis
updated with redis
2 parents c8ae255 + aea49eb commit dbdfaa4

File tree

1 file changed

+52
-39
lines changed

1 file changed

+52
-39
lines changed

src/InfrastructureAsCode/main.bicep

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -8,37 +8,56 @@ var webAppName = '${uniqueString(resourceGroup().id)}-${environment}'
88
var appServicePlanName = '${uniqueString(resourceGroup().id)}-mpnp-asp'
99
var logAnalyticsName = '${uniqueString(resourceGroup().id)}-mpnp-la'
1010
var appInsightsName = '${uniqueString(resourceGroup().id)}-mpnp-ai'
11-
var sku = 'S1'
11+
var sku = 'P0V3'
1212
var registryName = '${uniqueString(resourceGroup().id)}mpnpreg'
1313
var registrySku = 'Standard'
1414
var imageName = 'techexcel/dotnetcoreapp'
1515
var startupCommand = ''
16+
var redisCacheName = '${uniqueString(resourceGroup().id)}-mpnp-redis'
17+
var redisCacheSku = 'Basic'
1618

17-
// Create Log Analytics Workspace
18-
resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2021-06-01' = {
19+
resource redisCache 'Microsoft.Cache/Redis@2023-08-01' = {
20+
name: redisCacheName
21+
location: location
22+
properties: {
23+
sku: {
24+
name: redisCacheSku
25+
family: 'C'
26+
capacity: 0
27+
}
28+
enableNonSslPort: false
29+
minimumTlsVersion: '1.2'
30+
redisConfiguration: {
31+
'maxmemory-policy': 'volatile-lru'
32+
}
33+
}
34+
}
35+
36+
resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2021-12-01-preview' = {
1937
name: logAnalyticsName
2038
location: location
2139
properties: {
2240
sku: {
2341
name: 'PerGB2018'
2442
}
25-
retentionInDays: 30
43+
retentionInDays: 90
44+
workspaceCapping: {
45+
dailyQuotaGb: 1
46+
}
2647
}
2748
}
2849

29-
// Create Application Insights
30-
resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
50+
resource appInsights 'Microsoft.Insights/components@2020-02-02-preview' = {
3151
name: appInsightsName
3252
location: location
3353
kind: 'web'
3454
properties: {
3555
Application_Type: 'web'
36-
WorkspaceResourceId: logAnalytics.id
56+
WorkspaceResourceId: logAnalyticsWorkspace.id
3757
}
3858
}
3959

40-
// Create Azure Container Registry
41-
resource containerRegistry 'Microsoft.ContainerRegistry/registries@2021-06-01-preview' = {
60+
resource containerRegistry 'Microsoft.ContainerRegistry/registries@2020-11-01-preview' = {
4261
name: registryName
4362
location: location
4463
sku: {
@@ -49,62 +68,56 @@ resource containerRegistry 'Microsoft.ContainerRegistry/registries@2021-06-01-pr
4968
}
5069
}
5170

52-
// Create App Service Plan
53-
resource appServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = {
71+
resource appServicePlan 'Microsoft.Web/serverFarms@2022-09-01' = {
5472
name: appServicePlanName
5573
location: location
74+
kind: 'linux'
75+
properties: {
76+
reserved: true
77+
}
5678
sku: {
5779
name: sku
58-
tier: 'Standard'
59-
}
60-
properties: {
61-
reserved: true // This property is required for Linux
6280
}
6381
}
6482

65-
// Create Web App
66-
resource webApp 'Microsoft.Web/sites@2021-02-01' = {
83+
resource appServiceApp 'Microsoft.Web/sites@2020-12-01' = {
6784
name: webAppName
6885
location: location
6986
properties: {
7087
serverFarmId: appServicePlan.id
88+
httpsOnly: true
89+
clientAffinityEnabled: false
7190
siteConfig: {
72-
linuxFxVersion: 'DOCKER|${imageName}'
91+
linuxFxVersion: 'DOCKER|${containerRegistry.name}.azurecr.io/${uniqueString(resourceGroup().id)}/${imageName}'
92+
http20Enabled: true
93+
minTlsVersion: '1.2'
94+
appCommandLine: startupCommand
7395
appSettings: [
96+
{
97+
name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE'
98+
value: 'false'
99+
}
74100
{
75101
name: 'DOCKER_REGISTRY_SERVER_URL'
76-
value: 'https://${registryName}.azurecr.io'
102+
value: 'https://${containerRegistry.name}.azurecr.io'
77103
}
78104
{
79105
name: 'DOCKER_REGISTRY_SERVER_USERNAME'
80-
value: containerRegistry.properties.adminUserEnabled ? listCredentials(containerRegistry.id, '2021-06-01-preview').username : ''
106+
value: containerRegistry.name
81107
}
82108
{
83109
name: 'DOCKER_REGISTRY_SERVER_PASSWORD'
84-
value: containerRegistry.properties.adminUserEnabled ? listCredentials(containerRegistry.id, '2021-06-01-preview').passwords[0].value : ''
110+
value: containerRegistry.listCredentials().passwords[0].value
85111
}
86112
{
87113
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
88114
value: appInsights.properties.InstrumentationKey
89115
}
90-
{
91-
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
92-
value: appInsights.properties.ConnectionString
93-
}
94-
{
95-
name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE'
96-
value: 'false'
97-
}
98-
{
99-
name: 'WEBSITES_PORT'
100-
value: '80' // Default port for your application
101-
}
102-
]
116+
]
117+
}
103118
}
104-
}
105119
}
106120

107-
// Outputs
108-
output appServiceName string = webApp.name
109-
output appServiceUrl string = 'https://${webAppName}.azurewebsites.net'
110-
output containerRegistryName string = containerRegistry.name
121+
output application_name string = appServiceApp.name
122+
output application_url string = appServiceApp.properties.hostNames[0]
123+
output container_registry_name string = containerRegistry.name

0 commit comments

Comments
 (0)