# AzureResourceExtensions Methods

- Package: [Aspire.Hosting.Azure](/reference/api/csharp/aspire.hosting.azure.md)
- Type: [AzureResourceExtensions](/reference/api/csharp/aspire.hosting.azure/azureresourceextensions.md)
- Kind: `Methods`
- Members: `3`

Provides extension methods for adding Azure resources to the application model.

## ClearDefaultRoleAssignments(IResourceBuilder<T>)

- Name: `ClearDefaultRoleAssignments(IResourceBuilder<T>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureResourceExtensions.cs#L68-L76)

Clears all default role assignments for the specified Azure resource.

```csharp
public static class AzureResourceExtensions
{
    public static IResourceBuilder<T> ClearDefaultRoleAssignments<T>(
        this IResourceBuilder<T> builder)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.

## Returns

`IResourceBuilder<T>` -- The configured `ApplicationModel.IResourceBuilder`1`.

## Remarks

This method removes all default role assignments from the Azure resource. This can be useful when role assignments can't be created, for example on existing resources where you don't have permission to create the assignments.

## Examples

Clear default role assignments for an Azure Key Vault resource:

```csharp
var builder = DistributedApplication.CreateBuilder(args);

var keyVault = builder.AddAzureKeyVault("keyvault")
    .RunAsExisting("kv-dev-secrets", "rg-keyvault")
    .ClearDefaultRoleAssignments();

var api = builder.AddProject<Projects.Api>("api")
    .WithReference(keyVault);
```

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## GetBicepIdentifier(IAzureResource)

- Name: `GetBicepIdentifier(IAzureResource)`
- Modifiers: `extension`
- Returns: `string`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureResourceExtensions.cs#L37)

Gets the Bicep identifier for the Azure resource.

```csharp
public static class AzureResourceExtensions
{
    public static string GetBicepIdentifier(
        this IAzureResource resource)
    {
        // ...
    }
}
```

## Parameters

- `resource` ([IAzureResource](/reference/api/csharp/aspire.hosting.azure/iazureresource.md))
  The Azure resource.

## Returns

`string` -- A valid Bicep identifier.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## PublishAsConnectionString(IResourceBuilder<T>)

- Name: `PublishAsConnectionString(IResourceBuilder<T>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure/AzureResourceExtensions.cs#L26-L27)

Changes the resource to be published as a connection string reference in the manifest.

```csharp
public static class AzureResourceExtensions
{
    public static IResourceBuilder<T> PublishAsConnectionString<T>(
        this IResourceBuilder<T> builder)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource builder.

## Returns

`IResourceBuilder<T>` -- The configured `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
