When asking for a password from the user, we use the Read-Host -AsSecureString to have the password hidden while typing. Before getting the authentication token from Cloud-iQ, we need to convert this to plain text before adding it to the header.
However, at first we had issues with Windows PowerShell since it doesn't like ConvertFrom-SecureString so we tried setting it up using the Marshal class from dotnet. Now that seems to be a problem for running the code in Azure Functions.
On reflection, decoding the string before adding it to the header means that one have to encode it first. If we didn't encode the string when using a value from $ENV:CloudiQPassword, and kept decoding to only happen if the password came from user input, we could avoid unnecessary steps.
When asking for a password from the user, we use the
Read-Host -AsSecureString
to have the password hidden while typing. Before getting the authentication token from Cloud-iQ, we need to convert this to plain text before adding it to the header.However, at first we had issues with Windows PowerShell since it doesn't like
ConvertFrom-SecureString
so we tried setting it up using the Marshal class from dotnet. Now that seems to be a problem for running the code in Azure Functions.On reflection, decoding the string before adding it to the header means that one have to encode it first. If we didn't encode the string when using a value from
$ENV:CloudiQPassword
, and kept decoding to only happen if the password came from user input, we could avoid unnecessary steps.