# AspireBlobStorageExtensions Methods

- Package: [Aspire.Azure.Storage.Blobs](/reference/api/csharp/aspire.azure.storage.blobs.md)
- Type: [AspireBlobStorageExtensions](/reference/api/csharp/aspire.azure.storage.blobs/aspireblobstorageextensions.md)
- Kind: `Methods`
- Members: `6`

Provides extension methods for registering `Blobs.BlobServiceClient` as a singleton in the services provided by the `Hosting.IHostApplicationBuilder`.

## AddAzureBlobClient(IHostApplicationBuilder, string, Action<AzureStorageBlobsSettings>, Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>)

> **Obsolete:** Use AddAzureBlobServiceClient instead. This method will be removed in a future version.

- Name: `AddAzureBlobClient(IHostApplicationBuilder, string, Action<AzureStorageBlobsSettings>, Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Components/Aspire.Azure.Storage.Blobs/AspireBlobStorageExtensions.cs#L56-L60)

Registers `Blobs.BlobServiceClient` as a singleton in the services provided by the `builder`. Enables retries, corresponding health check, logging and telemetry.

```csharp
public static class AspireBlobStorageExtensions
{
    public static void AddAzureBlobClient(
        this IHostApplicationBuilder builder,
        string connectionName,
        Action<AzureStorageBlobsSettings>? configureSettings = null,
        Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>? configureClientBuilder = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IHostApplicationBuilder`)
  The `Hosting.IHostApplicationBuilder` to read config from and add services to.
- `connectionName` (`string`)
  A name used to retrieve the connection string from the ConnectionStrings configuration section.
- `configureSettings` (`Action<AzureStorageBlobsSettings>`) `optional`
  An optional method that can be used for customizing the [AzureStorageBlobsSettings](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings.md). It's invoked after the settings are read from the configuration.
- `configureClientBuilder` (`Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>`) `optional`
  An optional method that can be used for customizing the `Extensions.IAzureClientBuilder`2`.

## Exceptions

- `InvalidOperationException` -- Neither [AzureStorageBlobsSettings.ConnectionString](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings/properties.md#connectionstring) nor [AzureStorageBlobsSettings.ServiceUri](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings/properties.md#serviceuri) is provided.

## Remarks

Reads the configuration from "Aspire:Azure:Storage:Blobs" section.

## AddAzureBlobContainerClient(IHostApplicationBuilder, string, Action<AzureBlobStorageContainerSettings>, Action<IAzureClientBuilder<BlobContainerClient, BlobClientOptions>>)

- Name: `AddAzureBlobContainerClient(IHostApplicationBuilder, string, Action<AzureBlobStorageContainerSettings>, Action<IAzureClientBuilder<BlobContainerClient, BlobClientOptions>>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Components/Aspire.Azure.Storage.Blobs/AspireBlobStorageExtensions.cs#L133-L137)

Registers `Blobs.BlobContainerClient` as a singleton in the services provided by the `builder`. Enables retries, corresponding health check, logging and telemetry.

```csharp
public static class AspireBlobStorageExtensions
{
    public static void AddAzureBlobContainerClient(
        this IHostApplicationBuilder builder,
        string connectionName,
        Action<AzureBlobStorageContainerSettings>? configureSettings = null,
        Action<IAzureClientBuilder<BlobContainerClient, BlobClientOptions>>? configureClientBuilder = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IHostApplicationBuilder`)
  The `Hosting.IHostApplicationBuilder` to read config from and add services to.
- `connectionName` (`string`)
  A name used to retrieve the connection string from the ConnectionStrings configuration section.
- `configureSettings` (`Action<AzureBlobStorageContainerSettings>`) `optional`
  An optional method that can be used for customizing the [AzureStorageBlobsSettings](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings.md). It's invoked after the settings are read from the configuration.
- `configureClientBuilder` (`Action<IAzureClientBuilder<BlobContainerClient, BlobClientOptions>>`) `optional`
  An optional method that can be used for customizing the `Extensions.IAzureClientBuilder`2`.

## Exceptions

- `InvalidOperationException` -- Neither [AzureStorageBlobsSettings.ConnectionString](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings/properties.md#connectionstring) nor [AzureStorageBlobsSettings.ServiceUri](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings/properties.md#serviceuri) is provided. - or - [AzureBlobStorageContainerSettings.BlobContainerName](/reference/api/csharp/aspire.azure.storage.blobs/azureblobstoragecontainersettings/properties.md#blobcontainername) is not provided in the configuration section.

## Remarks

Reads the configuration from "Aspire:Azure:Storage:Blobs" section.

## AddAzureBlobServiceClient(IHostApplicationBuilder, string, Action<AzureStorageBlobsSettings>, Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>)

- Name: `AddAzureBlobServiceClient(IHostApplicationBuilder, string, Action<AzureStorageBlobsSettings>, Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Components/Aspire.Azure.Storage.Blobs/AspireBlobStorageExtensions.cs#L42-L46)

Registers `Blobs.BlobServiceClient` as a singleton in the services provided by the `builder`. Enables retries, corresponding health check, logging and telemetry.

```csharp
public static class AspireBlobStorageExtensions
{
    public static void AddAzureBlobServiceClient(
        this IHostApplicationBuilder builder,
        string connectionName,
        Action<AzureStorageBlobsSettings>? configureSettings = null,
        Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>? configureClientBuilder = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IHostApplicationBuilder`)
  The `Hosting.IHostApplicationBuilder` to read config from and add services to.
- `connectionName` (`string`)
  A name used to retrieve the connection string from the ConnectionStrings configuration section.
- `configureSettings` (`Action<AzureStorageBlobsSettings>`) `optional`
  An optional method that can be used for customizing the [AzureStorageBlobsSettings](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings.md). It's invoked after the settings are read from the configuration.
- `configureClientBuilder` (`Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>`) `optional`
  An optional method that can be used for customizing the `Extensions.IAzureClientBuilder`2`.

## Exceptions

- `InvalidOperationException` -- Neither [AzureStorageBlobsSettings.ConnectionString](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings/properties.md#connectionstring) nor [AzureStorageBlobsSettings.ServiceUri](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings/properties.md#serviceuri) is provided.

## Remarks

Reads the configuration from "Aspire:Azure:Storage:Blobs" section.

## AddKeyedAzureBlobClient(IHostApplicationBuilder, string, Action<AzureStorageBlobsSettings>, Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>)

> **Obsolete:** Use AddKeyedAzureBlobServiceClient instead. This method will be removed in a future version.

- Name: `AddKeyedAzureBlobClient(IHostApplicationBuilder, string, Action<AzureStorageBlobsSettings>, Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Components/Aspire.Azure.Storage.Blobs/AspireBlobStorageExtensions.cs#L102-L106)

Registers `Blobs.BlobServiceClient` as a singleton for given `name` in the services provided by the `builder`. Enables retries, corresponding health check, logging and telemetry.

```csharp
public static class AspireBlobStorageExtensions
{
    public static void AddKeyedAzureBlobClient(
        this IHostApplicationBuilder builder,
        string name,
        Action<AzureStorageBlobsSettings>? configureSettings = null,
        Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>? configureClientBuilder = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IHostApplicationBuilder`)
  The `Hosting.IHostApplicationBuilder` to read config from and add services to.
- `name` (`string`)
  The name of the component, which is used as the `ServiceDescriptor.ServiceKey` of the service and also to retrieve the connection string from the ConnectionStrings configuration section.
- `configureSettings` (`Action<AzureStorageBlobsSettings>`) `optional`
  An optional method that can be used for customizing the [AzureStorageBlobsSettings](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings.md). It's invoked after the settings are read from the configuration.
- `configureClientBuilder` (`Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>`) `optional`
  An optional method that can be used for customizing the `Extensions.IAzureClientBuilder`2`.

## Exceptions

- `InvalidOperationException` -- Neither [AzureStorageBlobsSettings.ConnectionString](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings/properties.md#connectionstring) nor [AzureStorageBlobsSettings.ServiceUri](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings/properties.md#serviceuri) is provided.

## Remarks

Reads the configuration from "Aspire:Azure:Storage:Blobs:{name}" section.

## AddKeyedAzureBlobContainerClient(IHostApplicationBuilder, string, Action<AzureBlobStorageContainerSettings>, Action<IAzureClientBuilder<BlobContainerClient, BlobClientOptions>>)

- Name: `AddKeyedAzureBlobContainerClient(IHostApplicationBuilder, string, Action<AzureBlobStorageContainerSettings>, Action<IAzureClientBuilder<BlobContainerClient, BlobClientOptions>>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Components/Aspire.Azure.Storage.Blobs/AspireBlobStorageExtensions.cs#L167-L171)

Registers `Blobs.BlobContainerClient` as a singleton in the services provided by the `builder`. Enables retries, corresponding health check, logging and telemetry.

```csharp
public static class AspireBlobStorageExtensions
{
    public static void AddKeyedAzureBlobContainerClient(
        this IHostApplicationBuilder builder,
        string name,
        Action<AzureBlobStorageContainerSettings>? configureSettings = null,
        Action<IAzureClientBuilder<BlobContainerClient, BlobClientOptions>>? configureClientBuilder = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IHostApplicationBuilder`)
  The `Hosting.IHostApplicationBuilder` to read config from and add services to.
- `name` (`string`)
  The name of the component, which is used as the `ServiceDescriptor.ServiceKey` of the service and also to retrieve the connection string from the ConnectionStrings configuration section.
- `configureSettings` (`Action<AzureBlobStorageContainerSettings>`) `optional`
  An optional method that can be used for customizing the [AzureStorageBlobsSettings](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings.md). It's invoked after the settings are read from the configuration.
- `configureClientBuilder` (`Action<IAzureClientBuilder<BlobContainerClient, BlobClientOptions>>`) `optional`
  An optional method that can be used for customizing the `Extensions.IAzureClientBuilder`2`.

## Exceptions

- `InvalidOperationException` -- Neither [AzureStorageBlobsSettings.ConnectionString](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings/properties.md#connectionstring) nor [AzureStorageBlobsSettings.ServiceUri](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings/properties.md#serviceuri) is provided. - or - [AzureBlobStorageContainerSettings.BlobContainerName](/reference/api/csharp/aspire.azure.storage.blobs/azureblobstoragecontainersettings/properties.md#blobcontainername) is not provided in the configuration section.

## Remarks

Reads the configuration from "Aspire:Azure:Storage:Blobs:{name}" section.

## AddKeyedAzureBlobServiceClient(IHostApplicationBuilder, string, Action<AzureStorageBlobsSettings>, Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>)

- Name: `AddKeyedAzureBlobServiceClient(IHostApplicationBuilder, string, Action<AzureStorageBlobsSettings>, Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Components/Aspire.Azure.Storage.Blobs/AspireBlobStorageExtensions.cs#L88-L92)

Registers `Blobs.BlobServiceClient` as a singleton for given `name` in the services provided by the `builder`. Enables retries, corresponding health check, logging and telemetry.

```csharp
public static class AspireBlobStorageExtensions
{
    public static void AddKeyedAzureBlobServiceClient(
        this IHostApplicationBuilder builder,
        string name,
        Action<AzureStorageBlobsSettings>? configureSettings = null,
        Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>? configureClientBuilder = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IHostApplicationBuilder`)
  The `Hosting.IHostApplicationBuilder` to read config from and add services to.
- `name` (`string`)
  The name of the component, which is used as the `ServiceDescriptor.ServiceKey` of the service and also to retrieve the connection string from the ConnectionStrings configuration section.
- `configureSettings` (`Action<AzureStorageBlobsSettings>`) `optional`
  An optional method that can be used for customizing the [AzureStorageBlobsSettings](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings.md). It's invoked after the settings are read from the configuration.
- `configureClientBuilder` (`Action<IAzureClientBuilder<BlobServiceClient, BlobClientOptions>>`) `optional`
  An optional method that can be used for customizing the `Extensions.IAzureClientBuilder`2`.

## Exceptions

- `InvalidOperationException` -- Neither [AzureStorageBlobsSettings.ConnectionString](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings/properties.md#connectionstring) nor [AzureStorageBlobsSettings.ServiceUri](/reference/api/csharp/aspire.azure.storage.blobs/azurestorageblobssettings/properties.md#serviceuri) is provided.

## Remarks

Reads the configuration from "Aspire:Azure:Storage:Blobs:{name}" section.
