# WithEventHubsRoleAssignments

- Module: [Aspire.Hosting.Azure.EventHubs](/reference/api/go/aspire.hosting.azure.eventhubs.md)
- Version: `17.0.0`
- Kind: `method`
- Defined on: `Resource`
- Source: [GitHub](https://github.com/microsoft/aspire/tree/bcfa151cdca6d0a573f22d5d9c23f9c727cb3b2f)

Assigns the specified roles to the given resource, granting it the necessary permissions on the target Azure Event Hubs Namespace resource. This replaces the default role assignments for the resource.

## Definition

```go
func (Resource) WithEventHubsRoleAssignments(
    target AzureEventHubsResource,
    roles []AzureEventHubsRole,
) Resource
```

## Parameters

- `target` ([`AzureEventHubsResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azureeventhubsresource.md)) -- The target Azure Event Hubs Namespace resource.
- `roles` ([`[]AzureEventHubsRole`](/reference/api/go/aspire.hosting.azure.eventhubs/azureeventhubsrole.md)) -- The Event Hubs roles to be assigned.

## Returns

`Resource` -- The resource builder.

Returns a handle; failures surface later via `Err()`.

## Applies to

- [`AzureBicepResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azurebicepresource.md)
- [`AzureBlobStorageContainerResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azureblobstoragecontainerresource.md)
- [`AzureBlobStorageResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azureblobstorageresource.md)
- [`AzureDataLakeStorageFileSystemResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azuredatalakestoragefilesystemresource.md)
- [`AzureDataLakeStorageResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azuredatalakestorageresource.md)
- [`AzureEnvironmentResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azureenvironmentresource.md)
- [`AzureEventHubConsumerGroupResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azureeventhubconsumergroupresource.md)
- [`AzureEventHubResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azureeventhubresource.md)
- [`AzureEventHubsEmulatorResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azureeventhubsemulatorresource.md)
- [`AzureEventHubsResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azureeventhubsresource.md)
- [`AzureProvisioningResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azureprovisioningresource.md)
- [`AzureQueueStorageQueueResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azurequeuestoragequeueresource.md)
- [`AzureQueueStorageResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azurequeuestorageresource.md)
- [`AzureStorageEmulatorResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azurestorageemulatorresource.md)
- [`AzureStorageResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azurestorageresource.md)
- [`AzureTableStorageResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azuretablestorageresource.md)
- [`AzureUserAssignedIdentityResource`](/reference/api/go/aspire.hosting.azure.eventhubs/azureuserassignedidentityresource.md)
- `CSharpAppResource`
- `ContainerRegistryResource`
- `ContainerResource`
- `DotnetToolResource`
- `ExecutableResource`
- `ExternalServiceResource`
- `ParameterResource`
- `ProjectResource`
