Azure Key Vault Task - How to pass secret (pfx) to another task?
See original GitHub issueTrying to use the Azure Key Vault Task following the documentation here. Tried the code mentioned below to get the pfx file from an Azure Powershell Task using an inline script, like this:
$kvSecretBytes = [System.Convert]::FromBase64String($(PfxSecret))
However I get the below error
2017-08-01T08:35:30.1870994Z ##[debug]Caught exception from task script. 2017-08-01T08:35:30.1870994Z ##[debug]Error record: 2017-08-01T08:35:30.2808945Z ##[debug]ForEach-Object : At E:\agent_work_temp\6e393290-eeb1-4530-a08b-83c62afa11bf.ps1:1 char:53 2017-08-01T08:35:30.2808945Z ##[debug]+ $kvSecretBytes = [System.Convert]::FromBase64String(MIIXkgIBAzCCF1IGC … 2017-08-01T08:35:30.2808945Z ##[debug]+ ~ 2017-08-01T08:35:30.2808945Z ##[debug]Missing ‘)’ in method call. 2017-08-01T08:35:30.2808945Z ##[debug] 2017-08-01T08:35:30.2808945Z ##[debug]At E:\agent_work_temp\6e393290-eeb1-4530-a08b-83c62afa11bf.ps1:1 char:53
How can I use the certificate from keyvault PfxSecret
or pass it to an Azure Powershell Task as a script argument? Can you please share working code?
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (9 by maintainers)
It works for me that if I change the inline script to:
$kvSecretBytes = [System.Convert]::FromBase64String("$(PfxSecret)")
Also https://github.com/microsoft/azure-pipelines-tasks/pull/14962 You cannot pass args, params to an inline script as pipeline ps task adds its own bits at the top which invalidates for example param($myparam) Alot of documentation that is totally misleading 😦