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: add base uri for web api #425

Merged
merged 5 commits into from
Feb 9, 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
16 changes: 10 additions & 6 deletions .azure/applications/web-api-eu/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ param location string

@minLength(3)
@secure()
param containerAppEnvironmentId string
param containerAppEnvironmentName string
@minLength(3)
@secure()
param appInsightConnectionString string
@minLength(3)
@minLength(5)
@secure()
param appConfigurationName string
@minLength(3)
Expand All @@ -23,8 +23,12 @@ param environmentKeyVaultName string
var namePrefix = 'dp-be-${environment}'
var baseImageUrl = 'ghcr.io/digdir/dialogporten-'

resource appConfig 'Microsoft.AppConfiguration/configurationStores@2023-03-01' existing = {
name: '${namePrefix}-appConfiguration'
resource appConfiguration 'Microsoft.AppConfiguration/configurationStores@2023-03-01' existing = {
name: appConfigurationName
}

resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' existing = {
name: containerAppEnvironmentName
}

var containerAppEnvVars = [
Expand All @@ -38,7 +42,7 @@ var containerAppEnvVars = [
}
{
name: 'AZURE_APPCONFIG_URI'
value: appConfig.properties.endpoint
value: appConfiguration.properties.endpoint
}
{
name: 'ASPNETCORE_URLS'
Expand All @@ -59,7 +63,7 @@ module containerApp '../../modules/containerApp/main.bicep' = {
image: '${baseImageUrl}webapi:${imageTag}'
location: location
envVariables: containerAppEnvVars
containerAppEnvId: containerAppEnvironmentId
containerAppEnvId: containerAppEnvironment.id
}
}

Expand Down
2 changes: 1 addition & 1 deletion .azure/applications/web-api-eu/staging.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ param imageTag = readEnvironmentVariable('IMAGE_TAG')

// secrets
param environmentKeyVaultName = readEnvironmentVariable('ENVIRONMENT_KEY_VAULT_NAME')
param containerAppEnvironmentId = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_ID')
param containerAppEnvironmentName = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_NAME')
param appInsightConnectionString = readEnvironmentVariable('APP_INSIGHTS_CONNECTION_STRING')
param appConfigurationName = readEnvironmentVariable('APP_CONFIGURATION_NAME')
2 changes: 1 addition & 1 deletion .azure/applications/web-api-eu/test.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ param imageTag = readEnvironmentVariable('IMAGE_TAG')

// secrets
param environmentKeyVaultName = readEnvironmentVariable('ENVIRONMENT_KEY_VAULT_NAME')
param containerAppEnvironmentId = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_ID')
param containerAppEnvironmentName = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_NAME')
param appInsightConnectionString = readEnvironmentVariable('APP_INSIGHTS_CONNECTION_STRING')
param appConfigurationName = readEnvironmentVariable('APP_CONFIGURATION_NAME')
8 changes: 6 additions & 2 deletions .azure/applications/web-api-migration-job/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ param location string

@minLength(3)
@secure()
param containerAppEnvironmentId string
param containerAppEnvironmentName string
@minLength(3)
@secure()
param adoConnectionStringSecretUri string
Expand All @@ -19,13 +19,17 @@ var baseImageUrl = 'ghcr.io/digdir/dialogporten-'

var name = '${namePrefix}-db-migration-job'

resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' existing = {
name: containerAppEnvironmentName
}

module migrationJob '../../modules/containerAppJob/main.bicep' = {
name: name
params: {
name: name
location: location
image: '${baseImageUrl}migration-bundle:${imageTag}'
containerAppEnvId: containerAppEnvironmentId
containerAppEnvId: containerAppEnvironment.id
adoConnectionStringSecretUri: adoConnectionStringSecretUri
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ using './main.bicep'

param environment = 'staging'
param location = 'norwayeast'
param imageTag = readEnvironmentVariable('IMAGE_TAG', '')
param containerAppEnvironmentId = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_ID', '')
param imageTag = readEnvironmentVariable('IMAGE_TAG')
param containerAppEnvironmentName = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_NAME')

//secrets
param adoConnectionStringSecretUri = readEnvironmentVariable('ADO_CONNECTION_STRING_SECRET_URI', '')
param adoConnectionStringSecretUri = readEnvironmentVariable('ADO_CONNECTION_STRING_SECRET_URI')
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ param location = 'norwayeast'

//secrets
param imageTag = readEnvironmentVariable('IMAGE_TAG')
param containerAppEnvironmentId = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_ID')
param containerAppEnvironmentName = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_NAME')
param adoConnectionStringSecretUri = readEnvironmentVariable('ADO_CONNECTION_STRING_SECRET_URI')
44 changes: 32 additions & 12 deletions .azure/applications/web-api-so/main.bicep
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
targetScope = 'resourceGroup'

@minLength(1)
@minLength(3)
param imageTag string
@minLength(1)
@minLength(3)
param environment string
@minLength(1)
@minLength(3)
param location string

@minLength(1)
@minLength(3)
@secure()
param containerAppEnvironmentId string
@minLength(1)
param containerAppEnvironmentName string
@minLength(3)
@secure()
param appInsightConnectionString string
@minLength(1)
@minLength(5)
@secure()
param appConfigurationName string
@minLength(1)
@minLength(3)
@secure()
param environmentKeyVaultName string
@minLength(3)
@secure()
param apimUri string

var namePrefix = 'dp-be-${environment}'
var baseImageUrl = 'ghcr.io/digdir/dialogporten-'

resource appConfig 'Microsoft.AppConfiguration/configurationStores@2023-03-01' existing = {
name: '${namePrefix}-appConfiguration'
resource appConfiguration 'Microsoft.AppConfiguration/configurationStores@2023-03-01' existing = {
name: appConfigurationName
}

resource containerAppEnvironment 'Microsoft.App/managedEnvironments@2023-05-01' existing = {
name: containerAppEnvironmentName
}

var containerAppEnvVars = [
Expand All @@ -38,7 +45,7 @@ var containerAppEnvVars = [
}
{
name: 'AZURE_APPCONFIG_URI'
value: appConfig.properties.endpoint
value: appConfiguration.properties.endpoint
}
{
name: 'ASPNETCORE_URLS'
Expand All @@ -63,7 +70,20 @@ module containerApp '../../modules/containerApp/main.bicep' = {
image: '${baseImageUrl}webapi:${imageTag}'
location: location
envVariables: containerAppEnvVars
containerAppEnvId: containerAppEnvironmentId
containerAppEnvId: containerAppEnvironment.id
}
}

// If the APIM URI is not provided, we will use the default domain of the container app environment. We only do this for the so service.
var baseUri = !empty(apimUri) ? apimUri : 'https://${containerAppName}.${containerAppEnvironment.properties.defaultDomain}'

module appConfigConfigurations '../../modules/appConfiguration/upsertKeyValue.bicep' = {
name: 'AppConfig_Add_DialogPortenBaseUri'
params: {
configStoreName: appConfigurationName
key: 'Application:Dialoporten:BaseUri'
value: baseUri
keyValueType: 'custom'
}
}

Expand Down
2 changes: 1 addition & 1 deletion .azure/applications/web-api-so/staging.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ param imageTag = readEnvironmentVariable('IMAGE_TAG')

// secrets
param environmentKeyVaultName = readEnvironmentVariable('ENVIRONMENT_KEY_VAULT_NAME')
param containerAppEnvironmentId = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_ID')
param containerAppEnvironmentName = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_NAME')
param appInsightConnectionString = readEnvironmentVariable('APP_INSIGHTS_CONNECTION_STRING')
param appConfigurationName = readEnvironmentVariable('APP_CONFIGURATION_NAME')
2 changes: 1 addition & 1 deletion .azure/applications/web-api-so/test.bicepparam
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ param imageTag = readEnvironmentVariable('IMAGE_TAG')

// secrets
param environmentKeyVaultName = readEnvironmentVariable('ENVIRONMENT_KEY_VAULT_NAME')
param containerAppEnvironmentId = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_ID')
param containerAppEnvironmentName = readEnvironmentVariable('CONTAINER_APP_ENVIRONMENT_NAME')
param appInsightConnectionString = readEnvironmentVariable('APP_INSIGHTS_CONNECTION_STRING')
param appConfigurationName = readEnvironmentVariable('APP_CONFIGURATION_NAME')
6 changes: 3 additions & 3 deletions .github/workflows/action-deploy-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
required: true
AZURE_ENVIRONMENT_KEY_VAULT_NAME:
required: true
AZURE_CONTAINER_APP_ENVIRONMENT_ID:
AZURE_CONTAINER_APP_ENVIRONMENT_NAME:
required: true
AZURE_APP_INSIGHTS_CONNECTION_STRING:
required: true
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
# IMAGE_TAG: ${{ inputs.gitShortSha }}
# # secrets
# ADO_CONNECTION_STRING_SECRET_URI: ${{ secrets.AZURE_ADO_CONNECTION_STRING_SECRET_URI }}
# CONTAINER_APP_ENVIRONMENT_ID: ${{ secrets.AZURE_CONTAINER_APP_ENVIRONMENT_ID }}
# CONTAINER_APP_ENVIRONMENT_NAME: ${{ secrets.AZURE_CONTAINER_APP_ENVIRONMENT_NAME }}
# with:
# scope: resourcegroup
# template: ./.azure/applications/web-api-migration-job/main.bicep
Expand Down Expand Up @@ -139,7 +139,7 @@ jobs:
# parameters
IMAGE_TAG: ${{ inputs.gitShortSha }}
# secrets
CONTAINER_APP_ENVIRONMENT_ID: ${{ secrets.AZURE_CONTAINER_APP_ENVIRONMENT_ID }}
CONTAINER_APP_ENVIRONMENT_NAME: ${{ secrets.AZURE_CONTAINER_APP_ENVIRONMENT_NAME }}
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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-cd-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
AZURE_RESOURCE_GROUP_NAME: ${{ secrets.AZURE_RESOURCE_GROUP_NAME }}
AZURE_ADO_CONNECTION_STRING_SECRET_URI: ${{ secrets.AZURE_ADO_CONNECTION_STRING_SECRET_URI }}
AZURE_ENVIRONMENT_KEY_VAULT_NAME: ${{ secrets.AZURE_ENVIRONMENT_KEY_VAULT_NAME }}
AZURE_CONTAINER_APP_ENVIRONMENT_ID: ${{ secrets.AZURE_CONTAINER_APP_ENVIRONMENT_ID }}
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 }}
with:
Expand Down
Loading