0
votes

Am working on Azure DevOps and Azure KeyVault. Here, am trying to login my Azure account using KeyVault secrets in Azure DevOps Pipelines. For that I followed the Link-1 which is used for fetching the secrets. All the setup is done properly and for checking it, I taken PowerShell task with Inline script as shown in figure where Password is KeyVault Secret: enter image description here

When the Build is run, it's runned without any error. But, here am getting KeyVault secrets(Password) values as following: enter image description here

After that, when I tried it for further steps by adding some code for login purpose am getting the error as following: enter image description here enter image description here Could you please suggest me how to get out of this situation

2
What are the further steps?Shayki Abramczyk
Thanks for giving reply @ShaykiAbramczyk. Further steps means trying to login by using Username and PasswordMani
Azure devops will never output variables defined as secret. Could you show the code of your further step please ? you probably don't need to convert your password as asecure string.Thomas
Hi @Thomas. I updated my question by adding the further stepMani
Can you try something like that $securePassword = "$(Password)" | ConvertTo-SecureString -AsPlainText -Force ? based on the error you may need to doube quote the variable.Thomas

2 Answers

0
votes

First, Azure Devops will not output varaibles defined as secrets.

Then you have a typo in your script. you should double-quote the password:

$securePassword = "$(Password)" | ConvertTo-SecureString -AsPlainText -Force
0
votes

Secrets variables need to be mapped before using it in pipeline.You can try below steps.

First, map the secrets to an environment variable in the powershell task enter image description here

Then use below scripts to refer to the password

$SecurePassword=$env:PASSWORDMAP

Click here For more information about how to use secret variables.