Skip to content
Docs Try Aspire

AzureStorageExtensions Methods

Class Methods 15 members
Extension methods for adding Azure Storage resources to an application model.
AddAzureStorage(IDistributedApplicationBuilder, string) Section titled AddAzureStorage(IDistributedApplicationBuilder, string) extension IResourceBuilder<AzureStorageResource>
Adds an Azure Storage resource to the application model. This resource can be used to create Azure blob, table, and queue resources.
public static class AzureStorageExtensions
{
public static IResourceBuilder<AzureStorageResource> AddAzureStorage(
this IDistributedApplicationBuilder builder,
string name)
{
// ...
}
}
builder IDistributedApplicationBuilder The builder for the distributed application.
name string The name of the resource.
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.
AddBlobContainer(IResourceBuilder<AzureStorageResource>, string, string?) Section titled AddBlobContainer(IResourceBuilder<AzureStorageResource>, string, string?) extension IResourceBuilder<AzureBlobStorageContainerResource>
Creates a builder for the AzureBlobStorageContainerResource which can be referenced to get the Azure Storage blob container endpoint for the storage account.
public static class AzureStorageExtensions
{
public static IResourceBuilder<AzureBlobStorageContainerResource> AddBlobContainer(
this IResourceBuilder<AzureStorageResource> builder,
string name,
string? blobContainerName = null)
{
// ...
}
}
builder IResourceBuilder<AzureStorageResource> The ApplicationModel.IResourceBuilder`1 for AzureStorageResource.
name string The name of the resource.
blobContainerName string? optional The name of the blob container.
IResourceBuilder<AzureBlobStorageContainerResource> An ApplicationModel.IResourceBuilder`1 for the AzureBlobStorageContainerResource.
AddBlobContainer(IResourceBuilder<AzureBlobStorageResource>, string, string?) Section titled AddBlobContainer(IResourceBuilder<AzureBlobStorageResource>, string, string?) extension IResourceBuilder<AzureBlobStorageContainerResource>
Creates a builder for the AzureBlobStorageContainerResource which can be referenced to get the Azure Storage blob container endpoint for the storage account.
public static class AzureStorageExtensions
{
public static IResourceBuilder<AzureBlobStorageContainerResource> AddBlobContainer(
this IResourceBuilder<AzureBlobStorageResource> builder,
string name,
string? blobContainerName = null)
{
// ...
}
}
builder IResourceBuilder<AzureBlobStorageResource> The ApplicationModel.IResourceBuilder`1 for AzureBlobStorageResource.
name string The name of the resource.
blobContainerName string? optional The name of the blob container.
IResourceBuilder<AzureBlobStorageContainerResource> An ApplicationModel.IResourceBuilder`1 for the AzureBlobStorageContainerResource.
AddBlobs(IResourceBuilder<AzureStorageResource>, string) Section titled AddBlobs(IResourceBuilder<AzureStorageResource>, string) extension IResourceBuilder<AzureBlobStorageResource>
Creates a builder for the AzureBlobStorageResource which can be referenced to get the Azure Storage blob endpoint for the storage account.
public static class AzureStorageExtensions
{
public static IResourceBuilder<AzureBlobStorageResource> AddBlobs(
this IResourceBuilder<AzureStorageResource> builder,
string name)
{
// ...
}
}
builder IResourceBuilder<AzureStorageResource> The ApplicationModel.IResourceBuilder`1 for AzureStorageResource.
name string The name of the resource.
IResourceBuilder<AzureBlobStorageResource> An ApplicationModel.IResourceBuilder`1 for the AzureBlobStorageResource.
AddQueue(IResourceBuilder<AzureStorageResource>, string, string?) Section titled AddQueue(IResourceBuilder<AzureStorageResource>, string, string?) extension IResourceBuilder<AzureQueueStorageQueueResource>
Creates a builder for the AzureQueueStorageQueueResource which can be referenced to get the Azure Storage queue for the storage account.
public static class AzureStorageExtensions
{
public static IResourceBuilder<AzureQueueStorageQueueResource> AddQueue(
this IResourceBuilder<AzureStorageResource> builder,
string name,
string? queueName = null)
{
// ...
}
}
builder IResourceBuilder<AzureStorageResource> The ApplicationModel.IResourceBuilder`1 for AzureStorageResource.
name string The name of the resource.
queueName string? optional The name of the queue.
IResourceBuilder<AzureQueueStorageQueueResource> An ApplicationModel.IResourceBuilder`1 for the AzureQueueStorageQueueResource.
AddQueues(IResourceBuilder<AzureStorageResource>, string) Section titled AddQueues(IResourceBuilder<AzureStorageResource>, string) extension IResourceBuilder<AzureQueueStorageResource>
Creates a builder for the AzureQueueStorageResource which can be referenced to get the Azure Storage queues endpoint for the storage account.
public static class AzureStorageExtensions
{
public static IResourceBuilder<AzureQueueStorageResource> AddQueues(
this IResourceBuilder<AzureStorageResource> builder,
string name)
{
// ...
}
}
builder IResourceBuilder<AzureStorageResource> The ApplicationModel.IResourceBuilder`1 for AzureStorageResource.
name string The name of the resource.
IResourceBuilder<AzureQueueStorageResource> An ApplicationModel.IResourceBuilder`1 for the AzureQueueStorageResource.
AddTables(IResourceBuilder<AzureStorageResource>, string) Section titled AddTables(IResourceBuilder<AzureStorageResource>, string) extension IResourceBuilder<AzureTableStorageResource>
Creates a builder for the AzureTableStorageResource which can be referenced to get the Azure Storage tables endpoint for the storage account.
public static class AzureStorageExtensions
{
public static IResourceBuilder<AzureTableStorageResource> AddTables(
this IResourceBuilder<AzureStorageResource> builder,
string name)
{
// ...
}
}
builder IResourceBuilder<AzureStorageResource> The ApplicationModel.IResourceBuilder`1 for AzureStorageResource.
name string The name of the resource.
IResourceBuilder<AzureTableStorageResource> An ApplicationModel.IResourceBuilder`1 for the AzureTableStorageResource.
RunAsEmulator(IResourceBuilder<AzureStorageResource>, Action<IResourceBuilder<AzureStorageEmulatorResource>>) Section titled RunAsEmulator(IResourceBuilder<AzureStorageResource>, Action<IResourceBuilder<AzureStorageEmulatorResource>>) extension IResourceBuilder<AzureStorageResource>
Configures an Azure Storage resource to be emulated using Azurite. This resource requires an AzureStorageResource to be added to the application model.
public static class AzureStorageExtensions
{
public static IResourceBuilder<AzureStorageResource> RunAsEmulator(
this IResourceBuilder<AzureStorageResource> builder,
Action<IResourceBuilder<AzureStorageEmulatorResource>>? configureContainer = null)
{
// ...
}
}
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.
IResourceBuilder<AzureStorageResource> A reference to the ApplicationModel.IResourceBuilder`1.
This version of the package defaults to the tag of the / container image.
WithApiVersionCheck(IResourceBuilder<AzureStorageEmulatorResource>, bool) Section titled WithApiVersionCheck(IResourceBuilder<AzureStorageEmulatorResource>, bool) extension IResourceBuilder<AzureStorageEmulatorResource>
Ensures the emulator checks that the requested API version is valid.
public static class AzureStorageExtensions
{
public static IResourceBuilder<AzureStorageEmulatorResource> WithApiVersionCheck(
this IResourceBuilder<AzureStorageEmulatorResource> builder,
bool enable = true)
{
// ...
}
}
builder IResourceBuilder<AzureStorageEmulatorResource> Storage emulator resource builder.
enable bool optional Whether to enable API version check or not. Default is true.
IResourceBuilder<AzureStorageEmulatorResource> An ApplicationModel.IResourceBuilder`1 for the AzureStorageEmulatorResource.
WithBlobPort(IResourceBuilder<AzureStorageEmulatorResource>, int) Section titled WithBlobPort(IResourceBuilder<AzureStorageEmulatorResource>, int) extension IResourceBuilder<AzureStorageEmulatorResource>
Modifies the host port that the storage emulator listens on for blob requests.
public static class AzureStorageExtensions
{
public static IResourceBuilder<AzureStorageEmulatorResource> WithBlobPort(
this IResourceBuilder<AzureStorageEmulatorResource> builder,
int port)
{
// ...
}
}
builder IResourceBuilder<AzureStorageEmulatorResource> Storage emulator resource builder.
port int Host port to use.
WithDataBindMount(IResourceBuilder<AzureStorageEmulatorResource>, string?, bool) Section titled WithDataBindMount(IResourceBuilder<AzureStorageEmulatorResource>, string?, bool) extension IResourceBuilder<AzureStorageEmulatorResource>
Adds a bind mount for the data folder to an Azure Storage emulator resource.
public static class AzureStorageExtensions
{
public static IResourceBuilder<AzureStorageEmulatorResource> WithDataBindMount(
this IResourceBuilder<AzureStorageEmulatorResource> builder,
string? path = null,
bool isReadOnly = false)
{
// ...
}
}
builder IResourceBuilder<AzureStorageEmulatorResource> The builder for the AzureStorageEmulatorResource.
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.
IResourceBuilder<AzureStorageEmulatorResource> A builder for the AzureStorageEmulatorResource.
WithDataVolume(IResourceBuilder<AzureStorageEmulatorResource>, string?, bool) Section titled WithDataVolume(IResourceBuilder<AzureStorageEmulatorResource>, string?, bool) extension IResourceBuilder<AzureStorageEmulatorResource>
Adds a named volume for the data folder to an Azure Storage emulator resource.
public static class AzureStorageExtensions
{
public static IResourceBuilder<AzureStorageEmulatorResource> WithDataVolume(
this IResourceBuilder<AzureStorageEmulatorResource> builder,
string? name = null,
bool isReadOnly = false)
{
// ...
}
}
builder IResourceBuilder<AzureStorageEmulatorResource> The builder for the AzureStorageEmulatorResource.
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.
IResourceBuilder<AzureStorageEmulatorResource> A builder for the AzureStorageEmulatorResource.
WithQueuePort(IResourceBuilder<AzureStorageEmulatorResource>, int) Section titled WithQueuePort(IResourceBuilder<AzureStorageEmulatorResource>, int) extension IResourceBuilder<AzureStorageEmulatorResource>
Modifies the host port that the storage emulator listens on for queue requests.
public static class AzureStorageExtensions
{
public static IResourceBuilder<AzureStorageEmulatorResource> WithQueuePort(
this IResourceBuilder<AzureStorageEmulatorResource> builder,
int port)
{
// ...
}
}
builder IResourceBuilder<AzureStorageEmulatorResource> Storage emulator resource builder.
port int Host port to use.
WithRoleAssignments(IResourceBuilder<T>, IResourceBuilder<AzureStorageResource>, StorageBuiltInRole[]) Section titled WithRoleAssignments(IResourceBuilder<T>, IResourceBuilder<AzureStorageResource>, StorageBuiltInRole[]) extension IResourceBuilder<T>
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.
public static class AzureStorageExtensions
{
public static IResourceBuilder<T> WithRoleAssignments<T>(
this IResourceBuilder<T> builder,
IResourceBuilder<AzureStorageResource> target,
params StorageBuiltInRole[] roles)
{
// ...
}
}
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.
IResourceBuilder<T> The updated ApplicationModel.IResourceBuilder`1 with the applied role assignments.
Assigns the StorageBlobDataContributor role to the 'Projects.Api' project.
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);
WithTablePort(IResourceBuilder<AzureStorageEmulatorResource>, int) Section titled WithTablePort(IResourceBuilder<AzureStorageEmulatorResource>, int) extension IResourceBuilder<AzureStorageEmulatorResource>
Modifies the host port that the storage emulator listens on for table requests.
public static class AzureStorageExtensions
{
public static IResourceBuilder<AzureStorageEmulatorResource> WithTablePort(
this IResourceBuilder<AzureStorageEmulatorResource> builder,
int port)
{
// ...
}
}
builder IResourceBuilder<AzureStorageEmulatorResource> Storage emulator resource builder.
port int Host port to use.
IResourceBuilder<AzureStorageEmulatorResource> An ApplicationModel.IResourceBuilder`1 for the AzureStorageEmulatorResource.