Skip to content

Commit

Permalink
fix: ensure jobs are run with correct arguments and parameters (#1085)
Browse files Browse the repository at this point in the history
<!--- Provide a general summary of your changes in the Title above -->

## Description

<!--- Describe your changes in detail -->

Apparently, the `command` property in Bicep for Azure Container Apps
overrides the `ENTRYPOINT` property in the `Dockerfile` 🤷 Changing to
using arguments instead. Tested with manual update of the container app
job.


https://azureossd.github.io/2024/01/17/Container-Apps-Using-the-command-override-option/

Other things:
- Added application insights connection string
- Added `ASPNETCORE_ENVIRONMENT` in order to use correct appconfig-file

## Related Issue(s)

- #{issue number}

## Verification

- [ ] **Your** code builds clean without any errors or warnings
- [ ] Manual testing done (required)
- [ ] Relevant automated test added (if you find this hard, leave it and
we'll help out)

## Documentation

- [ ] Documentation is updated (either in `docs`-directory, Altinnpedia
or a separate linked PR in
[altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if
applicable)
  • Loading branch information
arealmaas authored Sep 5, 2024
1 parent e8e4c02 commit e21de56
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ param environmentKeyVaultName string
@minLength(9)
param jobSchedule string

@description('The connection string for Application Insights')
@minLength(3)
@secure()
param appInsightConnectionString string

var namePrefix = 'dp-be-${environment}'
var baseImageUrl = 'ghcr.io/digdir/dialogporten-'
var tags = {
Expand All @@ -46,6 +51,14 @@ var containerAppEnvVars = [
name: 'Infrastructure__DialogDbConnectionString'
secretRef: 'dbconnectionstring'
}
{
name: 'ASPNETCORE_ENVIRONMENT'
value: environment
}
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: appInsightConnectionString
}
]

// https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-functions-deployment#example-1
Expand All @@ -70,7 +83,7 @@ module migrationJob '../../modules/containerAppJob/main.bicep' = {
secrets: secrets
tags: tags
cronExpression: jobSchedule
command: 'sync-subject-resource-mappings'
args: 'sync-subject-resource-mappings'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ param jobSchedule = '*/5 * * * *' // Runs every 5 minutes
//secrets
param containerAppEnvironmentName = readEnvironmentVariable('AZURE_CONTAINER_APP_ENVIRONMENT_NAME')
param environmentKeyVaultName = readEnvironmentVariable('AZURE_ENVIRONMENT_KEY_VAULT_NAME')
param appInsightConnectionString = readEnvironmentVariable('AZURE_APP_INSIGHTS_CONNECTION_STRING')
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ param jobSchedule = '*/5 * * * *' // Runs every 5 minutes
//secrets
param containerAppEnvironmentName = readEnvironmentVariable('AZURE_CONTAINER_APP_ENVIRONMENT_NAME')
param environmentKeyVaultName = readEnvironmentVariable('AZURE_ENVIRONMENT_KEY_VAULT_NAME')
param appInsightConnectionString = readEnvironmentVariable('AZURE_APP_INSIGHTS_CONNECTION_STRING')
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ param jobSchedule = '*/5 * * * *' // Runs every 5 minutes
//secrets
param containerAppEnvironmentName = readEnvironmentVariable('AZURE_CONTAINER_APP_ENVIRONMENT_NAME')
param environmentKeyVaultName = readEnvironmentVariable('AZURE_ENVIRONMENT_KEY_VAULT_NAME')
param appInsightConnectionString = readEnvironmentVariable('AZURE_APP_INSIGHTS_CONNECTION_STRING')
6 changes: 3 additions & 3 deletions .azure/modules/containerAppJob/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ param tags object
@description('The cron expression for the job schedule (optional)')
param cronExpression string = ''

@description('The command for the job (optional)')
param command string = ''
@description('The container args for the job (optional)')
param args string = ''

var isScheduled = !empty(cronExpression)

Expand Down Expand Up @@ -64,7 +64,7 @@ resource job 'Microsoft.App/jobs@2024-03-01' = {
env: environmentVariables
image: image
name: name
command: empty(command) ? null : [command]
args: empty(args) ? null : [args]
}
]
}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/action-deploy-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ jobs:
# secrets
AZURE_CONTAINER_APP_ENVIRONMENT_NAME: ${{ secrets.AZURE_CONTAINER_APP_ENVIRONMENT_NAME }}
AZURE_ENVIRONMENT_KEY_VAULT_NAME: ${{ secrets.AZURE_ENVIRONMENT_KEY_VAULT_NAME }}
AZURE_APP_INSIGHTS_CONNECTION_STRING: ${{ secrets.AZURE_APP_INSIGHTS_CONNECTION_STRING }}
with:
scope: resourcegroup
template: ./.azure/applications/${{ matrix.name }}/main.bicep
Expand Down

0 comments on commit e21de56

Please sign in to comment.