# Cloud Run Admin v2 API - Class ServiceCollectionExtensions (2.19.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [2.19.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.18.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.18.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.17.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.17.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.16.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.16.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.15.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.15.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.14.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.14.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.13.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.13.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.12.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.12.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.11.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.11.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.10.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.10.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.9.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.9.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.8.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.8.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.7.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.7.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.6.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.6.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.5.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.5.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.4.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.4.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.3.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.3.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.2.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.2.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.1.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.1.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [2.0.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/2.0.0/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)
- [1.0.0-beta02](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/1.0.0-beta02/Microsoft.Extensions.DependencyInjection.ServiceCollectionExtensions)

    public static class ServiceCollectionExtensions

Reference documentation and code samples for the Cloud Run Admin v2 API class ServiceCollectionExtensions.

Static class to provide extension methods to configure API clients.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> ServiceCollectionExtensions

## Inherited Members

[object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Microsoft.Extensions.DependencyInjection](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Microsoft.Extensions.DependencyInjection)

## Assembly

Google.Cloud.Run.V2.dll

## Methods

### AddBuildsClient(IServiceCollection, Action\<BuildsClientBuilder\>)

    public static IServiceCollection AddBuildsClient(this IServiceCollection services, Action<BuildsClientBuilder> action = null)

Adds a singleton [BuildsClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.BuildsClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.BuildsClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddBuildsClient(IServiceCollection, Action\<IServiceProvider, BuildsClientBuilder\>)

    public static IServiceCollection AddBuildsClient(this IServiceCollection services, Action<IServiceProvider, BuildsClientBuilder> action)

Adds a singleton [BuildsClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.BuildsClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-2System.IServiceProviderhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.BuildsClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddExecutionsClient(IServiceCollection, Action\<ExecutionsClientBuilder\>)

    public static IServiceCollection AddExecutionsClient(this IServiceCollection services, Action<ExecutionsClientBuilder> action = null)

Adds a singleton [ExecutionsClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.ExecutionsClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.ExecutionsClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddExecutionsClient(IServiceCollection, Action\<IServiceProvider, ExecutionsClientBuilder\>)

    public static IServiceCollection AddExecutionsClient(this IServiceCollection services, Action<IServiceProvider, ExecutionsClientBuilder> action)

Adds a singleton [ExecutionsClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.ExecutionsClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-2System.IServiceProviderhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.ExecutionsClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddInstancesClient(IServiceCollection, Action\<InstancesClientBuilder\>)

    public static IServiceCollection AddInstancesClient(this IServiceCollection services, Action<InstancesClientBuilder> action = null)

Adds a singleton [InstancesClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.InstancesClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.InstancesClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddInstancesClient(IServiceCollection, Action\<IServiceProvider, InstancesClientBuilder\>)

    public static IServiceCollection AddInstancesClient(this IServiceCollection services, Action<IServiceProvider, InstancesClientBuilder> action)

Adds a singleton [InstancesClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.InstancesClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-2System.IServiceProviderhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.InstancesClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddJobsClient(IServiceCollection, Action\<JobsClientBuilder\>)

    public static IServiceCollection AddJobsClient(this IServiceCollection services, Action<JobsClientBuilder> action = null)

Adds a singleton [JobsClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.JobsClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.JobsClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddJobsClient(IServiceCollection, Action\<IServiceProvider, JobsClientBuilder\>)

    public static IServiceCollection AddJobsClient(this IServiceCollection services, Action<IServiceProvider, JobsClientBuilder> action)

Adds a singleton [JobsClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.JobsClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-2System.IServiceProviderhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.JobsClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddRevisionsClient(IServiceCollection, Action\<RevisionsClientBuilder\>)

    public static IServiceCollection AddRevisionsClient(this IServiceCollection services, Action<RevisionsClientBuilder> action = null)

Adds a singleton [RevisionsClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.RevisionsClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.RevisionsClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddRevisionsClient(IServiceCollection, Action\<IServiceProvider, RevisionsClientBuilder\>)

    public static IServiceCollection AddRevisionsClient(this IServiceCollection services, Action<IServiceProvider, RevisionsClientBuilder> action)

Adds a singleton [RevisionsClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.RevisionsClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-2System.IServiceProviderhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.RevisionsClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddServicesClient(IServiceCollection, Action\<ServicesClientBuilder\>)

    public static IServiceCollection AddServicesClient(this IServiceCollection services, Action<ServicesClientBuilder> action = null)

Adds a singleton [ServicesClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.ServicesClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.ServicesClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddServicesClient(IServiceCollection, Action\<IServiceProvider, ServicesClientBuilder\>)

    public static IServiceCollection AddServicesClient(this IServiceCollection services, Action<IServiceProvider, ServicesClientBuilder> action)

Adds a singleton [ServicesClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.ServicesClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-2System.IServiceProviderhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.ServicesClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddTasksClient(IServiceCollection, Action\<TasksClientBuilder\>)

    public static IServiceCollection AddTasksClient(this IServiceCollection services, Action<TasksClientBuilder> action = null)

Adds a singleton [TasksClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.TasksClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.TasksClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddTasksClient(IServiceCollection, Action\<IServiceProvider, TasksClientBuilder\>)

    public static IServiceCollection AddTasksClient(this IServiceCollection services, Action<IServiceProvider, TasksClientBuilder> action)

Adds a singleton [TasksClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.TasksClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-2System.IServiceProviderhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.TasksClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddWorkerPoolsClient(IServiceCollection, Action\<WorkerPoolsClientBuilder\>)

    public static IServiceCollection AddWorkerPoolsClient(this IServiceCollection services, Action<WorkerPoolsClientBuilder> action = null)

Adds a singleton [WorkerPoolsClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.WorkerPoolsClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-1https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.WorkerPoolsClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |

### AddWorkerPoolsClient(IServiceCollection, Action\<IServiceProvider, WorkerPoolsClientBuilder\>)

    public static IServiceCollection AddWorkerPoolsClient(this IServiceCollection services, Action<IServiceProvider, WorkerPoolsClientBuilder> action)

Adds a singleton [WorkerPoolsClient](https://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.WorkerPoolsClient) to `services`.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `services` | `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` The service collection to add the client to. The services are used to configure the client when requested. |
| `action` | `https://learn.microsoft.com/dotnet/api/system.action-2System.IServiceProviderhttps://docs.cloud.google.com/dotnet/docs/reference/Google.Cloud.Run.V2/latest/Google.Cloud.Run.V2.WorkerPoolsClientBuilder` An optional action to invoke on the client builder. This is invoked before services from `services` are used. |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/microsoft.extensions.dependencyinjection.iservicecollection` |   |