Issue
We have a function app in Azure, and from Azure DevOps, through a classic release pipeline, we deploy the function and app settings.
One of those app settings has a value "abcrndefrnghirn…"
However, when we deploy this app setting from DevOps, the value in Azure portal becomes
"abc\r\ndef\r\nghi\r\n…"
Does anyone know why, and how to avoid this additional being added please?
Here’s an overview of the task group tasks:
What I noticed
In the Azure portal UI, the value of the app setting shows as it was provided in DevOps. Thus, with single where needed.
However, in the underlying json, via Advanced Edit on the app settings, I see that the actual (real/used) value has double characters.
What I tried
- I tried using ` instead of . This didn’t help.
- If I provide the correct value, with single via Advanced Edit, the sftp connection that I’m trying to make works fine. However, we don’t want to do this manually.
Edit after key vault integration
I noticed that when I use (backtick)n instead of rn I can force PowerShell to create new lines. With rn this doesn’t work.
However, when I store the private key in the key vault, containing `n for new lines, this doesn’t work via the function.
n in the key vault secret value also does not work.
PS. I know I should not be outputting the private key value, but I’m doing this now for testing purposes only.
2
Answers
After implementing the key vault structure as suggested by Rui Jarimba, I had to update the PowerShell code of the function just a little to make this work.
Basically, the function retrieves the value of the secret from the key vault as plain text. To work around it I added a 'replace'.
Example where n is used in the key vault secret value:
The sFTP connection could then be made via:
You may use Azure Keyvault to store multiline settings. Then create a reference from the setting:
Additionally, you may use PowerShell to set the variable:
The result: