# IDeploymentStateManager Methods

- Package: [Aspire.Hosting](/reference/api/csharp/aspire.hosting.md)
- Type: [IDeploymentStateManager](/reference/api/csharp/aspire.hosting/ideploymentstatemanager.md)
- Kind: `Methods`
- Members: `4`

Provides deployment state management functionality.

## AcquireSectionAsync(string, CancellationToken)

- Name: `AcquireSectionAsync(string, CancellationToken)`
- Modifiers: `abstract`
- Returns: [Task<DeploymentStateSection>](/reference/api/csharp/aspire.hosting/deploymentstatesection.md)

Acquires a specific section of the deployment state with version tracking for concurrency control. The returned section is an immutable snapshot of the data at the time of acquisition.

```csharp
public interface IDeploymentStateManager
{
    public abstract Task<DeploymentStateSection> AcquireSectionAsync(
        string sectionName,
        CancellationToken cancellationToken = default(CancellationToken))
    {
        // ...
    }
}
```

## Parameters

- `sectionName` (`string`)
  The name of the section to acquire (e.g., "Parameters", "Azure").
- `cancellationToken` (`CancellationToken`) `optional`
  The cancellation token.

## Returns

[Task<DeploymentStateSection>](/reference/api/csharp/aspire.hosting/deploymentstatesection.md) -- A StateSection containing the section data and version information.

## ClearAllStateAsync(CancellationToken)

- Name: `ClearAllStateAsync(CancellationToken)`
- Modifiers: `abstract`
- Returns: `Task`

Clears all deployment state, removing all sections and the underlying storage.

```csharp
public interface IDeploymentStateManager
{
    public abstract Task ClearAllStateAsync(
        CancellationToken cancellationToken = default(CancellationToken))
    {
        // ...
    }
}
```

## Parameters

- `cancellationToken` (`CancellationToken`) `optional`
  The cancellation token.

## DeleteSectionAsync(DeploymentStateSection, CancellationToken)

- Name: `DeleteSectionAsync(DeploymentStateSection, CancellationToken)`
- Modifiers: `abstract`
- Returns: `Task`

Delete a section of deployment state with optimistic concurrency control. The section must have a matching version number or a concurrency exception will be thrown.

```csharp
public interface IDeploymentStateManager
{
    public abstract Task DeleteSectionAsync(
        DeploymentStateSection section,
        CancellationToken cancellationToken = default(CancellationToken))
    {
        // ...
    }
}
```

## Parameters

- `section` ([DeploymentStateSection](/reference/api/csharp/aspire.hosting/deploymentstatesection.md))
  The section to delete, including version information.
- `cancellationToken` (`CancellationToken`) `optional`
  The cancellation token.

## Exceptions

- `InvalidOperationException` -- Thrown when a version conflict is detected, indicating the section was modified after it was acquired.

## SaveSectionAsync(DeploymentStateSection, CancellationToken)

- Name: `SaveSectionAsync(DeploymentStateSection, CancellationToken)`
- Modifiers: `abstract`
- Returns: `Task`

Saves a section of deployment state with optimistic concurrency control. The section must have a matching version number or a concurrency exception will be thrown.

```csharp
public interface IDeploymentStateManager
{
    public abstract Task SaveSectionAsync(
        DeploymentStateSection section,
        CancellationToken cancellationToken = default(CancellationToken))
    {
        // ...
    }
}
```

## Parameters

- `section` ([DeploymentStateSection](/reference/api/csharp/aspire.hosting/deploymentstatesection.md))
  The section to save, including version information.
- `cancellationToken` (`CancellationToken`) `optional`
  The cancellation token.

## Exceptions

- `InvalidOperationException` -- Thrown when a version conflict is detected, indicating the section was modified after it was acquired.
