7

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?

Boris Lipschitz
  • 9,236
  • 5
  • 53
  • 63

2 Answers2

1

You can use variable in Azure Subscription, but the value should be the actual value of related endpoint.

  1. Create a new release/build definition with debug enabled (set/add system.debug variable to true) and add Azure PowerShell task to get the actual value.
  2. Start/Queue release/build, then check the log, you can find the log like this: ##[debug]INPUT_CONNECTEDSERVICENAMEARM: '{actual value}’
  3. Edit task group, specify variable in Azure Subscription input box (e.g. $(sub)) >Save
  4. Edit your release definition, add the variable(s) (e.g. mySub) with that actual value (step 1)
  5. Tasks > Select related Task group > Specify variable (e.g. $(mySub)) in sub (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
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