question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Azure Key Vault Task - How to pass secret (pfx) to another task?

See original GitHub issue

Trying 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:closed
  • Created 6 years ago
  • Comments:13 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
psuncommented, May 19, 2019

It works for me that if I change the inline script to:

$kvSecretBytes = [System.Convert]::FromBase64String("$(PfxSecret)")

0reactions
mkocakscommented, Jun 8, 2022

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 😦

Read more comments on GitHub >

github_iconTop Results From Across the Web

Azure Key Vault Task - How to pass secret (pfx) to another ...
Trying to use the Azure Key Vault Task following the documentation here. Tried the code mentioned below to get the pfx file from...
Read more >
AzureKeyVault@2 - Azure Key Vault v2 task
Use this task to download secrets, such as authentication keys, storage account keys, data encryption keys, .PFX files, and passwords from ...
Read more >
Using secrets from Azure Key Vault in a pipeline
Navigate to the Azure DevOps project. Select Pipelines | Pipelines from the left navigation bar.
Read more >
Using Azure Key Vault Secrets from your DevOps pipelines
PFX files, and passwords from an Azure Key Vault instance. The task can be used to fetch the latest values of all or...
Read more >
As description of Azure Key Vault task of release pipelien in ...
As description of Azure Key Vault task of release pipelien in Azure devops says: It will ... I am passing my secret name...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found