# AzureAppConfigurationExtensions Methods

- Package: [Aspire.Hosting.Azure.AppConfiguration](/reference/api/csharp/aspire.hosting.azure.appconfiguration.md)
- Type: [AzureAppConfigurationExtensions](/reference/api/csharp/aspire.hosting.azure.appconfiguration/azureappconfigurationextensions.md)
- Kind: `Methods`
- Members: `6`

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

## AddAzureAppConfiguration(IDistributedApplicationBuilder, string)

- Name: `AddAzureAppConfiguration(IDistributedApplicationBuilder, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureAppConfigurationResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.AppConfiguration/AzureAppConfigurationExtensions.cs#L37-L86)

Adds an Azure App Configuration resource to the application model.

```csharp
public static class AzureAppConfigurationExtensions
{
    public static IResourceBuilder<AzureAppConfigurationResource> AddAzureAppConfiguration(
        this IDistributedApplicationBuilder builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The `Hosting.IDistributedApplicationBuilder`.
- `name` (`string`)
  The name of the resource. This name will be used as the connection string name when referenced in a dependency.

## Returns

`IResourceBuilder<AzureAppConfigurationResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

By default references to the Azure App Configuration resource will be assigned the following roles: - `AppConfigurationBuiltInRole.AppConfigurationDataOwner` These can be replaced by calling [AzureAppConfigurationExtensions.WithRoleAssignments(IResourceBuilder<T>, IResourceBuilder<AzureAppConfigurationResource>, AppConfigurationBuiltInRole[])](/reference/api/csharp/aspire.hosting.azure.appconfiguration/azureappconfigurationextensions/methods.md#withroleassignments-iresourcebuilder-t-iresourcebuilder-azureappconfigurationresource-appconfigurationbuiltinrole).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## RunAsEmulator(IResourceBuilder<AzureAppConfigurationResource>, Action<IResourceBuilder<AzureAppConfigurationEmulatorResource>>)

- Name: `RunAsEmulator(IResourceBuilder<AzureAppConfigurationResource>, Action<IResourceBuilder<AzureAppConfigurationEmulatorResource>>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureAppConfigurationResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.AppConfiguration/AzureAppConfigurationExtensions.cs#L103-L125)

Configures an Azure App Configuration resource to be emulated. This resource requires an [AzureAppConfigurationResource](/reference/api/csharp/aspire.hosting.azure.appconfiguration/azureappconfigurationresource.md) to be added to the application model.

```csharp
public static class AzureAppConfigurationExtensions
{
    public static IResourceBuilder<AzureAppConfigurationResource> RunAsEmulator(
        this IResourceBuilder<AzureAppConfigurationResource> builder,
        Action<IResourceBuilder<AzureAppConfigurationEmulatorResource>>? configureEmulator = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureAppConfigurationResource>`)
  The Azure App Configuration resource builder.
- `configureEmulator` (`Action<IResourceBuilder<AzureAppConfigurationEmulatorResource>>`) `optional`
  Callback that exposes underlying container used for emulation to allow for customization.

## Returns

`IResourceBuilder<AzureAppConfigurationResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## Remarks

This version of the package defaults to the tag of the / container image.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithDataBindMount(IResourceBuilder<AzureAppConfigurationEmulatorResource>, string?)

- Name: `WithDataBindMount(IResourceBuilder<AzureAppConfigurationEmulatorResource>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureAppConfigurationEmulatorResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.AppConfiguration/AzureAppConfigurationExtensions.cs#L137-L139)

Adds a bind mount for the storage of an Azure App Configuration emulator resource.

```csharp
public static class AzureAppConfigurationExtensions
{
    public static IResourceBuilder<AzureAppConfigurationEmulatorResource> WithDataBindMount(
        this IResourceBuilder<AzureAppConfigurationEmulatorResource> builder,
        string? path = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureAppConfigurationEmulatorResource>`)
  The builder for the [AzureAppConfigurationEmulatorResource](/reference/api/csharp/aspire.hosting.azure.appconfiguration/azureappconfigurationemulatorresource.md).
- `path` (`string?`) `optional`
  Relative path to the AppHost where emulator storage is persisted between runs. Defaults to the path '.aace'

## Returns

`IResourceBuilder<AzureAppConfigurationEmulatorResource>` -- A builder for the [AzureAppConfigurationEmulatorResource](/reference/api/csharp/aspire.hosting.azure.appconfiguration/azureappconfigurationemulatorresource.md).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithDataVolume(IResourceBuilder<AzureAppConfigurationEmulatorResource>, string?)

- Name: `WithDataVolume(IResourceBuilder<AzureAppConfigurationEmulatorResource>, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureAppConfigurationEmulatorResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.AppConfiguration/AzureAppConfigurationExtensions.cs#L151-L153)

Adds a named volume for the data folder to an Azure App Configuration emulator resource.

```csharp
public static class AzureAppConfigurationExtensions
{
    public static IResourceBuilder<AzureAppConfigurationEmulatorResource> WithDataVolume(
        this IResourceBuilder<AzureAppConfigurationEmulatorResource> builder,
        string? name = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureAppConfigurationEmulatorResource>`)
  The builder for the [AzureAppConfigurationEmulatorResource](/reference/api/csharp/aspire.hosting.azure.appconfiguration/azureappconfigurationemulatorresource.md).
- `name` (`string?`) `optional`
  The name of the volume. Defaults to an auto-generated name based on the application and resource names.

## Returns

`IResourceBuilder<AzureAppConfigurationEmulatorResource>` -- A builder for the [AzureAppConfigurationEmulatorResource](/reference/api/csharp/aspire.hosting.azure.appconfiguration/azureappconfigurationemulatorresource.md).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithHostPort(IResourceBuilder<AzureAppConfigurationEmulatorResource>, int?)

- Name: `WithHostPort(IResourceBuilder<AzureAppConfigurationEmulatorResource>, int?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureAppConfigurationEmulatorResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.AppConfiguration/AzureAppConfigurationExtensions.cs#L166-L171)

Configures the host port for the Azure App Configuration emulator is exposed on instead of using randomly assigned port.

```csharp
public static class AzureAppConfigurationExtensions
{
    public static IResourceBuilder<AzureAppConfigurationEmulatorResource> WithHostPort(
        this IResourceBuilder<AzureAppConfigurationEmulatorResource> builder,
        int? port)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureAppConfigurationEmulatorResource>`)
  Builder for the Azure App Configuration emulator container
- `port` (`int?`)
  The port to bind on the host. If `null` is used, a random port will be assigned.

## Returns

`IResourceBuilder<AzureAppConfigurationEmulatorResource>` -- A reference to the `ApplicationModel.IResourceBuilder`1`.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithRoleAssignments(IResourceBuilder<T>, IResourceBuilder<AzureAppConfigurationResource>, AppConfigurationBuiltInRole[])

- Name: `WithRoleAssignments(IResourceBuilder<T>, IResourceBuilder<AzureAppConfigurationResource>, AppConfigurationBuiltInRole[])`
- Modifiers: `extension`
- Returns: `IResourceBuilder<T>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.AppConfiguration/AzureAppConfigurationExtensions.cs)

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

```csharp
public static class AzureAppConfigurationExtensions
{
    public static IResourceBuilder<T> WithRoleAssignments<T>(
        this IResourceBuilder<T> builder,
        IResourceBuilder<AzureAppConfigurationResource> target,
        params AppConfigurationBuiltInRole[] roles)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource to which the specified roles will be assigned.
- `target` (`IResourceBuilder<AzureAppConfigurationResource>`)
  The target Azure App Configuration resource.
- `roles` (`AppConfigurationBuiltInRole[]`)
  The built-in App Configuration roles to be assigned.

## Returns

`IResourceBuilder<T>` -- The updated `ApplicationModel.IResourceBuilder`1` with the applied role assignments.

## Remarks

This overload is not available in polyglot app hosts. Use [AzureAppConfigurationExtensions.WithRoleAssignments(IResourceBuilder<T>, IResourceBuilder<AzureAppConfigurationResource>, AppConfigurationBuiltInRole[])](/reference/api/csharp/aspire.hosting.azure.appconfiguration/azureappconfigurationextensions/methods.md#withroleassignments-iresourcebuilder-t-iresourcebuilder-azureappconfigurationresource-appconfigurationbuiltinrole) instead. Assigns the AppConfigurationDataReader role to the 'Projects.Api' project.

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

var appStore = builder.AddAzureAppConfiguration("appStore");

var api = builder.AddProject<Projects.Api>("api")
  .WithRoleAssignments(appStore, AppConfigurationBuiltInRole.AppConfigurationDataReader)
  .WithReference(appStore);
```

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.
