Skip to content

Container surrogate for UseEmulator for Azure Storage.#2132

Merged
mitchdenny merged 8 commits intomainfrom
mitchdenny/add-container-surrogate-for-useemulator
Feb 10, 2024
Merged

Container surrogate for UseEmulator for Azure Storage.#2132
mitchdenny merged 8 commits intomainfrom
mitchdenny/add-container-surrogate-for-useemulator

Conversation

@mitchdenny
Copy link
Copy Markdown
Member

@mitchdenny mitchdenny commented Feb 8, 2024

Container surrogate for Azure Storage. The idea is that with this optional callback you can manipuate the underlying resource as if it were a container when using the emulator. This was a model proposed at the App Model offsite.

The builder in the callback on UseEmulator is for type AzureStorageEmulatorContainerResource which derives from ContainerResource to activate all of those extension methods. The annotations a proxied through to the underlying resource.

Here is an example of using the code to enable persistent storage:

var builder = DistributedApplication.CreateBuilder(args);

var storage = builder.AddAzureStorage("storage").UseEmulator(container =>
{
    container.UsePersistence();
});

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

builder.AddProject<Projects.AzureStorageEndToEnd_ApiService>("api")
       .WithReference(blobs);

builder.Build().Run();

@mitchdenny mitchdenny added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Feb 8, 2024
@mitchdenny mitchdenny added this to the preview 4 (Mar) milestone Feb 8, 2024
@mitchdenny mitchdenny self-assigned this Feb 8, 2024
@mitchdenny mitchdenny marked this pull request as ready for review February 9, 2024 13:13
@mitchdenny mitchdenny requested a review from davidfowl February 9, 2024 13:13
Copy link
Copy Markdown
Contributor

@davidfowl davidfowl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice

@mitchdenny mitchdenny enabled auto-merge (squash) February 10, 2024 04:15
@mitchdenny mitchdenny merged commit 30df444 into main Feb 10, 2024
@mitchdenny mitchdenny deleted the mitchdenny/add-container-surrogate-for-useemulator branch February 10, 2024 06:59

namespace Aspire.Hosting.Azure;

public class AzureStorageEmulatorResource(AzureStorageResource innerResource) : ContainerResource(innerResource.Name), IResource
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All public APIs should have triple slash comments. We should not merge any PRs without them, perhaps we can fail the build or something if they're missing? //cc @davidfowl and @mitchdenny

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we should start to do that.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've opened #2191 for this.

radical pushed a commit to radical/aspire that referenced this pull request Feb 12, 2024
* Container surrogate for UseEmulator for Azure Storage.

* PR feedback.

* Create a factory method of IDAB to create a builder.

* Update playground/AzureStorageEndToEnd/AzureStorageEndToEnd.AppHost/Program.cs

Co-authored-by: David Fowler <davidfowl@gmail.com>

* Remove absolute path.

* PR feedback.

* Feedback.

---------

Co-authored-by: David Fowler <davidfowl@gmail.com>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 22, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants