Users

All Posts (7)

avatar

mariobeeler

Initialize.ps1 not run, Trigger "Server Started" not triggered for keyvault registration

avatar
avatar
avatar
avatar
avatar

Thank you for your feedback. After Point 2: Can you go to “Platform - Variables” and if you add a new secret-variable do you see your registered vault in the menu “Vaults”? Because I can register the SecretVault but I don’t see it in PowerShell Universal. I ask this because of the manual, I was never able to see the new secret-vault there on “Vaults”

The rest is working fine, I used your code and have now my secret set as secret-variable in powershell universal.

Thank you.

Edit:

At mine there must be something wrong with step two. I run that and do not have any error, I can also run step 3 and get the variables from the AZKeyVault. But after that I have an error in the variable that says “This secret does not exist in the vault”. At this point I have no idea why my Register-SecretVault ist not working.

Initialize.ps1 not run, Trigger "Server Started" not triggered for keyvault registration

avatar
avatar
avatar
avatar
avatar

My script to register the secret vault looks like this:

1361Variables

$1361SubscriptionID = “xyxy”

$VaultName = ‘xyxy’

$VaultParameters = @{

AZKVaultName = $VaultName

SubscriptionId = $1361SubscriptionID

}

Connect Azure

Connect-AzAccount -Identity -SubscriptionId $1361SubscriptionID

Register Azure Key Vault

Register-SecretVault -ModuleName ‘Az.KeyVault’ -Name ‘AzureKeyVault’ -VaultParameters $VaultParameters -AllowClobber

Initialize.ps1 not run, Trigger "Server Started" not triggered for keyvault registration

avatar
avatar
avatar
avatar
avatar

Still have problems to get it to work. I now have the version 4.0.12-modules in the docker. I also activated the managed Identity for the app service and give them Reader-Permissions to the subscription and SecretReader-Permissions to the key vault.

Now in the job of the script I see that Connect-Azure works fine, but there is no feedback on the Register-SecretVault command. I also can not look at it at jobs, because since I have version 4.0.12 loaded there is just “No data” in jobs.

Till now, I just have problems with the version 4.0.12. It also needs much more time when I restart the app service, I have to wait about 6-7 minutes till I can access. And always on first access there is “Application error” and on the second access it loads all the modules and loads Universal fine.

I will now try to figure the problems out with the system logs.

Addendum:

I do the one time scripts: Connect-AzAccount - Identity -SubscriptionID… works fine. Then i do Set-AzContext with a Name and the SubscriptionID… also works fine. I can run Get-AzContext and get the context i set. After that I do a “Restart” of the app service. I try to run Get-AzContext again… no feedback, there is no Context there after the restart.

I tried this with 4.0.12-modules and also with 4.0.11-modules, with both version the same problem. Also with both version there are no jobs showed, it loads a long time and then shows “no jobs”.

Probably someone have a tip for me? I try to figure it out.

Best,

Mario

Initialize.ps1 not run, Trigger "Server Started" not triggered for keyvault registration

avatar
avatar
avatar
avatar
avatar

I will try it with the 4.0.12-modules later that day and will let you know.

The application error is gone, i just had to wait a few minutes and Universal was starting up without error. Now I don’t have an error when i connect to the Azure Key Vault, but it is not connected. I will load the older version, try it again and will let you know.

Initialize.ps1 not run, Trigger "Server Started" not triggered for keyvault registration

avatar
avatar
avatar
avatar
avatar

Hi @AnonymousUser

Thank you for your answer. We are using “ironmansoftware/universal:latest”

I try to do that. But when I activate managed Identity for my app, give them Reader-Permissions to the subscription and SecretReader-Permissions to the key vault it ends with “Application Error” when i start up the app service again.

I will figure it out why this error happens here and come back how it works.

Best,

Mario

Initialize.ps1 not run, Trigger "Server Started" not triggered for keyvault registration

avatar
avatar
avatar
avatar
avatar

Addendum: initialize.ps1 runs, because I also tested if the script is creating the test.txt file in the directory “.universal” > it does.

Initialize.ps1 not run, Trigger "Server Started" not triggered for keyvault registration

avatar
avatar
avatar
avatar
avatar

Hi there

I found this article because I have problems to import modules in initilize.ps1. I want to import Az.Accounts and Az.KeyVault, that I am able to connect our Azure KeyVault to PowerShell Universal. We have PowerShell Universal installed as docker in our Azure.

I can not connect our Azure KeyVault in initilize.ps1 because of this error:

System.Management.Automation.CommandNotFoundException: The term ‘Connect-AzAccount’ is not recognized as a name of a cmdlet, function, script file, or executable program

I try to import the modules which are installed in Modules, but I get this error when I try to import:

System.IO.FileNotFoundException: The specified module ‘Modules/Az.Accounts’ was not loaded because no valid module file was found in any module directory.

2023-09-12 13:59:42.004 +00:00 [ERR] Exception:

System.IO.FileNotFoundException: The specified module ‘Modules/Az.KeyVault/4.11.0/Az.KeyVault.psd1’ was not loaded because no valid module file was found in any module directory.

2023-09-12 13:59:42.004 +00:00 [ERR] Exception:

As you see in the log: I tried with name, with folder-path and also with the whole path from the .psd1 or also the .psm1 file… everytime the same error “no valid module file was found in any module directory”

Do I have to import it differently because of the docker-installation?

Thank you for your inputs.

Best,

Mario

1 - 7 of 7 items