# AzureStorageExtensions Methods

- Package: [Aspire.Hosting.Azure.Storage](/reference/api/csharp/aspire.hosting.azure.storage.md)
- Type: [AzureStorageExtensions](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageextensions.md)
- Kind: `Methods`
- Members: `17`

Extension methods for adding Azure Storage resources to an application model.

## AddAzureStorage(IDistributedApplicationBuilder, string)

- Name: `AddAzureStorage(IDistributedApplicationBuilder, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureStorageResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs#L43-L166)

Adds an Azure Storage resource to the application model. This resource can be used to create Azure blob, table, and queue resources.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureStorageResource> AddAzureStorage(
        this IDistributedApplicationBuilder builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IDistributedApplicationBuilder`)
  The builder for the distributed application.
- `name` (`string`)
  The name of the resource.

## Remarks

By default references to the Azure Storage resource will be assigned the following roles: - `StorageBuiltInRole.StorageBlobDataContributor` - `StorageBuiltInRole.StorageTableDataContributor` - `StorageBuiltInRole.StorageQueueDataContributor` These can be replaced by calling [AzureStorageExtensions.WithRoleAssignments(IResourceBuilder<T>, IResourceBuilder<AzureStorageResource>, StorageBuiltInRole[])](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageextensions/methods.md#withroleassignments-iresourcebuilder-t-iresourcebuilder-azurestorageresource-storagebuiltinrole).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## AddBlobContainer(IResourceBuilder<AzureStorageResource>, string, string?)

- Name: `AddBlobContainer(IResourceBuilder<AzureStorageResource>, string, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureBlobStorageContainerResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs)

Creates a builder for the [AzureBlobStorageContainerResource](/reference/api/csharp/aspire.hosting.azure.storage/azureblobstoragecontainerresource.md) which can be referenced to get the Azure Storage blob container endpoint for the storage account.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureBlobStorageContainerResource> AddBlobContainer(
        this IResourceBuilder<AzureStorageResource> builder,
        string name,
        string? blobContainerName = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureStorageResource>`)
  The `ApplicationModel.IResourceBuilder`1` for [AzureStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageresource.md).
- `name` (`string`)
  The name of the resource.
- `blobContainerName` (`string?`) `optional`
  The name of the blob container.

## Returns

`IResourceBuilder<AzureBlobStorageContainerResource>` -- An `ApplicationModel.IResourceBuilder`1` for the [AzureBlobStorageContainerResource](/reference/api/csharp/aspire.hosting.azure.storage/azureblobstoragecontainerresource.md).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## AddBlobContainer(IResourceBuilder<AzureBlobStorageResource>, string, string?)

> **Obsolete:** Use AddBlobContainer on IResourceBuilder<AzureStorageResource> instead.

- Name: `AddBlobContainer(IResourceBuilder<AzureBlobStorageResource>, string, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureBlobStorageContainerResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs)

Creates a builder for the [AzureBlobStorageContainerResource](/reference/api/csharp/aspire.hosting.azure.storage/azureblobstoragecontainerresource.md) which can be referenced to get the Azure Storage blob container endpoint for the storage account.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureBlobStorageContainerResource> AddBlobContainer(
        this IResourceBuilder<AzureBlobStorageResource> builder,
        string name,
        string? blobContainerName = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureBlobStorageResource>`)
  The `ApplicationModel.IResourceBuilder`1` for [AzureBlobStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azureblobstorageresource.md).
- `name` (`string`)
  The name of the resource.
- `blobContainerName` (`string?`) `optional`
  The name of the blob container.

## Returns

`IResourceBuilder<AzureBlobStorageContainerResource>` -- An `ApplicationModel.IResourceBuilder`1` for the [AzureBlobStorageContainerResource](/reference/api/csharp/aspire.hosting.azure.storage/azureblobstoragecontainerresource.md).

## AddBlobs(IResourceBuilder<AzureStorageResource>, string)

- Name: `AddBlobs(IResourceBuilder<AzureStorageResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureBlobStorageResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs#L387-L397)

Creates a builder for the [AzureBlobStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azureblobstorageresource.md) which can be referenced to get the Azure Storage blob endpoint for the storage account.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureBlobStorageResource> AddBlobs(
        this IResourceBuilder<AzureStorageResource> builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureStorageResource>`)
  The `ApplicationModel.IResourceBuilder`1` for [AzureStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageresource.md).
- `name` (`string`)
  The name of the resource.

## Returns

`IResourceBuilder<AzureBlobStorageResource>` -- An `ApplicationModel.IResourceBuilder`1` for the [AzureBlobStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azureblobstorageresource.md).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## AddDataLake(IResourceBuilder<AzureStorageResource>, string)

- Name: `AddDataLake(IResourceBuilder<AzureStorageResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureDataLakeStorageResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs#L411-L422)

Creates a builder for the [AzureDataLakeStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azuredatalakestorageresource.md) which can be referenced to get the Azure Data Lake endpoint for the storage account.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureDataLakeStorageResource> AddDataLake(
        this IResourceBuilder<AzureStorageResource> builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureStorageResource>`)
  The `ApplicationModel.IResourceBuilder`1` for [AzureStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageresource.md).
- `name` (`string`)
  The name of the resource.

## Returns

`IResourceBuilder<AzureDataLakeStorageResource>` -- An `ApplicationModel.IResourceBuilder`1` for the [AzureDataLakeStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azuredatalakestorageresource.md).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## AddDataLakeFileSystem(IResourceBuilder<AzureStorageResource>, string, string?)

- Name: `AddDataLakeFileSystem(IResourceBuilder<AzureStorageResource>, string, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureDataLakeStorageFileSystemResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs#L517-L528)

Creates a builder for the [AzureDataLakeStorageFileSystemResource](/reference/api/csharp/aspire.hosting.azure.storage/azuredatalakestoragefilesystemresource.md) which can be referenced to get the Azure DataLake file system connection string.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureDataLakeStorageFileSystemResource> AddDataLakeFileSystem(
        this IResourceBuilder<AzureStorageResource> builder,
        string name,
        string? dataLakeFileSystemName = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureStorageResource>`)
  The `ApplicationModel.IResourceBuilder`1` for [AzureStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageresource.md).
- `name` (`string`)
  The name of the resource.
- `dataLakeFileSystemName` (`string?`) `optional`
  The name of the data lake file system.

## Returns

`IResourceBuilder<AzureDataLakeStorageFileSystemResource>` -- An `ApplicationModel.IResourceBuilder`1` for the [AzureDataLakeStorageFileSystemResource](/reference/api/csharp/aspire.hosting.azure.storage/azuredatalakestoragefilesystemresource.md).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## AddQueue(IResourceBuilder<AzureStorageResource>, string, string?)

- Name: `AddQueue(IResourceBuilder<AzureStorageResource>, string, string?)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureQueueStorageQueueResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs#L634-L658)

Creates a builder for the [AzureQueueStorageQueueResource](/reference/api/csharp/aspire.hosting.azure.storage/azurequeuestoragequeueresource.md) which can be referenced to get the Azure Storage queue for the storage account.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureQueueStorageQueueResource> AddQueue(
        this IResourceBuilder<AzureStorageResource> builder,
        string name,
        string? queueName = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureStorageResource>`)
  The `ApplicationModel.IResourceBuilder`1` for [AzureStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageresource.md).
- `name` (`string`)
  The name of the resource.
- `queueName` (`string?`) `optional`
  The name of the queue.

## Returns

`IResourceBuilder<AzureQueueStorageQueueResource>` -- An `ApplicationModel.IResourceBuilder`1` for the [AzureQueueStorageQueueResource](/reference/api/csharp/aspire.hosting.azure.storage/azurequeuestoragequeueresource.md).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## AddQueues(IResourceBuilder<AzureStorageResource>, string)

- Name: `AddQueues(IResourceBuilder<AzureStorageResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureQueueStorageResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs#L595-L605)

Creates a builder for the [AzureQueueStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azurequeuestorageresource.md) which can be referenced to get the Azure Storage queues endpoint for the storage account.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureQueueStorageResource> AddQueues(
        this IResourceBuilder<AzureStorageResource> builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureStorageResource>`)
  The `ApplicationModel.IResourceBuilder`1` for [AzureStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageresource.md).
- `name` (`string`)
  The name of the resource.

## Returns

`IResourceBuilder<AzureQueueStorageResource>` -- An `ApplicationModel.IResourceBuilder`1` for the [AzureQueueStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azurequeuestorageresource.md).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## AddTables(IResourceBuilder<AzureStorageResource>, string)

- Name: `AddTables(IResourceBuilder<AzureStorageResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureTableStorageResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs#L578-L581)

Creates a builder for the [AzureTableStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azuretablestorageresource.md) which can be referenced to get the Azure Storage tables endpoint for the storage account.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureTableStorageResource> AddTables(
        this IResourceBuilder<AzureStorageResource> builder,
        string name)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureStorageResource>`)
  The `ApplicationModel.IResourceBuilder`1` for [AzureStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageresource.md).
- `name` (`string`)
  The name of the resource.

## Returns

`IResourceBuilder<AzureTableStorageResource>` -- An `ApplicationModel.IResourceBuilder`1` for the [AzureTableStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azuretablestorageresource.md).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## RunAsEmulator(IResourceBuilder<AzureStorageResource>, Action<IResourceBuilder<AzureStorageEmulatorResource>>)

- Name: `RunAsEmulator(IResourceBuilder<AzureStorageResource>, Action<IResourceBuilder<AzureStorageEmulatorResource>>)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureStorageResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs#L183-L265)

Configures an Azure Storage resource to be emulated using Azurite. This resource requires an [AzureStorageResource](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageresource.md) to be added to the application model.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureStorageResource> RunAsEmulator(
        this IResourceBuilder<AzureStorageResource> builder,
        Action<IResourceBuilder<AzureStorageEmulatorResource>>? configureContainer = null)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureStorageResource>`)
  The Azure storage resource builder.
- `configureContainer` (`Action<IResourceBuilder<AzureStorageEmulatorResource>>`) `optional`
  Callback that exposes underlying container used for emulation to allow for customization.

## Returns

`IResourceBuilder<AzureStorageResource>` -- 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.

## WithApiVersionCheck(IResourceBuilder<AzureStorageEmulatorResource>, bool)

- Name: `WithApiVersionCheck(IResourceBuilder<AzureStorageEmulatorResource>, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureStorageEmulatorResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs#L360-L373)

Ensures the emulator checks that the requested API version is valid.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureStorageEmulatorResource> WithApiVersionCheck(
        this IResourceBuilder<AzureStorageEmulatorResource> builder,
        bool enable = true)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureStorageEmulatorResource>`)
  Storage emulator resource builder.
- `enable` (`bool`) `optional`
  Whether to enable API version check or not. Default is true.

## Returns

`IResourceBuilder<AzureStorageEmulatorResource>` -- An `ApplicationModel.IResourceBuilder`1` for the [AzureStorageEmulatorResource](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageemulatorresource.md).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithBlobPort(IResourceBuilder<AzureStorageEmulatorResource>, int)

- Name: `WithBlobPort(IResourceBuilder<AzureStorageEmulatorResource>, int)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureStorageEmulatorResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs#L307-L312)

Modifies the host port that the storage emulator listens on for blob requests.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureStorageEmulatorResource> WithBlobPort(
        this IResourceBuilder<AzureStorageEmulatorResource> builder,
        int port)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureStorageEmulatorResource>`)
  Storage emulator resource builder.
- `port` (`int`)
  Host port to use.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithDataBindMount(IResourceBuilder<AzureStorageEmulatorResource>, string?, bool)

- Name: `WithDataBindMount(IResourceBuilder<AzureStorageEmulatorResource>, string?, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureStorageEmulatorResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs#L278-L280)

Adds a bind mount for the data folder to an Azure Storage emulator resource.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureStorageEmulatorResource> WithDataBindMount(
        this IResourceBuilder<AzureStorageEmulatorResource> builder,
        string? path = null,
        bool isReadOnly = false)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureStorageEmulatorResource>`)
  The builder for the [AzureStorageEmulatorResource](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageemulatorresource.md).
- `path` (`string?`) `optional`
  Relative path to the AppHost where emulator storage is persisted between runs. Defaults to the path '.azurite/{builder.Resource.Name}'
- `isReadOnly` (`bool`) `optional`
  A flag that indicates if this is a read-only mount.

## Returns

`IResourceBuilder<AzureStorageEmulatorResource>` -- A builder for the [AzureStorageEmulatorResource](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageemulatorresource.md).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithDataVolume(IResourceBuilder<AzureStorageEmulatorResource>, string?, bool)

- Name: `WithDataVolume(IResourceBuilder<AzureStorageEmulatorResource>, string?, bool)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureStorageEmulatorResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs#L293-L295)

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

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureStorageEmulatorResource> WithDataVolume(
        this IResourceBuilder<AzureStorageEmulatorResource> builder,
        string? name = null,
        bool isReadOnly = false)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureStorageEmulatorResource>`)
  The builder for the [AzureStorageEmulatorResource](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageemulatorresource.md).
- `name` (`string?`) `optional`
  The name of the volume. Defaults to an auto-generated name based on the application and resource names.
- `isReadOnly` (`bool`) `optional`
  A flag that indicates if this is a read-only volume.

## Returns

`IResourceBuilder<AzureStorageEmulatorResource>` -- A builder for the [AzureStorageEmulatorResource](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageemulatorresource.md).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithQueuePort(IResourceBuilder<AzureStorageEmulatorResource>, int)

- Name: `WithQueuePort(IResourceBuilder<AzureStorageEmulatorResource>, int)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureStorageEmulatorResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs#L324-L329)

Modifies the host port that the storage emulator listens on for queue requests.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureStorageEmulatorResource> WithQueuePort(
        this IResourceBuilder<AzureStorageEmulatorResource> builder,
        int port)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureStorageEmulatorResource>`)
  Storage emulator resource builder.
- `port` (`int`)
  Host port to use.

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.

## WithRoleAssignments(IResourceBuilder<T>, IResourceBuilder<AzureStorageResource>, StorageBuiltInRole[])

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

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

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

## Parameters

- `builder` (`IResourceBuilder<T>`)
  The resource to which the specified roles will be assigned.
- `target` (`IResourceBuilder<AzureStorageResource>`)
  The target Azure Storage account.
- `roles` (`StorageBuiltInRole[]`)
  The built-in storage roles to be assigned.

## Returns

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

## Remarks

Assigns the StorageBlobDataContributor role to the 'Projects.Api' project.

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

var storage = builder.AddAzureStorage("storage");
var blobs = storage.AddBlobs("blobs");

var api = builder.AddProject<Projects.Api>("api")
  .WithRoleAssignments(storage, StorageBuiltInRole.StorageBlobDataContributor)
  .WithReference(blobs);
```

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## WithTablePort(IResourceBuilder<AzureStorageEmulatorResource>, int)

- Name: `WithTablePort(IResourceBuilder<AzureStorageEmulatorResource>, int)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<AzureStorageEmulatorResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/cbc352350f1a9bafbaff10d14a2c8de4ac186a48/src/Aspire.Hosting.Azure.Storage/AzureStorageExtensions.cs#L342-L347)

Modifies the host port that the storage emulator listens on for table requests.

```csharp
public static class AzureStorageExtensions
{
    public static IResourceBuilder<AzureStorageEmulatorResource> WithTablePort(
        this IResourceBuilder<AzureStorageEmulatorResource> builder,
        int port)
    {
        // ...
    }
}
```

## Parameters

- `builder` (`IResourceBuilder<AzureStorageEmulatorResource>`)
  Storage emulator resource builder.
- `port` (`int`)
  Host port to use.

## Returns

`IResourceBuilder<AzureStorageEmulatorResource>` -- An `ApplicationModel.IResourceBuilder`1` for the [AzureStorageEmulatorResource](/reference/api/csharp/aspire.hosting.azure.storage/azurestorageemulatorresource.md).

## ATS metadata

### ATS export

- Available to Polyglot AppHosts through the Aspire Type System.
