Skip to content

Commit

Permalink
chore: Disable resources connection string for pr env instead of soft…
Browse files Browse the repository at this point in the history
… deleting it
  • Loading branch information
Jonathanio123 committed Nov 7, 2024
1 parent ba60cda commit 666a523
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pipelines/environment-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,19 @@ stages:
azureSubscription: 'FRA Automation Non-Prod'
coreAzureSubscription: 'PROJECT_PORTAL (63b791ae-b2bc-41a1-ac66-806c4e69bffe)'

## To get the pr slots to talk to the correct databases, we need to kill the key vault secret for connection string.
## To get the pr slots to talk to the correct databases, we need to disable the key vault secret for connection string.
## The secret would override the direct env property used to target the correct db.
## Cannot delete as this would only soft delete the secret and now allow subsequent deployment to create the secret again.
- task: AzurePowerShell@5
displayName: 'Remove db connection string secret'
displayName: 'Disable db connection string secret'
inputs:
azureSubscription: 'PROJECT_PORTAL (63b791ae-b2bc-41a1-ac66-806c4e69bffe)'
ScriptType: InlineScript
FailOnStandardError: true
azurePowerShellVersion: 'LatestVersion'
Inline: |
Write-Host "Deleting secret @ kv-fap-resources-pr/ConnectionStrings--ResourcesDbContext"
Remove-AzKeyVaultSecret -VaultName kv-fap-resources-pr -Name ConnectionStrings--ResourcesDbContext -Force
Write-Host "Disabling secret @ kv-fap-resources-pr/ConnectionStrings--ResourcesDbContext"
Update-AzKeyVaultSecret -VaultName kv-fap-resources-pr -Name ConnectionStrings--ResourcesDbContext -Enable $False
- stage: DeployQA
Expand Down
3 changes: 3 additions & 0 deletions src/backend/api/Fusion.Resources.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((ctx, configBuilder) =>
{

if (ShouldLoadConfiguration())
{

configBuilder.AddJsonFile("/app/secrets/appsettings.secrets.yaml", optional: true);
configBuilder.AddJsonFile("/app/config/appsettings.json", optional: true); // to be able to override settings by using a config map in kubernetes

Expand Down Expand Up @@ -50,6 +52,7 @@ private static void AddKeyVault(HostBuilderContext hostBuilderContext, IConfigur
var credential = new ClientSecretCredential(tenantId, clientId, clientSecret);
configBuilder.AddAzureKeyVault(new Uri(keyVaultUrl), credential);
}

else
{
Console.WriteLine("Skipping key vault as url is empty.");
Expand Down

0 comments on commit 666a523

Please sign in to comment.