I'm trying to create a Task Group out of several tasks that Deploy a few apps into Azure AppService among other things. My idea is to use this Task Group to deploy into different Environments (ie, Dev, QA, UAT, Prod). However, I can't convert Azure Subscription into a variable, which is currently a process Parameter. Is there a solution for that?
Asked
Active
Viewed 1,772 times
2 Answers
1
You can use variable in Azure Subscription, but the value should be the actual value of related endpoint.
- Create a new release/build definition with debug enabled (set/add
system.debug
variable totrue
) and add Azure PowerShell task to get the actual value. - Start/Queue release/build, then check the log, you can find the log like this: ##[debug]INPUT_CONNECTEDSERVICENAMEARM: '{actual value}’
- Edit task group, specify variable in Azure Subscription input box (e.g.
$(sub)
) >Save - Edit your release definition, add the variable(s) (e.g.
mySub
) with that actual value (step 1) - Tasks > Select related Task group > Specify variable (e.g.
$(mySub)
) insub
(per to step 3) input box.
On the other hand, you can choose azure subscription for related task group directly (step 3, then edit tasks for an environment > Choose Azure Subscription directly)

starian chen-MSFT
- 33,174
- 2
- 29
- 53
-
Thanks. I've tried that and it didn't work. My debug value output was: ##[debug]ConnectedServiceName={--Guid--}. Then, after substituting, I got the error: Error: Task failed while initializing. Error: Endpoint auth data not present: {--Guid--} – Boris Lipschitz Apr 19 '18 at 00:07
-
What's the Guid like? (XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX) No quotes (`''`) and {}. On the other hand, what's the result if you choose endpoint for task group directly? – starian chen-MSFT Apr 19 '18 at 01:56
-
Yep, normal guid and no quotes. – Boris Lipschitz Apr 19 '18 at 06:52
-
Can you share the detail log on the OneDrive (Set system.debug variable to true)? – starian chen-MSFT Apr 19 '18 at 06:53
-
https://support.office.com/en-us/article/share-onedrive-files-and-folders-9fcc2f7d-de0c-4cec-93b0-a82024800c07?ui=en-US&rs=en-US&ad=US, remove sensitive data, such as Guid value. – starian chen-MSFT Apr 19 '18 at 07:21
-
what's the result if you choose endpoint for task group directly? – starian chen-MSFT Apr 19 '18 at 07:49
-
what do you mean? – Boris Lipschitz Apr 19 '18 at 09:52
-
@BorisLipschitz 1. Step 3, 2. Edit an environment of your release definition and choose endpoint for the task group in `sub` (per to step 3) input box. – starian chen-MSFT Apr 20 '18 at 01:25
-
1Using the value in INPUT_CONNECTEDSERVICENAMEARM worked for me. – Martijn B Dec 17 '18 at 15:52
-
@starianchen-MSFT I can't save if I put variable in Azure Resource Manager connection. https://imgur.com/a/B8zOGIs How I can deal with this? – Krzysztof Madej Jul 14 '20 at 12:06
0
While there are examples out there that suggest you can use a variable for the service connection name, there is also some documentation out there that suggests that variables for service connections are not supported (https://learn.microsoft.com/en-us/azure/devops/pipelines/library/service-endpoints?view=azure-devops&tabs=yaml#use-a-service-connection, for example).
I've run up against this in my own pipelines and solved it using template expressions:
${{ if eq(parameters.environmentType, 'dev') }}:
azureResourceManagerConnection: Azure Dev
${{ if eq(parameters.environmentType, 'test') }}:
azureResourceManagerConnection: Azure Test
${{ if eq(parameters.environmentType, 'prod') }}:
azureResourceManagerConnection: Azure Prod

WaitingForGuacamole
- 3,744
- 1
- 8
- 22