.NET Octopus.Client: tenant.Delete() not available?

Hi Support,

I was wondering if there was a way to delete tenants via the Octopus.Client .NET interface?

I’ve created dozens of tenants in a test setup but removing them is a very cumbersome task. Writing a small tool to delete all tenants matching a certain regexp is easy, as long as the interface allows me to delete a tenant.

Is there a way?


Hi Eelko,

Thanks for getting in touch.

The Tenants repository in our Octopus.Client package conforms to the IDelete<TenantResponse> interface, so if you have a Tenant resource object, you should be able to call repository.Tenants.Delete(yourTenantResourceHere).

For example

async Task MainAsync() 
	var server = "http://YOUR_OCTOPUS_SERVER";
	var apiKey = "API-YOUR_API_KEY";
	var tenantNameToDelete = "YOUR_TENANT_NAME";
	using(var client = await OctopusAsyncClient.Create(new OctopusServerEndpoint(server, apiKey))) 
		var tenant = await client.Repository.Tenants.FindByName(tenantNameToDelete);
		if (tenant == null) {
			throw new Exception($"Failed to find tenant with name: {tenantNameToDelete}");
		await client.Repository.Tenants.Delete(tenant);
		Console.WriteLine($"Tenant {tenant.Name} has been successfully deleted.");

Hope this helps. Let me know how you go.


Hi Mark!

Thanks for your answer - it showed me The Way.

I’ve been able to create my delete-tenant commandline tool that looks for and deletes all expression-matching tenants. Very useful with my tests, in which I’ve created hundreds of tenants.

So thanks!


1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.