aspire icon indicating copy to clipboard operation
aspire copied to clipboard

Failed Step 3 of "aspire deploy" returns exit code 0 even if failed.

Open Steinblock opened this issue 1 month ago • 3 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Describe the bug

I am in the process of migrating from azd up to aspire deploy in a CI/CD pipeline to deploy to azure.

For some errors that I had aspire deploy failed so my pipeline (GitLab) failed as well.

Now I saw my pipeline succeeded but the app was not updated so I looked at the logs. aspire deploy failed during step 3 but the exit code was 0

Expected Behavior

I would exepect a non zero exit code so my pipeline fails.

Steps To Reproduce

I don't know how to reproduce this because I don't know the root cause yet, but this is my (stripped down) build step

deploy:
  stage: staging
  image: mcr.microsoft.com/dotnet/sdk:9.0-noble
  before_script:
    # install az
    - curl -sL https://aka.ms/InstallAzureCLIDeb | bash
    - az version
    # install aspire-cli
    - curl -sSL https://aspire.dev/install.sh | bash
    - ~/.aspire/bin/aspire --version
  script:
    - az login --service-principal --username "$AZURE_CLIENT_ID" --password "$AZURE_CLIENT_SECRET" --tenant "$AZURE_TENANT_ID"
    # deploy
    - ~/.aspire/bin/aspire deploy
    - echo "aspire deploy exitcode:$?"

and this is the (relevant) output

...
$ ~/.aspire/bin/aspire --version
9.5.2+2fc27528ec03a94f2d6c663c9fa2392a9568ee41
$ az login --service-principal --username "$AZURE_CLIENT_ID" --password "$AZURE_CLIENT_SECRET" --tenant "$AZURE_TENANT_ID"
...
$ ~/.aspire/bin/aspire deploy
🔬 Checking project type...: AppHost.csproj
🛠  Building apphost... AppHost.csproj
🛠 Generating artifacts...
Step 1: Analyzing model.
✅ COMPLETED: Analyzing model. completed successfully
════════════════════════════════════════════════════════════════════════════════
Step 2: Validating Azure CLI authentication
✅ COMPLETED: Azure CLI authentication validated successfully
════════════════════════════════════════════════════════════════════════════════
Step 3: Deploying Azure resources
Deploying cae: 0%
Deploying postgres: 0%
Deploying postgres-kv: 0%
Deploying messaging: 0%
Deploying storage: 0%
Deploying azureopenai: 0%
Deploying app-identity: 0%
Deploying app-roles-postgres-kv: 0%
Deploying app-roles-messaging: 0%
Deploying app-roles-storage: 0%
Deploying functions-identity: 0%
Deploying functions-roles-storage: 0%
Deploying functions-roles-messaging: 0%
Deploying functions-roles-azureopenai: 0%
Deploying functions-roles-postgres-kv: 0%
Deploying cae: 0%
✗ FAILED: Deploying postgres: 0%
✗ FAILED: Deploying postgres-kv: 0%
Deploying messaging: 0%
Deploying storage: 0%
Deploying azureopenai: 0%
Deploying app-identity: 0%
✗ FAILED: Deploying app-roles-postgres-kv: 0%
Deploying app-roles-messaging: 0%
✗ FAILED: Deploying app-roles-storage: 0%
✗ FAILED: Deploying functions-identity: 0%
Deploying functions-roles-storage: 0%
✗ FAILED: Deploying functions-roles-messaging: 0%
Deploying functions-roles-azureopenai: 0%
Deploying functions-roles-postgres-kv: 0%
❌ FAILED: Failed to deploy Azure resources
════════════════════════════════════════════════════════════════════════════════
✗ DEPLOYMENT FAILED: Deployment completed with errors
$ echo "aspire deploy exitcode:$?"
aspire deploy exitcode:0

As you can see, the deployment of some resources failed so

Step 3: Deploying Azure resources
...
✗ FAILED: Deploying postgres: 0%
...
❌ FAILED: Failed to deploy Azure resources

so the process stops. But the exit code is 0

Exceptions (if any)

No response

.NET Version info

No response

Anything else?

No response

Steinblock avatar Nov 09 '25 13:11 Steinblock

I'm a bot. Here is a possible related and/or duplicate issue (I may be wrong):

  • https://github.com/dotnet/aspire/issues/8852

MihuBot avatar Nov 09 '25 13:11 MihuBot

same here, despite using aspire-cli as a local-tool

9.5.2+2fc27528ec03a94f2d6c663c9fa2392a9568ee41

earloc avatar Nov 10 '25 11:11 earloc

Since this is also happening for 13.0.0+7512c2944094a58904b6c803aa824c4a4ce42e11 we are now basically just looking for the final success-message ✓ PIPELINE SUCCEEDED and fail the step, when it isn't present. This works fine for now in azure pipelines on ubuntu-latest:

        set -e
        tmpfile=$(mktemp)
        dotnet aspire deploy 2>&1 | tee "$tmpfile"
        if ! grep -q "✓ PIPELINE SUCCEEDED" "$tmpfile"; then
          echo "Aspire deploy seemed to have failed, success message not found."
          exit 1
        fi

I guess a similar thing might also work for 9.5.2, despite having a different success critera.

We moved on, so I cannot tell, which kind of message to look for in order to infer "success" for 9.5.2:)

earloc avatar Nov 13 '25 17:11 earloc