# ITenantProviderBindingStore

> Tracon documentation. Tracon is a .NET package family that adds a control
> plane on Microsoft Agent Framework, published as NuGet packages that run
> inside your own ASP.NET Core application.
>
> Page: https://tracon.dev/api/tracon.itenantproviderbindingstore/
> Summary: ITenantProviderBindingStore: The store for per-tenant model provider bindings (BYOK).

<div class="api-provenance">Namespace Tracon · Assembly <code>Tracon.Abstractions.dll</code></div>

The store for per-tenant model provider bindings (BYOK).

```csharp
public interface ITenantProviderBindingStore
```

## Remarks

This store never writes or reads a secret value, only the
**name** of the configuration key the value is read from at
call time.

**Provider names are matched case-insensitively.** An
implementation must pass every provider name it writes, and every
provider name it is queried with, through
[TenantProviderBinding.NormalizeProviderName](/api/tracon.tenantproviderbinding/#Tracon_TenantProviderBinding_NormalizeProviderName_System_String_). This is not a
convenience: the provider registry, the tenant egress policy and the admin
endpoint all match the name case-insensitively, so a case-sensitive store
turns a binding saved as `"OpenAI"` into a MISS for an agent whose
definition says `"openai"` — and a miss falls through to the global
setup credential silently, billing the wrong tenant with no error raised.
`TenantProviderBindingStoreContract` proves this for every
implementation.

An implementation is registered as a *singleton* and must be safe
under concurrent calls from unrelated tenants.

## Methods

### <a id="Tracon_ITenantProviderBindingStore_DeleteAsync_System_String_System_String_System_Threading_CancellationToken_"></a> DeleteAsync\(string, string, CancellationToken\)

Deletes a tenant's binding for a provider.

```csharp
ValueTask<bool> DeleteAsync(string tenantId, string providerName, CancellationToken cancellationToken = default)
```

#### Parameters

`tenantId` [string](https://learn.microsoft.com/dotnet/api/system.string)

The tenant identifier.

`providerName` [string](https://learn.microsoft.com/dotnet/api/system.string)

The provider name.

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

The cancellation token.

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask\-1)<[bool](https://learn.microsoft.com/dotnet/api/system.boolean)\>

[true](https://learn.microsoft.com/dotnet/csharp/language-reference/builtin-types/bool) if a binding was found and deleted.

### <a id="Tracon_ITenantProviderBindingStore_GetAsync_System_String_System_String_System_Threading_CancellationToken_"></a> GetAsync\(string, string, CancellationToken\)

Reads a single tenant's binding for a provider.

```csharp
ValueTask<TenantProviderBinding?> GetAsync(string tenantId, string providerName, CancellationToken cancellationToken = default)
```

#### Parameters

`tenantId` [string](https://learn.microsoft.com/dotnet/api/system.string)

The tenant identifier.

`providerName` [string](https://learn.microsoft.com/dotnet/api/system.string)

The provider name.

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

The cancellation token.

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask\-1)<[TenantProviderBinding](/api/tracon.tenantproviderbinding/)?\>

The binding; [null](https://learn.microsoft.com/dotnet/csharp/language-reference/keywords/null) if none exists.

### <a id="Tracon_ITenantProviderBindingStore_ListAsync_System_String_System_Threading_CancellationToken_"></a> ListAsync\(string, CancellationToken\)

Lists every provider binding of a tenant.

```csharp
ValueTask<IReadOnlyList<TenantProviderBinding>> ListAsync(string tenantId, CancellationToken cancellationToken = default)
```

#### Parameters

`tenantId` [string](https://learn.microsoft.com/dotnet/api/system.string)

The tenant identifier.

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

The cancellation token.

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask\-1)<[IReadOnlyList](https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist\-1)<[TenantProviderBinding](/api/tracon.tenantproviderbinding/)\>\>

The bindings, by provider name.

### <a id="Tracon_ITenantProviderBindingStore_UpsertAsync_Tracon_TenantProviderBinding_System_Threading_CancellationToken_"></a> UpsertAsync\(TenantProviderBinding, CancellationToken\)

Creates or replaces a tenant's binding for a provider.

```csharp
ValueTask UpsertAsync(TenantProviderBinding binding, CancellationToken cancellationToken = default)
```

#### Parameters

`binding` [TenantProviderBinding](/api/tracon.tenantproviderbinding/)

The binding to save.

`cancellationToken` [CancellationToken](https://learn.microsoft.com/dotnet/api/system.threading.cancellationtoken)

The cancellation token.

#### Returns

 [ValueTask](https://learn.microsoft.com/dotnet/api/system.threading.tasks.valuetask)

The completion task.
