AzureStorageExtensions.WithRoleAssignments<T> Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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 Aspire.Hosting.ApplicationModel.IResourceBuilder<T> WithRoleAssignments<T>(this Aspire.Hosting.ApplicationModel.IResourceBuilder<T> builder, Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureStorageResource> target, params Azure.Provisioning.Storage.StorageBuiltInRole[] roles) where T : Aspire.Hosting.ApplicationModel.IResource;
static member WithRoleAssignments : Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)> * Aspire.Hosting.ApplicationModel.IResourceBuilder<Aspire.Hosting.Azure.AzureStorageResource> * Azure.Provisioning.Storage.StorageBuiltInRole[] -> Aspire.Hosting.ApplicationModel.IResourceBuilder<'T (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)> (requires 'T :> Aspire.Hosting.ApplicationModel.IResource)
<Extension()>
Public Function WithRoleAssignments(Of T As IResource) (builder As IResourceBuilder(Of T), target As IResourceBuilder(Of AzureStorageResource), ParamArray roles As StorageBuiltInRole()) As IResourceBuilder(Of T)
Type Parameters
- T
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
The updated IResourceBuilder<T> with the applied role assignments.
Examples
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);