Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mounted volume information isn't respected when generating deployment templates #1676

Closed
aaronpowell opened this issue Jan 17, 2024 · 5 comments
Assignees
Labels
area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication enhancement An enhancement to an existing feature or capability.

Comments

@aaronpowell
Copy link
Contributor

I'm building an app with a Postgres database which I need to ensure some extensions are installed into Postgres for the app to work.

This is a pretty easy solved problem locally, you just add .WithVolumeMount("./database", "/docker-entrypoint-initdb.d", VolumeMountType.Bind) to the resource builder for Postgres (copied from this sample).

But when I scaffold out the infrastructure with azd infra synth (because I wanted to check it before deployment) I noticed that there was no analogy to the WithVolumeMount that would run my SQL script for me.

I don't think that mounting a volume is the right solution when deploying to Azure (given the transient nature of storage), I was thinking that it might generate something that uses the deploymentScripts feature of Bicep.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Jan 17, 2024
@davidfowl
Copy link
Member

It's unlikely that we'll ship anything for deploying volumes in aspire v1. @mitchdenny has done some thinking here, but it's not baked enough to make it.

@mitchdenny mitchdenny added this to the Backlog milestone Jan 22, 2024
@mitchdenny mitchdenny self-assigned this Jan 22, 2024
@davidfowl davidfowl modified the milestones: Backlog, preview 5 (Apr) Mar 3, 2024
@davidfowl davidfowl assigned DamianEdwards and unassigned mitchdenny Mar 3, 2024
@davidfowl
Copy link
Member

Bringing this back into preview 5 and assigning to @DamianEdwards. We want to scope this to container resources and a representation in the manifest that is viable that is enough information to make work in deployment environments like ACA and Kuberenetes.

Not sure how much we will need to scope, but we just need an initial investigation.

Related to #1521

@aaronpowell
Copy link
Contributor Author

I wonder if there's a way Aspire can try to determine what the objective of the volume mount is to then make that objective available to the metadata and then the IaC generator can generate the appropriate output.

If we use the example in the DatabaseContainers sample the reason for introducing a volume mount is to run a SQL script on startup of the container (to, say, pre-provision the db).

Expanding this objective out to an Azure context, we'd be wanting a PostgreSQL db and we can then use a deploymentScript resource to run the script against the Azure PostgreSQL service that's been deployed.

@davidfowl
Copy link
Member

davidfowl commented Mar 3, 2024

The goal is to represent the existing information in the model since what we have today is lossy. Then we need to figure out if reflecting what we have in the manifest is enough for the container scenario. Mapping deployment scripts that run against the cloud database is magical and out of scope.

However, it would OK if that were an explicit API on top of the existing model being built in preview4 and beyond:

var pg = builder.AddPostgres("pg")
                .WithVolume(...)
                .PublishAsAzurePostgresFlexibleServer(azurePg => 
                {
                       azurePg.RunDeploymentScript(.....);
                })
                .AddDatabase("db");

@DamianEdwards DamianEdwards added enhancement An enhancement to an existing feature or capability. feature A single user-facing feature. Can be grouped under an epic. and removed untriaged enhancement An enhancement to an existing feature or capability. feature A single user-facing feature. Can be grouped under an epic. labels Mar 8, 2024
@DamianEdwards
Copy link
Member

Closing this done via #2742 as the scope was constrained to writing out the volume details to the manifest.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 25, 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 enhancement An enhancement to an existing feature or capability.
Projects
None yet
Development

No branches or pull requests

4 participants