I am currently trying out a lot with Azure Functions. With CI / CD pipelines and how to automatically deploy them. But also trying out C# and PowerShell to be used with Azure Functions. When I came to use PowerShell with Azure Functions, I got to a problem.
I am using an Azure Function with a queue trigger to read from that trigger. This function currently is including an administrator account and a password in clear text. Not good I though. I could encrypt it before putting it into the queue and then decrypt it when getting it out. But I wanted to have these settings rather saved in the app settings of the function. But how to access these app settings?
Lets see the following PowerShell Script that you could use
$result = ls env: | out-string write-output $result
What this does is basically getting all the environment variables, converting them into a string and output them to the logs. What you get is the following
There you can see variables starting with the name APPSETTING_ this means you could just access any app settings with the environment prefix. For example we want to access the standard variable QueueConnectionString. This would look like this
$result = ls env:APPSETTING_QueueConnectionString $result.value
So now you know how to access app settings this PowerShell 🙂