# CosmosGrainStorage.WriteStateAsync(string, GrainId, IGrainState&lt;T&gt;)

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.persistence.cosmos.cosmosgrainstorage/) | [Methods](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.persistence.cosmos.cosmosgrainstorage/methods/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/CosmosGrainStorage.cs#L101-L167)

```csharp
public Task WriteStateAsync<T>(string grainType, GrainId grainId, IGrainState<T> grainState)
```

Write data function for this storage instance.

### Parameters

- `grainType` (`string`): Name of the state for this grain
- `grainId` (`GrainId`): Grain ID
- `grainState` (`IGrainState<T>`): State data object to be written for this grain.

### Returns

Completion promise for the Write operation on the specified grain.
