Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(azure): revert to using connection string for IDistributedCache Redis #526

Merged
merged 1 commit into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .azure/applications/web-api-eu/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ param apimIp string
param containerAppEnvironmentName string
@minLength(3)
@secure()
param redisName string
@minLength(3)
@secure()
param appInsightConnectionString string
@minLength(5)
@secure()
Expand All @@ -36,10 +33,6 @@ resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01'
name: containerAppEnvironmentName
}

resource redis 'Microsoft.Cache/redis@2023-08-01' existing = {
name: redisName
}

var containerAppEnvVars = [
{
name: 'ASPNETCORE_ENVIRONMENT'
Expand Down Expand Up @@ -77,16 +70,6 @@ module containerApp '../../modules/containerApp/main.bicep' = {
}
}

resource redisAccessPolicyAssignment 'Microsoft.Cache/redis/accessPolicyAssignments@2023-08-01' = {
parent: redis
name: containerAppName
properties: {
accessPolicyName: 'Data Contributor'
objectId: containerApp.outputs.identityPrincipalId
objectIdAlias: '${containerAppName}-access-policy-redis'
}
}

module keyVaultReaderAccessPolicy '../../modules/keyvault/addReaderRoles.bicep' = {
name: 'keyVaultReaderAccessPolicy-${containerAppName}'
params: {
Expand Down
1 change: 0 additions & 1 deletion .azure/applications/web-api-eu/staging.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ param environmentKeyVaultName = readEnvironmentVariable('ENVIRONMENT_KEY_VAULT_N
param containerAppEnvironmentName = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_NAME')
param appInsightConnectionString = readEnvironmentVariable('APP_INSIGHTS_CONNECTION_STRING')
param appConfigurationName = readEnvironmentVariable('APP_CONFIGURATION_NAME')
param redisName = readEnvironmentVariable('REDIS_NAME')
1 change: 0 additions & 1 deletion .azure/applications/web-api-eu/test.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ param environmentKeyVaultName = readEnvironmentVariable('ENVIRONMENT_KEY_VAULT_N
param containerAppEnvironmentName = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_NAME')
param appInsightConnectionString = readEnvironmentVariable('APP_INSIGHTS_CONNECTION_STRING')
param appConfigurationName = readEnvironmentVariable('APP_CONFIGURATION_NAME')
param redisName = readEnvironmentVariable('REDIS_NAME')
17 changes: 0 additions & 17 deletions .azure/applications/web-api-so/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ param apimIp string
param containerAppEnvironmentName string
@minLength(3)
@secure()
param redisName string
@minLength(3)
@secure()
param appInsightConnectionString string
@minLength(5)
@secure()
Expand All @@ -36,10 +33,6 @@ resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01'
name: containerAppEnvironmentName
}

resource redis 'Microsoft.Cache/redis@2023-08-01' existing = {
name: redisName
}

var containerAppEnvVars = [
{
name: 'ASPNETCORE_ENVIRONMENT'
Expand Down Expand Up @@ -81,16 +74,6 @@ module containerApp '../../modules/containerApp/main.bicep' = {
}
}

resource redisAccessPolicyAssignment 'Microsoft.Cache/redis/accessPolicyAssignments@2023-08-01' = {
parent: redis
name: containerAppName
properties: {
accessPolicyName: 'Data Contributor'
objectId: containerApp.outputs.identityPrincipalId
objectIdAlias: '${containerAppName}-access-policy-redis'
}
}

module keyVaultReaderAccessPolicy '../../modules/keyvault/addReaderRoles.bicep' = {
name: 'keyVaultReaderAccessPolicy-${containerAppName}'
params: {
Expand Down
1 change: 0 additions & 1 deletion .azure/applications/web-api-so/staging.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ param environmentKeyVaultName = readEnvironmentVariable('ENVIRONMENT_KEY_VAULT_N
param containerAppEnvironmentName = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_NAME')
param appInsightConnectionString = readEnvironmentVariable('APP_INSIGHTS_CONNECTION_STRING')
param appConfigurationName = readEnvironmentVariable('APP_CONFIGURATION_NAME')
param redisName = readEnvironmentVariable('REDIS_NAME')
1 change: 0 additions & 1 deletion .azure/applications/web-api-so/test.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ param environmentKeyVaultName = readEnvironmentVariable('ENVIRONMENT_KEY_VAULT_N
param containerAppEnvironmentName = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_NAME')
param appInsightConnectionString = readEnvironmentVariable('APP_INSIGHTS_CONNECTION_STRING')
param appConfigurationName = readEnvironmentVariable('APP_CONFIGURATION_NAME')
param redisName = readEnvironmentVariable('REDIS_NAME')
8 changes: 4 additions & 4 deletions .azure/infrastructure/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ module postgresConnectionStringAppConfig '../modules/appConfiguration/upsertKeyV
}
}

module redisHostNameAppConfig '../modules/appConfiguration/upsertKeyValue.bicep' = {
module redisConnectionStringAppConfig '../modules/appConfiguration/upsertKeyValue.bicep' = {
scope: resourceGroup
name: 'AppConfig_Add_RedisHostName'
name: 'AppConfig_Add_DialogRedisConnectionString'
params: {
configStoreName: appConfiguration.outputs.name
key: 'Infrastructure:RedisHostName'
value: redis.outputs.hostNameKeyVaultUri
key: 'Infrastructure:DialogRedisConnectionString'
value: redis.outputs.connectionStringSecretUri
keyValueType: 'keyVaultReference'
}
}
Expand Down
12 changes: 7 additions & 5 deletions .azure/modules/redis/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ resource redis 'Microsoft.Cache/Redis@2023-08-01' = {
}
}

module redisHostName '../keyvault/upsertSecret.bicep' = {
name: 'redisHostName'
// Until managed identity is supported in the Redis for IDistributedCache, we need to use a connection string
// https://github.com/dotnet/aspnetcore/issues/54414
module redisConnectionString '../keyvault/upsertSecret.bicep' = {
name: 'redisConnectionString'
params: {
destKeyVaultName: environmentKeyVaultName
secretName: 'dialogportenRedisHostName'
secretName: 'dialogportenRedisConnectionString'
// disable public access? Use vnet here maybe?
secretValue: redis.properties.hostName
secretValue: 'redis://${redis.properties.hostName}:${redis.properties.port},password=${redis.properties.accessKeys.primaryKey},ssl=True,abortConnect=False'
}
}

output hostNameKeyVaultUri string = redisHostName.outputs.secretUri
output connectionStringSecretUri string = redisConnectionString.outputs.secretUri
5 changes: 0 additions & 5 deletions .github/workflows/action-deploy-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ on:
required: true
AZURE_ADO_CONNECTION_STRING_SECRET_URI:
required: true
AZURE_REDIS_NAME:
required: true

inputs:
region:
Expand Down Expand Up @@ -119,8 +117,6 @@ jobs:
# needs: deploy-migration-job
strategy:
fail-fast: true
# to ensure that the bicep commands doesn't conflict with eachother, we need to set the max-parallel to 1
max-parallel: 1
matrix:
include:
- name: web-api-eu
Expand Down Expand Up @@ -151,7 +147,6 @@ jobs:
APP_INSIGHTS_CONNECTION_STRING: ${{ secrets.AZURE_APP_INSIGHTS_CONNECTION_STRING }}
APP_CONFIGURATION_NAME: ${{ secrets.AZURE_APP_CONFIGURATION_NAME }}
ENVIRONMENT_KEY_VAULT_NAME: ${{ secrets.AZURE_ENVIRONMENT_KEY_VAULT_NAME }}
REDIS_NAME: ${{ secrets.AZURE_REDIS_NAME }}
with:
scope: resourcegroup
template: ./.azure/applications/${{ matrix.name }}/main.bicep
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-cd-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ jobs:
AZURE_CONTAINER_APP_ENVIRONMENT_NAME: ${{ secrets.AZURE_CONTAINER_APP_ENVIRONMENT_NAME }}
AZURE_APP_INSIGHTS_CONNECTION_STRING: ${{ secrets.AZURE_APP_INSIGHTS_CONNECTION_STRING }}
AZURE_APP_CONFIGURATION_NAME: ${{ secrets.AZURE_APP_CONFIGURATION_NAME }}
AZURE_REDIS_NAME: ${{ secrets.AZURE_REDIS_NAME }}
with:
environment: test
region: norwayeast
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-cd-pull-request-release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ jobs:
AZURE_CONTAINER_APP_ENVIRONMENT_NAME: ${{ secrets.AZURE_CONTAINER_APP_ENVIRONMENT_NAME }}
AZURE_APP_INSIGHTS_CONNECTION_STRING: ${{ secrets.AZURE_APP_INSIGHTS_CONNECTION_STRING }}
AZURE_APP_CONFIGURATION_NAME: ${{ secrets.AZURE_APP_CONFIGURATION_NAME }}
AZURE_REDIS_NAME: ${{ secrets.AZURE_REDIS_NAME }}
with:
environment: staging
region: norwayeast
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-cd-staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
AZURE_CONTAINER_APP_ENVIRONMENT_NAME: ${{ secrets.AZURE_CONTAINER_APP_ENVIRONMENT_NAME }}
AZURE_APP_INSIGHTS_CONNECTION_STRING: ${{ secrets.AZURE_APP_INSIGHTS_CONNECTION_STRING }}
AZURE_APP_CONFIGURATION_NAME: ${{ secrets.AZURE_APP_CONFIGURATION_NAME }}
AZURE_REDIS_NAME: ${{ secrets.AZURE_REDIS_NAME }}
with:
environment: staging
region: norwayeast
Expand Down
Loading