Hello @Sanjana Pushkar
Welcome to Microsoft QnA!
Try this :
- script: | echo "Extracting zip file" unzip $(System.DefaultWorkingDirectory)/EXCO.AzureFunctions_01Aug.zip -d $(Pipeline.Workspace)/extracted displayName: 'Extract Zip File'
- script: | echo "Printing local.settings.json content" cat $(Pipeline.Workspace)/extracted/**/local.settings.json displayName: 'Print local.settings.json content'
- script: | echo "Parsing local.settings.json" CONFIG_FILE=$(find $(Pipeline.Workspace)/extracted/ -name "local.settings.json") ENV_VARS=$(jq -r '.Values | to_entries | map("(.key)=(.value)") | .[]' $CONFIG_FILE) echo "$ENV_VARS" > $(Pipeline.Workspace)/env_vars.txt displayName: 'Parse local.settings.json'
- script: | echo "Setting environment variables" while IFS= read -r line; do
done < $(Pipeline.Workspace)/env_vars.txt displayName: 'Set Environment Variables'echo "##vso[task.setvariable variable=${line%=*}]${line#*=}"
- job: DeployFunctionApp dependsOn: DownloadBuild steps:
- task: AzureFunctionApp@2 inputs: connectedServiceNameARM: 'DevServiceConnector' appType: 'functionApp' appName: 'sanjanatestfademo' package: '$(System.DefaultWorkingDirectory)/**/*.zip' appSettings: '$(Pipeline.Workspace)/env_vars.txt' deploymentMethod: 'auto' displayName: 'Deploy Function App with Environment Variables'
The script loops through each environment variable, sanitizing the value (e.g., adding quotes when necessary) and uses the ##vso[task.setvariable]
command to set the variable securely within the pipeline environment.
Let me know how it went !
--
I hope this helps!
The answer or portions of it may have been assisted by AI Source: ChatGPT Subscription
Kindly mark the answer as Accepted and Upvote in case it helped!
Regards