Write Redis cache settings during post-deployment configuration - #1462
Merged
Paul Lizer (paullizer) merged 1 commit intoSep 7, 2026
Merged
Conversation
postconfig.py provisioned and RBAC-granted a Redis cache but never wrote the
settings the application reads, leaving a placeholder:
# Scale > Redis Cache
# todo support redis cache configuration
The App Service only receives REDIS_ENTRA_TOKEN_SCOPE, and configure_sessions()
in app.py reads enable_redis_cache and redis_url from the Cosmos settings
document. Those stayed False and empty, so every deployment that enabled Redis
silently fell back to filesystem sessions and in-memory caching.
postconfig now writes enable_redis_cache, redis_url, redis_auth_type,
redis_service_type, redis_port and redis_key when the deployment provisioned a
cache. It is skipped when no cache was provisioned so an operator-configured
external Redis is preserved.
The Bicep redisCacheKind parameter uses managed/classic while the application
uses azure_managed_redis/azure_cache_for_redis, so the value is translated
rather than passed through. Writing it through unchanged would resolve the
wrong TLS port (10000 vs 6380).
Adds functional_tests/test_postconfig_redis_cache_configuration.py, which also
cross-checks the identifiers against the SERVICE_TYPE constants in
functions_redis_client.py so the two vocabularies cannot drift apart.
Bumps deployers/version.txt to 1.0.30.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
postconfig.pyprovisioned and RBAC-granted a Redis cache but never wrote the settings the application reads. The Redis section was a placeholder:Impact
configure_sessions()inapplication/single_app/app.pyreadsenable_redis_cacheandredis_urlfrom the Cosmos settings document. The App Service only receivesREDIS_ENTRA_TOKEN_SCOPEfrom Bicep, nothing else.So on a deployment with
deployRedisCache: true, after provisioning succeeded, the settings document still read:The cache was billed and running, the managed identity role assignment was in place, and the application silently used filesystem sessions and in-memory caching instead. There was no error, which is why this was easy to miss.
Observed on a fresh Azure Managed Redis deployment (
Balanced_B0, HA enabled) in North Central US.Fix
postconfig now writes
enable_redis_cache,redis_url,redis_auth_type,redis_service_type,redis_portandredis_key.Two deliberate choices:
if redis_cache_host_name:so an operator-configured external Redis is not overwritten whendeployRedisCacheis false.redisCacheKindusesmanaged/classic; the application usesazure_managed_redis/azure_cache_for_redis. Writing the Bicep value through unchanged would failresolve_redis_service_type()and resolve the wrong TLS port - 6380 instead of 10000 for Managed Redis.redis_keyis set fromcore_service_keys, which is empty under managed identity. That also clears a stale key left by an earlier key-auth deployment.Tests
Adds
functional_tests/test_postconfig_redis_cache_configuration.py:SERVICE_TYPE_*constants out offunctions_redis_client.pyand asserts postconfig emits those exact values, so the deployer and application vocabularies cannot drift apart againUnrelated pre-existing failure
functional_tests/test_postconfig_azurecli_credential.pycurrently fails onDevelopmentbefore this change. It expectsclient = CosmosClient(cosmosEndpoint, cosmosKey)but the code was refactored toazure_cosmos.CosmosClient(...). Left alone to keep this PR scoped - happy to fix separately.deployers/version.txtbumped to 1.0.30.