@@ -10,8 +10,16 @@ param secretKey string
1010var prefix = '${name }-${resourceToken }'
1111
1212var pgServerName = '${prefix }-postgres-server'
13+ //added for Redis Cache
14+ var cacheServerName = '${prefix }-redisCache'
1315var databaseSubnetName = 'database-subnet'
1416var webappSubnetName = 'webapp-subnet'
17+ //added for Redis Cache
18+ var cacheSubnetName = 'cache-subnet'
19+ //added for Redis Cache
20+ var cachePrivateEndpointName = 'cache-privateEndpoint'
21+ //added for Redis Cache
22+ var cachePvtEndpointDnsGroupName = 'cacheDnsGroup'
1523
1624resource virtualNetwork 'Microsoft.Network/virtualNetworks@2019-11-01' = {
1725 name : '${prefix }-vnet'
@@ -52,6 +60,12 @@ resource virtualNetwork 'Microsoft.Network/virtualNetworks@2019-11-01' = {
5260 ]
5361 }
5462 }
63+ {
64+ name : cacheSubnetName
65+ properties :{
66+ addressPrefix : '10.0.2.0/24'
67+ }
68+ }
5569 ]
5670 }
5771 resource databaseSubnet 'subnets' existing = {
@@ -60,6 +74,10 @@ resource virtualNetwork 'Microsoft.Network/virtualNetworks@2019-11-01' = {
6074 resource webappSubnet 'subnets' existing = {
6175 name : webappSubnetName
6276 }
77+ //added for Redis Cache
78+ resource cacheSubnet 'subnets' existing = {
79+ name : cacheSubnetName
80+ }
6381}
6482
6583resource privateDnsZone 'Microsoft.Network/privateDnsZones@2020-06-01' = {
@@ -71,6 +89,16 @@ resource privateDnsZone 'Microsoft.Network/privateDnsZones@2020-06-01' = {
7189 ]
7290}
7391
92+ // added for Redis Cache
93+ resource privateDnsZoneCache 'Microsoft.Network/privateDnsZones@2020-06-01' = {
94+ name : 'privatelink.redis.cache.windows.net'
95+ location : 'global'
96+ tags : tags
97+ dependsOn :[
98+ virtualNetwork
99+ ]
100+ }
101+
74102resource privateDnsZoneLink 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2020-06-01' = {
75103 parent : privateDnsZone
76104 name : '${pgServerName }-link'
@@ -83,6 +111,54 @@ resource privateDnsZoneLink 'Microsoft.Network/privateDnsZones/virtualNetworkLin
83111 }
84112}
85113
114+ //added for Redis Cache
115+ resource privateDnsZoneLinkCache 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2020-06-01' = {
116+ parent : privateDnsZoneCache
117+ name : 'privatelink.redis.cache.windows.net-applink'
118+ location : 'global'
119+ properties : {
120+ registrationEnabled : false
121+ virtualNetwork : {
122+ id : virtualNetwork .id
123+ }
124+ }
125+ }
126+
127+
128+ resource cachePrivateEndpoint 'Microsoft.Network/privateEndpoints@2023-05-01' = {
129+ name : cachePrivateEndpointName
130+ location : location
131+ properties : {
132+ subnet : {
133+ id : virtualNetwork ::cacheSubnet .id
134+ }
135+ privateLinkServiceConnections : [
136+ {
137+ name : cachePrivateEndpointName
138+ properties : {
139+ privateLinkServiceId : redisCache .id
140+ groupIds : [
141+ 'redisCache'
142+ ]
143+ }
144+ }
145+ ]
146+ }
147+ resource cachePvtEndpointDnsGroup 'privateDnsZoneGroups' = {
148+ name : cachePvtEndpointDnsGroupName
149+ properties : {
150+ privateDnsZoneConfigs : [
151+ {
152+ name : 'privatelink-redis-cache-windows-net'
153+ properties : {
154+ privateDnsZoneId : privateDnsZoneCache .id
155+ }
156+ }
157+ ]
158+ }
159+ }
160+ }
161+
86162resource web 'Microsoft.Web/sites@2022-03-01' = {
87163 name : '${prefix }-app-service'
88164 location : location
@@ -92,7 +168,7 @@ resource web 'Microsoft.Web/sites@2022-03-01' = {
92168 serverFarmId : appServicePlan .id
93169 siteConfig : {
94170 alwaysOn : true
95- linuxFxVersion : 'PYTHON|3.10 '
171+ linuxFxVersion : 'PYTHON|3.11 '
96172 ftpsState : 'Disabled'
97173 appCommandLine : 'startup.sh'
98174 }
@@ -108,6 +184,7 @@ resource web 'Microsoft.Web/sites@2022-03-01' = {
108184 AZURE_POSTGRESQL_CONNECTIONSTRING : 'dbname=${djangoDatabase .name } host=${postgresServer .name }.postgres.database.azure.com port=5432 sslmode=require user=${postgresServer .properties .administratorLogin } password=${databasePassword }'
109185 SCM_DO_BUILD_DURING_DEPLOYMENT : 'true'
110186 SECRET_KEY : secretKey
187+ //TODO: add settings for Redis Cache
111188 }
112189 }
113190
@@ -151,7 +228,7 @@ resource appServicePlan 'Microsoft.Web/serverfarms@2021-03-01' = {
151228 location : location
152229 tags : tags
153230 sku : {
154- name : 'B1 '
231+ name : 'S1 '
155232 }
156233 properties : {
157234 reserved : true
@@ -229,5 +306,35 @@ resource djangoDatabase 'Microsoft.DBforPostgreSQL/flexibleServers/databases@202
229306 name : 'django'
230307}
231308
309+ //added for Redis Cache
310+ resource redisCache 'Microsoft.Cache/redis@2023-04-01' = {
311+ location :location
312+ name :cacheServerName
313+ properties :{
314+ sku :{
315+ capacity : 1
316+ family :'C'
317+ name :'Standard'
318+ }
319+ enableNonSslPort :false
320+ redisVersion :'6'
321+ publicNetworkAccess :'Disabled'
322+ //subnetId:virtualNetwork::cacheSubnet.id //commented out b/c vnet injection only works for premium skus
323+ }
324+
325+ // resource redisCacheNetwork 'privateEndpointConnections' = {
326+ // name: '${cacheServerName}-privateEndpointConnection'
327+ // properties:{
328+ // privateLinkServiceConnectionState: {
329+ // actionsRequired: 'Change on the service provider will require updates on the consumer. see https://learn.microsoft.com/en-us/azure/templates/microsoft.cache/redis/privateendpointconnections?pivots=deployment-language-bicep#privatelinkserviceconnectionstate'
330+ // description: 'the private link service connection state for setting up private link'
331+ // status: 'Approved'
332+ // }
333+ // privateEndpoint: cachePrivateEndpoint
334+ // }
335+ // }
336+
337+ }
338+
232339output WEB_URI string = 'https://${web .properties .defaultHostName }'
233340output APPLICATIONINSIGHTS_CONNECTION_STRING string = applicationInsightsResources .outputs .APPLICATIONINSIGHTS_CONNECTION_STRING
0 commit comments