Skip to content

Commit 86fe619

Browse files
committed
finops: Replace Azure Cache for Redis by a Redis container
Lower POC cost for users.
1 parent c0b5872 commit 86fe619

File tree

5 files changed

+50
-28
lines changed

5 files changed

+50
-28
lines changed

Diff for: Makefile

+2-2
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ sync-local-config:
212212
--query "[0].properties.template.containers[0].env[?name=='CONFIG_JSON'].value" \
213213
--resource-group $(name_sanitized) \
214214
| iconv -f utf-8 -t utf-8 -c \
215-
| yq \
216-
--output-format yaml \
215+
| yq eval 'del(.cache)' \
216+
--output-format=yaml \
217217
--prettyPrint \
218218
> config.yaml

Diff for: README.md

-6
Original file line numberDiff line numberDiff line change
@@ -633,12 +633,6 @@ This totalizes $720.07 /month, $0.12 /hour, with the following breakdown:
633633
| Sweden Central | Serverless vCPU | $0.000024 /sec | $128.56 | Avg of 2 replicas with 1 vCPU |
634634
| Sweden Central | Serverless memory (average of 2 replicas) | $0.000003 /sec | $32.14 | Avg of 2 replicas with 2GB |
635635

636-
[Azure Cache for Redis](https://azure.microsoft.com/en-us/pricing/details/cache/):
637-
638-
| Region | Metric | Cost | Total (monthly $) | Note |
639-
|-|-|-|-|-|
640-
| Sweden Central | Standard C0 | $40.15 /month | $40.15 | Has 250MB of memory, should be upgraded for more intensive usage |
641-
642636
[Azure AI Search](https://azure.microsoft.com/en-us/pricing/details/search/):
643637

644638
| Region | Metric | Cost | Total (monthly $) | Note |

Diff for: app/helpers/config_models/cache.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def instance(self) -> ICache:
2828
class RedisModel(BaseModel, frozen=True):
2929
database: int = Field(default=0, ge=0)
3030
host: str
31-
password: SecretStr
31+
password: SecretStr | None = None
3232
port: int = 6379
3333
ssl: bool = True
3434

Diff for: app/persistence/redis.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ async def _use_connection_pool(self) -> ConnectionPool:
138138
host=self._config.host,
139139
port=self._config.port,
140140
# Authentication
141-
password=self._config.password.get_secret_value(),
141+
password=self._config.password.get_secret_value()
142+
if self._config.password
143+
else None,
142144
)
143145

144146
@asynccontextmanager

Diff for: cicd/bicep/app.bicep

+44-18
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,8 @@ var config = {
101101
cache: {
102102
mode: 'redis'
103103
redis: {
104-
host: redis.properties.hostName
105-
password: redis.listKeys().primaryKey
106-
port: redis.properties.sslPort
104+
host: redis.name
105+
ssl: false
107106
}
108107
}
109108
app_configuration: {
@@ -160,6 +159,48 @@ resource acaEnv 'Microsoft.App/managedEnvironments@2024-02-02-preview' = {
160159
}
161160
}
162161

162+
resource redis 'Microsoft.App/containerApps@2024-03-01' = {
163+
name: 'redis'
164+
location: location
165+
tags: tags
166+
properties: {
167+
configuration: {
168+
activeRevisionsMode: 'Single'
169+
ingress: {
170+
exposedPort: 6379
171+
targetPort: 6379
172+
transport: 'tcp'
173+
}
174+
}
175+
environmentId: acaEnv.id
176+
template: {
177+
scale: {
178+
maxReplicas: 1
179+
minReplicas: 1
180+
}
181+
containers: [
182+
{
183+
image: 'redis/redis-stack-server:7.4.0-v2'
184+
name: 'redis'
185+
resources: {
186+
cpu: json('0.5')
187+
memory: '1Gi'
188+
}
189+
probes: [
190+
{
191+
type: 'Startup'
192+
tcpSocket: {
193+
port: 6379
194+
}
195+
initialDelaySeconds: 10
196+
}
197+
]
198+
}
199+
]
200+
}
201+
}
202+
}
203+
163204
var containerAppScaleRules = [
164205
for queue in [
165206
callQueue.name
@@ -909,21 +950,6 @@ resource translate 'Microsoft.CognitiveServices/accounts@2024-06-01-preview' = {
909950
}
910951
}
911952

912-
resource redis 'Microsoft.Cache/redis@2024-03-01' = {
913-
name: prefix
914-
location: location
915-
tags: tags
916-
properties: {
917-
sku: {
918-
capacity: 0 // 250 MB of data
919-
family: 'C'
920-
name: 'Standard' // First tier with SLA
921-
}
922-
minimumTlsVersion: '1.2'
923-
redisVersion: '6' // v6.x
924-
}
925-
}
926-
927953
resource configStore 'Microsoft.AppConfiguration/configurationStores@2023-03-01' = {
928954
name: prefix
929955
location: location

0 commit comments

Comments
 (0)