diff --git a/.env b/.env index 1314b887..af3351f4 100644 --- a/.env +++ b/.env @@ -3,4 +3,4 @@ DBNAME=app DBHOST=localhost DBUSER=app_user DBPASS=app_password -CACHELOCATION=redis://redis:6379/0 +CACHELOCATION=redis://redis:10000/0 diff --git a/README.md b/README.md index 97c0b9c1..07ea761e 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ description: This is a Python web app using the Flask framework and the Azure Da # Deploy a Python (Flask) web app with PostgreSQL in Azure -This is a Python web app using the Flask framework and the Azure Database for PostgreSQL relational database service. The Flask app is hosted in a fully managed Azure App Service. This app is designed to be be run locally and then deployed to Azure. You can either deploy this project by following the tutorial [*Deploy a Python (Django or Flask) web app with PostgreSQL in Azure*](https://docs.microsoft.com/azure/app-service/tutorial-python-postgresql-app) or by using the [Azure Developer CLI (azd)](https://learn.microsoft.com/azure/developer/azure-developer-cli/overview) according to the instructions below. +This is a Python web app using the Flask framework and the Azure Database for PostgreSQL relational database service. The Flask app is hosted in a fully managed Azure App Service. This app is designed to be be run locally and then deployed to Azure. You can either deploy this project by following the tutorial [*Deploy a Python (Django or Flask) web app with PostgreSQL in Azure*](https://docs.microsoft.com/azure/app-service/tutorial-python-postgresql-app) or by using the [Azure Developer CLI (azd)](https://learn.microsoft.com/azure/developer/azure-developer-cli/overview) according to the instructions below. The Azure deployment includes Azure Managed Redis for Redis-compatible caching scenarios. ## Requirements diff --git a/infra/resources.bicep b/infra/resources.bicep index f5fba55f..803c3f13 100644 --- a/infra/resources.bicep +++ b/infra/resources.bicep @@ -148,7 +148,7 @@ resource privateDnsZoneDB 'Microsoft.Network/privateDnsZones@2024-06-01' = { } } -// Resources needed to secure Redis Cache behind a private endpoint +// Resources needed to secure Azure Managed Redis behind a private endpoint resource cachePrivateEndpoint 'Microsoft.Network/privateEndpoints@2024-03-01' = { name: '${appName}-cache-privateEndpoint' location: location @@ -161,7 +161,7 @@ resource cachePrivateEndpoint 'Microsoft.Network/privateEndpoints@2024-03-01' = name: '${appName}-cache-privateEndpoint' properties: { privateLinkServiceId: redisCache.id - groupIds: ['redisCache'] + groupIds: ['redisEnterprise'] } } ] @@ -181,7 +181,7 @@ resource cachePrivateEndpoint 'Microsoft.Network/privateEndpoints@2024-03-01' = } } resource privateDnsZoneCache 'Microsoft.Network/privateDnsZones@2024-06-01' = { - name: 'privatelink.redis.cache.windows.net' + name: 'privatelink.redis.azure.net' location: 'global' dependsOn: [ virtualNetwork @@ -274,23 +274,25 @@ resource dbserver 'Microsoft.DBforPostgreSQL/flexibleServers@2022-01-20-preview' ] } -// The Redis cache is configured to the minimum pricing tier -resource redisCache 'Microsoft.Cache/redis@2024-11-01' = { +// Azure Managed Redis is configured to the minimum pricing tier +resource redisCache 'Microsoft.Cache/redisEnterprise@2026-05-01-preview' = { name: '${appName}-cache' location: location + sku: { + name: 'Balanced_B0' + } properties: { - sku: { - name: 'Basic' - family: 'C' - capacity: 0 - } - redisConfiguration: {} - enableNonSslPort: false - redisVersion: '6' + encryption: {} + minimumTlsVersion: '1.2' publicNetworkAccess: 'Disabled' } } +resource redisDatabase 'Microsoft.Cache/redisEnterprise/databases@2026-05-01-preview' existing = { + parent: redisCache + name: 'default' +} + // The App Service plan is configured to the B1 pricing tier resource appServicePlan 'Microsoft.Web/serverfarms@2024-04-01' = { name: '${appName}-plan' @@ -430,7 +432,7 @@ resource cacheConnector 'Microsoft.ServiceLinker/linkers@2024-04-01' = { clientType: 'python' targetService: { type: 'AzureResource' - id: resourceId('Microsoft.Cache/Redis/Databases', redisCache.name, '0') + id: redisDatabase.id } authInfo: { authType: 'accessKey'