0

I have a Deployment Group with X number of servers.
I've created and set up my Release Pipeline to work as expected.
When I run it, it deploys to all servers under my Deployment group. (I do filter by specific Tags but that's irrelevant)

What I need now, is to be able to filter/exclude servers on the fly during deployments (for example: deploy only on the first server and leave the rest unchanged)

Something like the below (screenshot taken from Octopus which supports this functionality) enter image description here

I'm trying to migrate a few Release Definitions from Octopus to Azure Pipelines and this is blocking me.

George Vovos
  • 7,563
  • 2
  • 22
  • 45
  • It looks like this is not supported so I created a ticket at https://developercommunity.visualstudio.com/idea/938778/allow-users-to-exclude-deployment-targets-from-rel.html – George Vovos Mar 04 '20 at 13:48
  • We are creating Windows applications. Actually what I want is a pool of deployment machines, just like the agent pool. – ffonz Mar 28 '23 at 17:13

3 Answers3

3

Since this is not supported by Azure Pipelines, I ended up using a workaround:

  1. Create a Pipeline Variable that contains my 4 server names. enter image description here

  2. Add a Custom condition on my steps
    'and(succeeded(), contains(variables['IncludedServers'],variables['Agent.MachineName'])) enter image description here

3.Edit the variable, if necessary, when creating a release enter image description here

I do want to improve a few things, like the contains expression so that there are no problems with false positives when I have substrings.

It's not perfect, because of the possibilities of typos but it's probably an acceptable workaround. Hopefully Microsoft will add official support for this.

I'm adding the feature request link again here, upvote if you find this useful.
Allow users to Exclude Deployment Targets from Release on the fly

George Vovos
  • 7,563
  • 2
  • 22
  • 45
  • Clever solution. But why is the condition and(succeeded(),... added? Isn't contains(...) sufficient? – ffonz Mar 28 '23 at 15:09
  • 1
    @ffonz succeeded() function checks if the previous step succeeded. I don't want to run this step is something has failed. https://learn.microsoft.com/en-us/azure/devops/pipelines/process/conditions?view=azure-devops&tabs=classic%2Cstages – George Vovos Mar 28 '23 at 16:58
1

How deploy Release on subset of Deployment Group servers

Generally, we use machine tags to limit deployment to specific sets of target servers.

The tags you assign allow you to limit deployment to specific servers when the deployment group is used in a Deployment group job.

enter image description here

enter image description here

In addition, you can also disable targets in the Deployment pools of Organization Settings.

enter image description here

Update:

Here is the uservoice on allowing users to Exclude Deployment Targets from Release on the fly. Anyone interested in this can vote for it and track it.

Hugh Lin
  • 17,829
  • 2
  • 21
  • 25
  • Thanks Hugh,I was hoping there was a simpler way without disabling and reenabling servers. We have hundreds of servers, I don't think I can sell this to management. My scenerio is the following.For each of our products, there are X number of servers with the same Tag that sit behind a load balancer and I would like to be able to deploy to a subset of them first,then run tests and lastly deploy to the rest. – George Vovos Mar 04 '20 at 08:04
  • According to your scenario, you can only add a separate tag to these target machines for filtering.Currently we cannot filter after filtering with tags. – Hugh Lin Mar 04 '20 at 08:14
  • Thanks Hugh but I don't think I can sell this to management, it'll be too complex to create separate tags per server per product. I'll try to find another alternative or stick to Octopus for now. I'll create a suggestion on developercommunity.visualstudio.com though. Thanks again – George Vovos Mar 04 '20 at 11:16
  • @George Vovos Great! I've seen your ticket and voted for you.I added the uservoice to the answer, so anyone interested in this can vote for it and track it. Thanks for your feedback which may improve our product. Hope this helps. :) – Hugh Lin Mar 05 '20 at 09:53
  • Hugh, I do have a workaround involving variables and conditional tasks. It's not perfect but it's better than disabling/re-enabling servers I think. I'll post it as an answer later – George Vovos Mar 05 '20 at 09:57
  • Great! I think this is feasible. It is better to test the feasibility of the custom condition expression through a simple test. – Hugh Lin Mar 05 '20 at 14:31
0

We can create a custom variable and use that as a tag name under deployment group job. Deployment group with the servers should have approproiate matching tags to filter the servers on the fly. This way, we can deploy the artifacts through release pipelines by simply updating Deployment groups and Custom variable as needed.