-
Notifications
You must be signed in to change notification settings - Fork 521
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
Allow specifying MSBuild arguments to build project resources for in publish mode #7069
Comments
What is WithContainer? Do you mean AddDockerFile or WithDockerFile? |
sorry - meant builder.AddContainer("image","tag") |
I'm confused. Are you building a container image using AddContainer(...).WithDockerFile? |
Here's an example of what I'm talking about ================================ Microservice Repo: FileService AppHost: var storageResource = builder.AddAzureStorage("storageAccount")
.RunAsEmulator(opt => opt.WithBlobPort(10000).WithLifetime(ContainerLifetime.Persistent))
.AddBlobs("files");
var apiService = builder.AddProject<Projects.FileServiceApi>("apiservice")
.WithReference(storageResource); ======================== Mircorservice Repo: RulesEngine AppHost: var cosmosDb = builder.AddAzureCosmosDB("rulesData")
.WithExternalHttpEndpoints()
.ConfigureInfrastructure(infr =>
{
var account = infr.GetProvisionableResources().OfType<CosmosDBAccount>().First();
account.Capabilities.Add(new CosmosDBAccountCapability { Name = "EnableServerless" });
})
.AddDatabase("rules");
var rulesEngine = builder.AddNpmApp("rules-engine", "../RulesEngine")
.PublishAsDockerFile();
var apiService = builder.AddProject<Projects.RulesApi>("apiservice")
.WithReference(rulesEngine)
.WithReference(cosmosDb); =========================== // File Service
var storageResource = builder.AddAzureStorage("storageAccount")
.RunAsEmulator(opt => opt.WithBlobPort(10000).WithLifetime(ContainerLifetime.Persistent))
.AddBlobs("files");
var fileService = builder.AddContainer("file-service","fileserviceapi/apiservice","azd-deploy-124215")
.WithReference(storageResource);
// Rules Engine
var cosmosDb = builder.AddAzureCosmosDB("rulesData")
.WithExternalHttpEndpoints()
.ConfigureInfrastructure(infr =>
{
var account = infr.GetProvisionableResources().OfType<CosmosDBAccount>().First();
account.Capabilities.Add(new CosmosDBAccountCapability { Name = "EnableServerless" });
})
.AddDatabase("rules");
var rulesEngine = builder.AddContainer("rules-engine","rulesengine/rulesengine","azd-deploy-523532")
var rulesApi = builder.AddContainer("rules-engine","rulesengine/apiservice","azd-deploy-5235243")
.WithReference(rulesEngine)
.WithReference(cosmosDb);
var application = builder.AddProject<Projects.ContentApp>("frontend")
.WithReference(rulesApi)
.WithReference(fileService) In this way - we can build and test all of our microservice in isolation - we then have a product repo that pulls it all together and (would ideally) reference semantically versioned container images from azure container registry for our microservices |
In the samples I dint see why azd would build any container. The image in this situation is baked into the bicep as a literal. |
I think I understand what you are asking for, but I think what you want is to be able to control msbuild properties when building projects. Today we have no way of setting build properties for projects. |
Background and Motivation
There should be a way to control how the container for a project gets produced in publish mode. Right now the deployment tool (such as azd) uses the manifest sees the project resource and has to infer how that project gets turned into a container image. Docker files are similar, but containers are able to expose build arguments that instruct tools on what values to pass to docker build. We need to same capability for projects.
Proposed API
Manifest
Usage Examples
Risks
We need to make sure that build arguments are applied in all of the places that make sense. Today, the apphost gets built, along with referenced projects before we execute. That might cause some confusion.
original issue
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
We deploy microservices via Aspire and Azure Developer CLI (azd). Currently, Aspire does not specify container repository naming conventions or image tags in the service manifests, and Azure Developer CLI (azd) applies default naming conventions:
Repository name: {projectName}/{serviceName}-{env}
Image tag: azd-deploy-{clock.now().unix()}
Steps to Reproduce
This behaviour limits our ability to use semantic versioning and custom repository names for container images.
Describe the solution you'd like
I propose adding support in Aspire to allow developers to specify container repository names and image tags directly in the manifest. Aspire should generate the manifest with these options so that azd can use the specified values instead of its defaults.
Proposed API Changes in Aspire
Add
ContainerPublishingOptionsAnnotation
This annotation will store the repository and image tag information.
Add Extension Method to Project Resource Builder
The extension method enables developers to configure these values.
Modify
WriteToProjectAsync
inManifestPublishingContext
Update the manifest generation logic to include the
config
section ifContainerPublishingOptionsAnnotation
is present.Updated Code:
Manifest changes:
Current
Updated
This would permit developers to do the following:
and then reference the deployed container image in a separate project as
Additional context
Currently, azd generates the container image name using the following logic:
This applies default values for the image repository and tag. To support configurable options for
containerImageTags
andcontainerRepository
, azd would need a corresponding change such as:This change would allow azd to read the custom values defined in the Aspire-generated manifest under the
config
section, enabling developers to override the defaults with their desired repository names and semantic version tags.The selection of "config" as the manifest property is driven by the existing azd ServiceConfig type which defines:
Final Notes:
These changes will:
These updates align with azd's existing
ServiceConfig
structure, leveraging itsconfig
property for container customization. I am happy to contribute the necessary code changes.The text was updated successfully, but these errors were encountered: