.NET Octopus Client - Update Machine settings


I need to lock the version on a bunch of machines. Does anyone have a c# example on how to update that setting?



Hi Don,

I have put together a quick C# script that will lock the version of machines specified:

var server = "<youroctopusserverurl>";
var apiKey = "<yourapikey>";

var client = new Octopus.Client.OctopusClient(new Octopus.Client.OctopusServerEndpoint(server, apiKey));
var repo = new Octopus.Client.OctopusRepository(client);

var machineNamesToLockVersionFor = new string[] { "...", "...", "..." }; //Include the names of the machines you want to lock the version for
var machines = repo.Machines.FindMany(m=>machineNamesToLockVersionFor.Contains(m.Name));
foreach (var machine in machines)
	var endpoint = machine.Endpoint as Octopus.Client.Model.Endpoints.TentacleEndpointResource;
	if (endpoint != null)
		endpoint.TentacleVersionDetails.UpgradeLocked = true;

I hope that helps!

Thank you and best regards,