# AspireQueueStorageExtensions Methods

- Package: [Aspire.Azure.Storage.Queues](/reference/api/csharp/aspire.azure.storage.queues.md)
- Type: [AspireQueueStorageExtensions](/reference/api/csharp/aspire.azure.storage.queues/aspirequeuestorageextensions.md)
- Kind: `Methods`
- Members: `6`

Provides extension methods for registering `Queues.QueueServiceClient` as a singleton in the services provided by the `Hosting.IHostApplicationBuilder`. Enables retries, corresponding health check, logging and telemetry.

## AddAzureQueue(IHostApplicationBuilder, string, Action<AzureStorageQueueSettings>, Action<IAzureClientBuilder<QueueClient, QueueClientOptions>>)

- Name: `AddAzureQueue(IHostApplicationBuilder, string, Action<AzureStorageQueueSettings>, Action<IAzureClientBuilder<QueueClient, QueueClientOptions>>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Components/Aspire.Azure.Storage.Queues/AspireQueueStorageExtensions.cs#L141-L145)

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

```csharp
public static class AspireQueueStorageExtensions
{
    public static void AddAzureQueue(
        this IHostApplicationBuilder builder,
        string connectionName,
        Action<AzureStorageQueueSettings>? configureSettings = null,
        Action<IAzureClientBuilder<QueueClient, QueueClientOptions>>? 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<AzureStorageQueueSettings>`) `optional`
  An optional method that can be used for customizing the [AzureStorageQueueSettings](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuesettings.md). It's invoked after the settings are read from the configuration.
- `configureClientBuilder` (`Action<IAzureClientBuilder<QueueClient, QueueClientOptions>>`) `optional`
  An optional method that can be used for customizing the `Extensions.IAzureClientBuilder`2`.

## Exceptions

- `InvalidOperationException` -- Neither [AzureStorageQueuesSettings.ConnectionString](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings/properties.md#connectionstring) nor [AzureStorageQueuesSettings.ServiceUri](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings/properties.md#serviceuri) is provided. - or - [AzureStorageQueueSettings.QueueName](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuesettings/properties.md#queuename) is not provided in the configuration section.

## Remarks

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

## AddAzureQueueClient(IHostApplicationBuilder, string, Action<AzureStorageQueuesSettings>, Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>)

> **Obsolete:** Use AddAzureQueueServiceClient instead.

- Name: `AddAzureQueueClient(IHostApplicationBuilder, string, Action<AzureStorageQueuesSettings>, Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Components/Aspire.Azure.Storage.Queues/AspireQueueStorageExtensions.cs#L65-L69)

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

```csharp
public static class AspireQueueStorageExtensions
{
    public static void AddAzureQueueClient(
        this IHostApplicationBuilder builder,
        string connectionName,
        Action<AzureStorageQueuesSettings>? configureSettings = null,
        Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>? 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<AzureStorageQueuesSettings>`) `optional`
  An optional method that can be used for customizing the [AzureStorageQueuesSettings](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings.md). It's invoked after the settings are read from the configuration.
- `configureClientBuilder` (`Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>`) `optional`
  An optional method that can be used for customizing the `Extensions.IAzureClientBuilder`2`.

## Exceptions

- `InvalidOperationException` -- Thrown when neither [AzureStorageQueuesSettings.ConnectionString](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings/properties.md#connectionstring) nor [AzureStorageQueuesSettings.ServiceUri](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings/properties.md#serviceuri) is provided.

## Remarks

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

## AddAzureQueueServiceClient(IHostApplicationBuilder, string, Action<AzureStorageQueuesSettings>, Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>)

- Name: `AddAzureQueueServiceClient(IHostApplicationBuilder, string, Action<AzureStorageQueuesSettings>, Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Components/Aspire.Azure.Storage.Queues/AspireQueueStorageExtensions.cs#L42-L46)

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

```csharp
public static class AspireQueueStorageExtensions
{
    public static void AddAzureQueueServiceClient(
        this IHostApplicationBuilder builder,
        string connectionName,
        Action<AzureStorageQueuesSettings>? configureSettings = null,
        Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>? 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<AzureStorageQueuesSettings>`) `optional`
  An optional method that can be used for customizing the [AzureStorageQueuesSettings](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings.md). It's invoked after the settings are read from the configuration.
- `configureClientBuilder` (`Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>`) `optional`
  An optional method that can be used for customizing the `Extensions.IAzureClientBuilder`2`.

## Exceptions

- `InvalidOperationException` -- Thrown when neither [AzureStorageQueuesSettings.ConnectionString](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings/properties.md#connectionstring) nor [AzureStorageQueuesSettings.ServiceUri](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings/properties.md#serviceuri) is provided.

## Remarks

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

## AddKeyedAzureQueue(IHostApplicationBuilder, string, Action<AzureStorageQueueSettings>, Action<IAzureClientBuilder<QueueClient, QueueClientOptions>>)

- Name: `AddKeyedAzureQueue(IHostApplicationBuilder, string, Action<AzureStorageQueueSettings>, Action<IAzureClientBuilder<QueueClient, QueueClientOptions>>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Components/Aspire.Azure.Storage.Queues/AspireQueueStorageExtensions.cs#L175-L179)

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

```csharp
public static class AspireQueueStorageExtensions
{
    public static void AddKeyedAzureQueue(
        this IHostApplicationBuilder builder,
        string name,
        Action<AzureStorageQueueSettings>? configureSettings = null,
        Action<IAzureClientBuilder<QueueClient, QueueClientOptions>>? 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<AzureStorageQueueSettings>`) `optional`
  An optional method that can be used for customizing the [AzureStorageQueueSettings](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuesettings.md). It's invoked after the settings are read from the configuration.
- `configureClientBuilder` (`Action<IAzureClientBuilder<QueueClient, QueueClientOptions>>`) `optional`
  An optional method that can be used for customizing the `Extensions.IAzureClientBuilder`2`.

## Exceptions

- `InvalidOperationException` -- Neither [AzureStorageQueuesSettings.ConnectionString](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings/properties.md#connectionstring) nor [AzureStorageQueuesSettings.ServiceUri](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings/properties.md#serviceuri) is provided. - or - [AzureStorageQueueSettings.QueueName](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuesettings/properties.md#queuename) is not provided in the configuration section.

## Remarks

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

## AddKeyedAzureQueueClient(IHostApplicationBuilder, string, Action<AzureStorageQueuesSettings>, Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>)

> **Obsolete:** Use AddKeyedAzureQueueServiceClient instead.

- Name: `AddKeyedAzureQueueClient(IHostApplicationBuilder, string, Action<AzureStorageQueuesSettings>, Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Components/Aspire.Azure.Storage.Queues/AspireQueueStorageExtensions.cs#L110-L114)

Registers `Queues.QueueServiceClient` 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 AspireQueueStorageExtensions
{
    public static void AddKeyedAzureQueueClient(
        this IHostApplicationBuilder builder,
        string name,
        Action<AzureStorageQueuesSettings>? configureSettings = null,
        Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>? 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<AzureStorageQueuesSettings>`) `optional`
  An optional method that can be used for customizing the [AzureStorageQueuesSettings](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings.md). It's invoked after the settings are read from the configuration.
- `configureClientBuilder` (`Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>`) `optional`
  An optional method that can be used for customizing the `Extensions.IAzureClientBuilder`2`.

## Exceptions

- `InvalidOperationException` -- Thrown when neither [AzureStorageQueuesSettings.ConnectionString](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings/properties.md#connectionstring) nor [AzureStorageQueuesSettings.ServiceUri](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings/properties.md#serviceuri) is provided.

## Remarks

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

## AddKeyedAzureQueueServiceClient(IHostApplicationBuilder, string, Action<AzureStorageQueuesSettings>, Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>)

- Name: `AddKeyedAzureQueueServiceClient(IHostApplicationBuilder, string, Action<AzureStorageQueuesSettings>, Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>)`
- Modifiers: `extension`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/5bd693ae1897dee5e2ce71c2cc08879c1c7eff51/src/Components/Aspire.Azure.Storage.Queues/AspireQueueStorageExtensions.cs#L87-L91)

Registers `Queues.QueueServiceClient` 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 AspireQueueStorageExtensions
{
    public static void AddKeyedAzureQueueServiceClient(
        this IHostApplicationBuilder builder,
        string name,
        Action<AzureStorageQueuesSettings>? configureSettings = null,
        Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>? 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<AzureStorageQueuesSettings>`) `optional`
  An optional method that can be used for customizing the [AzureStorageQueuesSettings](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings.md). It's invoked after the settings are read from the configuration.
- `configureClientBuilder` (`Action<IAzureClientBuilder<QueueServiceClient, QueueClientOptions>>`) `optional`
  An optional method that can be used for customizing the `Extensions.IAzureClientBuilder`2`.

## Exceptions

- `InvalidOperationException` -- Thrown when neither [AzureStorageQueuesSettings.ConnectionString](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings/properties.md#connectionstring) nor [AzureStorageQueuesSettings.ServiceUri](/reference/api/csharp/aspire.azure.storage.queues/azurestoragequeuessettings/properties.md#serviceuri) is provided.

## Remarks

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