From 20c329f868b57491a8f16c642ffbc6a63d230d79 Mon Sep 17 00:00:00 2001 From: Chris Meagher Date: Sat, 11 Nov 2023 00:56:54 +0000 Subject: [PATCH] Remove `postdown` hook as it is no longer needed --- .azd/hooks/postdown.ps1 | 27 --------------------------- README.md | 5 ----- azure.yaml | 3 --- 3 files changed, 35 deletions(-) delete mode 100644 .azd/hooks/postdown.ps1 diff --git a/.azd/hooks/postdown.ps1 b/.azd/hooks/postdown.ps1 deleted file mode 100644 index 1a7f614..0000000 --- a/.azd/hooks/postdown.ps1 +++ /dev/null @@ -1,27 +0,0 @@ -$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path - -$envAzdPath = Join-Path $scriptDir "../../.azure/${env:AZURE_ENV_NAME}/.env" - -if (!(Test-Path $envAzdPath -PathType Leaf)) { - # azd env file does not exist so there is nothing to do - - return -} - -# Remove any env vars that were most likely set by provisioning the infrastructure - the infrastructure has been removed so they are no longer relevant - -$keysToKeep = @("AZURE_ENV_NAME", "AZURE_LOCATION", "AZURE_SUBSCRIPTION_ID", "AZURE_TENANT_ID") - -$envVars = @{} - -Get-Content $envAzdPath | ForEach-Object { - $key, $value = $_ -split '=', 2 - - if ($keysToKeep -contains $key) { - $envVars[$key] = $value - } -} - -$envVars.Keys | Sort-Object | ForEach-Object { - "$_=$($envVars[$_])" -} | Out-File $envAzdPath diff --git a/README.md b/README.md index 56a32e6..cd01aa5 100644 --- a/README.md +++ b/README.md @@ -221,11 +221,6 @@ When running `azd deploy`: 2. It then copies `.env.azure` and renames and overwrites the `.env.local` file with it 3. `next build` then runs, which loads in env files as normal including the `.env.local` file -When running `azd down`: - -1. A `postdown` hook runs the `.azd/hooks/postdown.ps1` script - * The contents of the `.azure/{AZURE_ENV_NAME}/.env` file is "cleaned up" so that only some [well-known variables](https://github.com/Azure/azure-dev/issues/1458) are retained - ### How the `.env.local` file is generated when running in a pipeline The `.env.local` file is required to provision, build and deploy the app, but it should never be committed to your repository and so is not available to the CI/CD pipeline when it clones your repo. diff --git a/azure.yaml b/azure.yaml index d5cdbce..17c0702 100644 --- a/azure.yaml +++ b/azure.yaml @@ -10,9 +10,6 @@ hooks: postprovision: shell: pwsh run: ./.azd/hooks/postprovision.ps1 - postdown: - shell: pwsh - run: ./.azd/hooks/postdown.ps1 services: web: project: ./