Skip to content

Split up publish and deploy and unify graphs#11175

Merged
captainsafia merged 3 commits intomainfrom
safia/deploy-publish-split
Sep 2, 2025
Merged

Split up publish and deploy and unify graphs#11175
captainsafia merged 3 commits intomainfrom
safia/deploy-publish-split

Conversation

@captainsafia
Copy link
Contributor

@captainsafia captainsafia commented Aug 29, 2025

Contributes towards #10448.

20250828_220506

Copilot AI review requested due to automatic review settings August 29, 2025 15:18
@github-actions
Copy link
Contributor

🚀 Dogfood this PR with:

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 11175

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 11175"

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR contributes to separating publish and deploy operations while unifying resource deployment graphs. The changes remove the sequential execution of publishing followed by deploying callbacks when deploying, making the operations truly independent.

Key Changes

  • Modified publishing logic to only execute deploy callbacks when deploying, and only publish callbacks when publishing
  • Removed the ResourceDeploymentGraph class and simplified Azure resource provisioning to run in parallel instead of in dependency order
  • Made output path optional for deploy operations while keeping it required for publish operations

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/Aspire.Hosting.Tests/PublishingTests.cs Updated tests to verify publishing callbacks are not called during deploy operations
tests/Aspire.Hosting.Azure.Tests/AzureDeployerTests.cs Modified test expectations to verify files are not created during deploy-only operations
tests/Aspire.Cli.Tests/Commands/DeployCommandTests.cs Added test for deploy command working without output path
src/Aspire.Hosting/Publishing/Publisher.cs Refactored to separate publish and deploy logic flows
src/Aspire.Hosting/Publishing/DeployingContext.cs Made OutputPath nullable to support deploy without artifacts
src/Aspire.Hosting.Azure/Provisioning/ResourceDeploymentGraph.cs Removed entire file containing dependency graph implementation
src/Aspire.Hosting.Azure/AzureDeployingContext.cs Replaced graph-based deployment with parallel provisioning
src/Aspire.Cli/Resources/DeployCommandStrings.resx Updated description to indicate output path is optional
src/Aspire.Cli/Commands/PublishCommandBase.cs Made output path nullable and removed default value factory
src/Aspire.Cli/Commands/PublishCommand.cs Updated to handle nullable output path with fallback
src/Aspire.Cli/Commands/DeployCommand.cs Modified to conditionally include output path in arguments

Comment on lines 74 to 102
if (resource is AzureBicepResource bicepResource)
{
var resourceTask = await deployingStep.CreateTaskAsync($"Provisioning {resource.Name}", cancellationToken).ConfigureAwait(false);
await using (resourceTask.ConfigureAwait(false))
var resourceTask = await deployingStep.CreateTaskAsync($"Deploying {resource.Name}", cancellationToken).ConfigureAwait(false);

var provisioningTask = Task.Run(async () =>
{
await bicepProvisioner.GetOrCreateResourceAsync(bicepResource, context, cancellationToken).ConfigureAwait(false);
await resourceTask.CompleteAsync($"Successfully provisioned {resource.Name}", CompletionState.Completed, cancellationToken).ConfigureAwait(false);
}
await using (resourceTask.ConfigureAwait(false))
{
try
{
bicepResource.ProvisioningTaskCompletionSource = new(TaskCreationOptions.RunContinuationsAsynchronously);

await bicepProvisioner.GetOrCreateResourceAsync(bicepResource, provisioningContext, cancellationToken).ConfigureAwait(false);

bicepResource.ProvisioningTaskCompletionSource?.TrySetResult();

await resourceTask.CompleteAsync($"Successfully provisioned {bicepResource.Name}", CompletionState.Completed, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex)
{
await resourceTask.CompleteAsync($"Failed to provision {bicepResource.Name}: {ex.Message}", CompletionState.CompletedWithError, cancellationToken).ConfigureAwait(false);
bicepResource.ProvisioningTaskCompletionSource?.TrySetException(ex);
throw;
}
}
}, cancellationToken);

provisioningTasks.Add(provisioningTask);
}
Copy link

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The type check 'resource is AzureBicepResource bicepResource' is redundant since the collection 'bicepResources' is already typed as List. The foreach variable can be used directly as AzureBicepResource.

Copilot uses AI. Check for mistakes.
@davidfowl
Copy link
Member

This is a good change overall, but I do worry about the inability to diagnose deployment failures (by looking at the intermediate files). We'll need to build UX for this.

@davidfowl
Copy link
Member

PS: I'm surprised you haven't fixed this yet
image

😄

@captainsafia
Copy link
Contributor Author

This is a good change overall, but I do worry about the inability to diagnose deployment failures (by looking at the intermediate files). We'll need to build UX for this.

I think we can do something like aspire deploy --export for this BUT I'd love to build on top of aspire deploy --debug and see if we can build an experience that provided deployment diagnostics for you. We could see if we could figure out a way to correlate to the ARM error with the Bicep code that caused it and maybe even provide a note about the ConfigureInfrastructure code that you need to write to fix it.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 2, 2025

🚀 Dogfood this PR with:

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 11175

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 11175"

@captainsafia captainsafia merged commit 8942905 into main Sep 2, 2025
299 checks passed
@captainsafia captainsafia deleted the safia/deploy-publish-split branch September 2, 2025 20:05
@dotnet-policy-service dotnet-policy-service bot added this to the 9.5 milestone Sep 2, 2025
Copilot AI pushed a commit that referenced this pull request Sep 3, 2025
* Split up publish and deploy and unify graphs

* Feedback

* Quarantine test
@github-actions github-actions bot locked and limited conversation to collaborators Oct 3, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants