# HostingExtensions Methods

[Type overview](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/)

## AddCosmosGrainStorage(IServiceCollection, string, Action&lt;CosmosGrainStorageOptions&gt;) {#addcosmosgrainstorage-this-microsoft-extensions-dependencyinjection-iservicecoll-a507245e}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorage-this-microsoft-extensions-dependencyinjection-iservicecoll-a507245e/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs)

```csharp
public static IServiceCollection AddCosmosGrainStorage(this IServiceCollection services, string name, Action<CosmosGrainStorageOptions> configureOptions)
```

Configure silo to use Azure Cosmos DB storage for grain storage.

### Parameters

- `services` (`IServiceCollection`): The service collection.
- `name` (`string`): The storage provider name.
- `configureOptions` (`Action<CosmosGrainStorageOptions>`): The delegate used to configure the provider.

## AddCosmosGrainStorage(IServiceCollection, string, Action&lt;OptionsBuilder&lt;CosmosGrainStorageOptions&gt;&gt;) {#addcosmosgrainstorage-this-microsoft-extensions-dependencyinjection-iservicecoll-11e671f2}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorage-this-microsoft-extensions-dependencyinjection-iservicecoll-11e671f2/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs)

```csharp
public static IServiceCollection AddCosmosGrainStorage(this IServiceCollection services, string name, Action<OptionsBuilder<CosmosGrainStorageOptions>>? configureOptions = null)
```

Configure silo to use Azure Cosmos DB storage for grain storage.

### Parameters

- `services` (`IServiceCollection`): The service collection.
- `name` (`string`): The storage provider name.
- `configureOptions` (`Action<OptionsBuilder<CosmosGrainStorageOptions>>`): The delegate used to configure the provider.

## AddCosmosGrainStorage(ISiloBuilder, string, Action&lt;CosmosGrainStorageOptions&gt;) {#addcosmosgrainstorage-this-orleans-hosting-isilobuilder-string-system-action-orl-f6a139eb}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorage-this-orleans-hosting-isilobuilder-string-system-action-orl-f6a139eb/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs)

```csharp
public static ISiloBuilder AddCosmosGrainStorage(this ISiloBuilder builder, string name, Action<CosmosGrainStorageOptions> configureOptions)
```

Configure silo to use Azure Cosmos DB storage for grain storage.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.
- `name` (`string`): The storage provider name.
- `configureOptions` (`Action<CosmosGrainStorageOptions>`): The delegate used to configure the provider.

## AddCosmosGrainStorage(ISiloBuilder, string, Action&lt;CosmosGrainStorageOptions&gt;, Type) {#addcosmosgrainstorage-this-orleans-hosting-isilobuilder-string-system-action-orl-9d7bb572}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorage-this-orleans-hosting-isilobuilder-string-system-action-orl-9d7bb572/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs#L72-L78)

```csharp
public static ISiloBuilder AddCosmosGrainStorage(this ISiloBuilder builder, string name, Action<CosmosGrainStorageOptions> configureOptions, Type customPartitionKeyProviderType)
```

Configure silo to use Azure Cosmos DB storage for grain storage using a custom Partition Key Provider.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.
- `name` (`string`): The storage provider name.
- `configureOptions` (`Action<CosmosGrainStorageOptions>`): The delegate used to configure the provider.
- `customPartitionKeyProviderType` (`Type`): The custom partition key provider type.

## AddCosmosGrainStorage(ISiloBuilder, string, Action&lt;OptionsBuilder&lt;CosmosGrainStorageOptions&gt;&gt;) {#addcosmosgrainstorage-this-orleans-hosting-isilobuilder-string-system-action-mic-fc355843}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorage-this-orleans-hosting-isilobuilder-string-system-action-mic-fc355843/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs)

```csharp
public static ISiloBuilder AddCosmosGrainStorage(this ISiloBuilder builder, string name, Action<OptionsBuilder<CosmosGrainStorageOptions>>? configureOptions = null)
```

Configure silo to use Azure Cosmos DB storage for grain storage.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.
- `name` (`string`): The storage provider name.
- `configureOptions` (`Action<OptionsBuilder<CosmosGrainStorageOptions>>`): The delegate used to configure the provider.

## AddCosmosGrainStorage(ISiloBuilder, string, Type, Action&lt;OptionsBuilder&lt;CosmosGrainStorageOptions&gt;&gt;) {#addcosmosgrainstorage-this-orleans-hosting-isilobuilder-string-system-type-syste-e3ed5be2}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorage-this-orleans-hosting-isilobuilder-string-system-type-syste-e3ed5be2/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs#L164-L170)

```csharp
public static ISiloBuilder AddCosmosGrainStorage(this ISiloBuilder builder, string name, Type customPartitionKeyProviderType, Action<OptionsBuilder<CosmosGrainStorageOptions>>? configureOptions = null)
```

Configure silo to use Azure Cosmos DB storage for grain storage using a custom Partition Key Provider.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.
- `name` (`string`): The storage provider name.
- `customPartitionKeyProviderType` (`Type`)
- `configureOptions` (`Action<OptionsBuilder<CosmosGrainStorageOptions>>`): The delegate used to configure the provider.

## AddCosmosGrainStorage(ISiloBuilder, string, Action&lt;CosmosGrainStorageOptions&gt;) {#addcosmosgrainstorage-1-this-orleans-hosting-isilobuilder-string-system-action-o-42abbec1}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorage-1-this-orleans-hosting-isilobuilder-string-system-action-o-42abbec1/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs)

```csharp
public static ISiloBuilder AddCosmosGrainStorage<TPartitionKeyProvider>(this ISiloBuilder builder, string name, Action<CosmosGrainStorageOptions> configureOptions)
```

Configure silo to use Azure Cosmos DB storage for grain storage using a custom Partition Key Provider.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.
- `name` (`string`): The storage provider name.
- `configureOptions` (`Action<CosmosGrainStorageOptions>`): The delegate used to configure the provider.

## AddCosmosGrainStorage(ISiloBuilder, string, Action&lt;OptionsBuilder&lt;CosmosGrainStorageOptions&gt;&gt;) {#addcosmosgrainstorage-1-this-orleans-hosting-isilobuilder-string-system-action-m-affbcbad}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorage-1-this-orleans-hosting-isilobuilder-string-system-action-m-affbcbad/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs)

```csharp
public static ISiloBuilder AddCosmosGrainStorage<TPartitionKeyProvider>(this ISiloBuilder builder, string name, Action<OptionsBuilder<CosmosGrainStorageOptions>>? configureOptions = null)
```

Configure silo to use Azure Cosmos DB storage for grain storage using a custom Partition Key Provider.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.
- `name` (`string`): The storage provider name.
- `configureOptions` (`Action<OptionsBuilder<CosmosGrainStorageOptions>>`): The delegate used to configure the provider.

## AddCosmosGrainStorageAsDefault(IServiceCollection, Action&lt;CosmosGrainStorageOptions&gt;) {#addcosmosgrainstorageasdefault-this-microsoft-extensions-dependencyinjection-ise-e6d48573}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorageasdefault-this-microsoft-extensions-dependencyinjection-ise-e6d48573/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs)

```csharp
public static IServiceCollection AddCosmosGrainStorageAsDefault(this IServiceCollection services, Action<CosmosGrainStorageOptions> configureOptions)
```

Configure silo to use Azure Cosmos DB storage as the default grain storage.

### Parameters

- `services` (`IServiceCollection`): The service collection.
- `configureOptions` (`Action<CosmosGrainStorageOptions>`): The delegate used to configure the provider.

## AddCosmosGrainStorageAsDefault(IServiceCollection, Action&lt;OptionsBuilder&lt;CosmosGrainStorageOptions&gt;&gt;) {#addcosmosgrainstorageasdefault-this-microsoft-extensions-dependencyinjection-ise-b99f47db}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorageasdefault-this-microsoft-extensions-dependencyinjection-ise-b99f47db/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs)

```csharp
public static IServiceCollection AddCosmosGrainStorageAsDefault(this IServiceCollection services, Action<OptionsBuilder<CosmosGrainStorageOptions>>? configureOptions = null)
```

Configure silo to use Azure Cosmos DB storage as the default grain storage.

### Parameters

- `services` (`IServiceCollection`): The service collection.
- `configureOptions` (`Action<OptionsBuilder<CosmosGrainStorageOptions>>`): The delegate used to configure the provider.

## AddCosmosGrainStorageAsDefault(ISiloBuilder, Action&lt;CosmosGrainStorageOptions&gt;) {#addcosmosgrainstorageasdefault-this-orleans-hosting-isilobuilder-system-action-o-4597b534}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorageasdefault-this-orleans-hosting-isilobuilder-system-action-o-4597b534/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs)

```csharp
public static ISiloBuilder AddCosmosGrainStorageAsDefault(this ISiloBuilder builder, Action<CosmosGrainStorageOptions> configureOptions)
```

Configure silo to use Azure Cosmos DB storage as the default grain storage.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.
- `configureOptions` (`Action<CosmosGrainStorageOptions>`): The delegate used to configure the provider.

## AddCosmosGrainStorageAsDefault(ISiloBuilder, Action&lt;CosmosGrainStorageOptions&gt;, Type) {#addcosmosgrainstorageasdefault-this-orleans-hosting-isilobuilder-system-action-o-c9d37c97}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorageasdefault-this-orleans-hosting-isilobuilder-system-action-o-c9d37c97/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs#L56)

```csharp
public static ISiloBuilder AddCosmosGrainStorageAsDefault(this ISiloBuilder builder, Action<CosmosGrainStorageOptions> configureOptions, Type customPartitionKeyProviderType)
```

Configure silo to use Azure Cosmos DB storage as the default grain storage using a custom Partition Key Provider.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.
- `configureOptions` (`Action<CosmosGrainStorageOptions>`): The delegate used to configure the provider.
- `customPartitionKeyProviderType` (`Type`): The custom partition key provider type.

## AddCosmosGrainStorageAsDefault(ISiloBuilder, Action&lt;OptionsBuilder&lt;CosmosGrainStorageOptions&gt;&gt;) {#addcosmosgrainstorageasdefault-this-orleans-hosting-isilobuilder-system-action-m-29b37b1c}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorageasdefault-this-orleans-hosting-isilobuilder-system-action-m-29b37b1c/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs)

```csharp
public static ISiloBuilder AddCosmosGrainStorageAsDefault(this ISiloBuilder builder, Action<OptionsBuilder<CosmosGrainStorageOptions>>? configureOptions = null)
```

Configure silo to use Azure Cosmos DB storage as the default grain storage.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.
- `configureOptions` (`Action<OptionsBuilder<CosmosGrainStorageOptions>>`): The delegate used to configure the provider.

## AddCosmosGrainStorageAsDefault(ISiloBuilder, Type, Action&lt;OptionsBuilder&lt;CosmosGrainStorageOptions&gt;&gt;) {#addcosmosgrainstorageasdefault-this-orleans-hosting-isilobuilder-system-type-sys-5c41de9b}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorageasdefault-this-orleans-hosting-isilobuilder-system-type-sys-5c41de9b/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs#L149)

```csharp
public static ISiloBuilder AddCosmosGrainStorageAsDefault(this ISiloBuilder builder, Type customPartitionKeyProviderType, Action<OptionsBuilder<CosmosGrainStorageOptions>>? configureOptions = null)
```

Configure silo to use Azure Cosmos DB storage as the default grain storage using a custom Partition Key Provider.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.
- `customPartitionKeyProviderType` (`Type`): The custom partition key provider type.
- `configureOptions` (`Action<OptionsBuilder<CosmosGrainStorageOptions>>`): The delegate used to configure the provider.

## AddCosmosGrainStorageAsDefault(ISiloBuilder, Action&lt;CosmosGrainStorageOptions&gt;) {#addcosmosgrainstorageasdefault-1-this-orleans-hosting-isilobuilder-system-action-7db9a628}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorageasdefault-1-this-orleans-hosting-isilobuilder-system-action-7db9a628/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs)

```csharp
public static ISiloBuilder AddCosmosGrainStorageAsDefault<TPartitionKeyProvider>(this ISiloBuilder builder, Action<CosmosGrainStorageOptions> configureOptions)
```

Configure silo to use Azure Cosmos DB storage as the default grain storage using a custom Partition Key Provider.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.
- `configureOptions` (`Action<CosmosGrainStorageOptions>`): The delegate used to configure the provider.

## AddCosmosGrainStorageAsDefault(ISiloBuilder, Action&lt;OptionsBuilder&lt;CosmosGrainStorageOptions&gt;&gt;) {#addcosmosgrainstorageasdefault-1-this-orleans-hosting-isilobuilder-system-action-bce4db20}

[Dedicated page](/orleans/docs/api/csharp/microsoft.orleans.persistence.cosmos/orleans.hosting.hostingextensions/methods/addcosmosgrainstorageasdefault-1-this-orleans-hosting-isilobuilder-system-action-bce4db20/)

[Source](https://github.com/dotnet/orleans/blob/e4e752cedecc2976811db49802c7a999b1f1c704/src/Azure/Orleans.Persistence.Cosmos/HostingExtensions.cs)

```csharp
public static ISiloBuilder AddCosmosGrainStorageAsDefault<TPartitionKeyProvider>(this ISiloBuilder builder, Action<OptionsBuilder<CosmosGrainStorageOptions>>? configureOptions = null)
```

Configure silo to use Azure Cosmos DB storage as the default grain storage using a custom Partition Key Provider.

### Parameters

- `builder` (`ISiloBuilder`): The silo builder.
- `configureOptions` (`Action<OptionsBuilder<CosmosGrainStorageOptions>>`): The delegate used to configure the provider.
