skip to Main Content

I have defined a service connection of type Generic, called ‘DowntimeApiKeyGen’ in azure.
The encrypted value of the apikey is saved under ‘Password/Token Key’.
How can i access the value of this apikey from an environment variable in a powershell-task under the agent phase?

I have tried various calls like following without success.
enter image description here

I think, there is something wrong with calling the variable.
Does anyone have an idea, how to solve this issue?

2

Answers


  1. In Azure, access a service connection from an environment variable using the Azure DevOps REST API. Integrate commands within your pipeline scripts.

    Login or Signup to reply.
  2. I believe you are interpreting the concept of a generic service connection in azure devops incorrectly. The username and Password/Token key is required to connect to your service which is hosted by the URL that you put in the Server URL field, while creating the generic service connection under project settings. It is not supposed to store environment variables for you. Judging by your screenshot, it looks you are using classic pipelines instead of YAML based pipelines. The powershell task that you are trying to configure doesn’t allow you to add a service connection. However Azure Powershell task will allow you to do that.

    But for your requirement, all you need to do is add your api keys/secrets under the variables tab, beside Tasks. That should fix your issue.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search