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.
I think, there is something wrong with calling the variable.
Does anyone have an idea, how to solve this issue?
2
Answers
In Azure, access a service connection from an environment variable using the Azure DevOps REST API. Integrate commands within your pipeline scripts.
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.