Skip to content

Commit

Permalink
Fix env var loop and key vault id query errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ebronson68 committed Aug 20, 2024
1 parent 022a1be commit 468c14c
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions .github/workflows/azfunction-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,14 @@ jobs:
with:
inlineScript: |
set -eu
# Assign the Key Vault Secrets User role to the managed identity
az role assignment create --role "Key Vault Secrets User" --assignee ${{ env.functionAppIdentity }} --scope $(az keyvault show --name ${{ env.keyVaultName }} --query id --output tsv)
# Retrieve the object ID of the managed identity
objectId=$(az ad sp show --id ${{ env.functionAppIdentity }} --query objectId --output tsv)
# Retrieve the Key Vault ID
keyVaultId=$(az keyvault show --name ${{ env.keyVaultName }} --query id --output tsv)
# Assign the Key Vault Secrets User role to the managed identity using object ID and principal type
az role assignment create --role "Key Vault Secrets User" --assignee-object-id $objectId --assignee-principal-type ServicePrincipal --scope $keyVaultId
- name: Retrieve environment variables
if: ${{ env.AZURE_CREDENTIALS_SET != 'false' }}
Expand All @@ -240,8 +246,10 @@ jobs:
inlineScript: |
set -eu
# Iterate over each environment variable
for part in ${{ steps.get-envs.outputs.environmentVariables }}; do
part=$(echo $part | xargs) # Trim leading and trailing spaces
ENV_VARS=($(echo '${{ steps.get-envs.outputs.environmentVariables }}'))
for part in ${ENV_VARS[@]}; do
IFS='=' read -r key value <<< "$part"
VARIABLE_LC=$(echo "$key" | tr '[:upper:]' '[:lower:]' | tr "_" "-")
if [[ "${{ inputs.environment }}" == "production" ]]; then
Expand Down

0 comments on commit 468c14c

Please sign in to comment.