var builder = DistributedApplication.CreateBuilder(args);
var storage = builder.AddAzureStorage("storage").RunAsEmulator();
var queue = storage.AddQueues("queue");
var blob = storage.AddBlobs("blob");
var eventHubs = builder.AddAzureEventHubs("eventhubs").UseExisting().AddEventHub("myhub");
var serviceBus = builder.AddAzureServiceBus("messaging").UseExisting().WithQueue("myqueue");
builder.AddAzureFunctionsProject<Projects.AzureFunctionsEndToEnd_Functions>("funcapp")
.WithExternalHttpEndpoints()
.WithReference(eventHubs).WaitFor(eventHubs)
.WithReference(serviceBus).WaitFor(serviceBus)
.WithReference(blob)
.WithReference(queue);
builder.Build().Run();
UsePreprovisioned
method a-laUseEmulator
- Defined on AzureResource type
- Requirement: How do we want to support customizing the already provisionedx resource?
- Do we need to think about something for non-Azure resources?
- Yes, we care about this not just for AWS but for SQL resources as well that are running locally.
- How is local resource different from plain old connection string?
- Yes, we care about this not just for AWS but for SQL resources as well that are running locally.
public static IResourceBuilder<AzureResource> UsePreprovisioned(this IResourceBuilder<AzureResource> builder)
{
var configuration = builder.ApplicationBuilder.Configuration.GetSection(builder.Resource.Name);
builder.Resource.BindOutputs(configuration)
builder.Resource.Annotations.Add(new PreprovisionedResource());
return builder;
}
PreprovosionedResource
marker annotation- Where can resources come from?
- Single resource group, single subscription, single location
- Strongly-typed output parameters for each resource type?
- Stages of the feature:
- See types of resources below
- Is pre-provisioned local-only or can you access pre-provisioned for production?
- Only for local-dev
- For both local and remote
- Emulated locally, pre-provisioned in deployment
- Pre-provisioned locally, Aspire-managed in deployment
Types of resources
- Create: Aspire-managed (what we have now)
- Update: Existing with permissions (pre-existing, not exclusive to Aspire, have admin permissions on it)
- Read: Existing but you have no permissions to write to it (e.g. modify persmission)
Min-bar: pre-existing resources in local and production (with global managed identity typed)
Proposed API:
public static IResourceBuilder<T> UseExisting(this IResourceBuilder<t> b, string subscriptionId = null, string resourceGroupName = null, string resourceName = null)
Resources have:
- State
- Behaviors