# WithSearchRoleAssignments

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

Assigns the specified roles to the given resource, granting it the necessary permissions on the target Azure AI Search service resource. This replaces the default role assignments for the resource.

## Definition

```go
func (Resource) WithSearchRoleAssignments(
    target AzureSearchResource,
    roles []AzureSearchRole,
) Resource
```

## Parameters

- `target` ([`AzureSearchResource`](/reference/api/go/aspire.hosting.azure.search/azuresearchresource.md)) -- The target Azure AI Search service resource.
- `roles` ([`[]AzureSearchRole`](/reference/api/go/aspire.hosting.azure.search/azuresearchrole.md)) -- The Azure AI Search 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.search/azurebicepresource.md)
- [`AzureEnvironmentResource`](/reference/api/go/aspire.hosting.azure.search/azureenvironmentresource.md)
- [`AzureProvisioningResource`](/reference/api/go/aspire.hosting.azure.search/azureprovisioningresource.md)
- [`AzureSearchResource`](/reference/api/go/aspire.hosting.azure.search/azuresearchresource.md)
- [`AzureUserAssignedIdentityResource`](/reference/api/go/aspire.hosting.azure.search/azureuserassignedidentityresource.md)
- `CSharpAppResource`
- `ContainerRegistryResource`
- `ContainerResource`
- `DotnetToolResource`
- `ExecutableResource`
- `ExternalServiceResource`
- `ParameterResource`
- `ProjectResource`
