ironmansoftware / powershell-universal

Issue tracker for PowerShell Universal
https://powershelluniversal.com
34 stars 2 forks source link

PSU KeyVault variables lost after reboot #1200

Open tobrienultima opened 2 years ago

tobrienultima commented 2 years ago

Steps to Reproduce

I'm running PSU in an Azure docker container webapp and I have it configured to store variables as secrets in an Azure KeyVault. Creating secrets and reading them back works fine and I can also import existing secrets via the UI and via script.

The problem seems to be when I reboot the webapp, all of the variables go into this state where PSU thinks they don't exist.

image

As written in the documentation, I have a script which runs after startup to re-register with KeyVault on a 30 second delay (I have also tried reducing this to 5 seconds) so I wonder if PSU is trying to load the variables before it has connected back to KeyVault, and then doesn't attempt to try again.

If I manually create a secret in the UI then it seems to force the connection to open and the existing variables go back to their normal state and can be used again.

Expected behavior

After re-registering with KeyVault the PSU variables with AzureKeyVault as the source should refresh.

Actual behavior

Variables stay in a disconnected state and all values are $null.
Example of using a variable in a dashboard in visuals section.

Environment data

PSU v2.11.1 Azure Docker WebApp

Visuals

image
tobrienultima commented 2 years ago

In addition, if I create an automation script which appends something to the variables.ps1 file then the variables section seems to 'reload' presumably because PSU has opened and updated the file, it then re-loads it. Adding or removing content from the file manually in VSCode doesn't do this though and the variables section remains out of sync.

MattHarrisUltima commented 1 year ago

Hi @adamdriscoll ,

I have been looking into this problem a little more and suspect part of the problem may be that all this runs after the container load but before the module load.

Would it be possible to include the latest az.keyvault and az.accounts modules with the next container release?