DE

deployment-e2e-testing

Create and manage end-to-end deployment tests for .NET Aspire applications on Azure.

Install

mkdir -p .claude/skills/deployment-e2e-testing && curl -L -o skill.zip "https://agentskills.codes/api/skills/download/5258" && unzip -o skill.zip -d .claude/skills/deployment-e2e-testing && rm skill.zip

Installs to .claude/skills/deployment-e2e-testing

Activation

This is the description your AI agent reads to decide when to run this skill — the better it matches your request, the more reliably it fires.

Guide for writing Aspire deployment end-to-end tests. Use this when asked to create, modify, or debug deployment E2E tests that deploy to Azure.
144 chars✓ has a “when” trigger
Advanced

Key capabilities

  • Generate unique Azure resource group names
  • Automate Aspire CLI deployment workflows
  • Report deployment success or failure to GitHub step summary
  • Cleanup Azure resources after test execution
  • Verify deployed endpoint functionality

How it works

Tests use the Hex1b terminal automation library to drive the Aspire CLI, deploying applications to Azure and verifying endpoints before cleaning up resources.

Inputs & outputs

You give it
Aspire project configuration and deployment target
You get back
Deployment status report and cleaned Azure resource group

When to use deployment-e2e-testing

  • Write E2E deployment tests
  • Debug Azure deployment failures
  • Verify Aspire cloud infrastructure

About this skill

Aspire Deployment End-to-End Testing

This skill provides patterns and practices for writing end-to-end tests that deploy Aspire applications to real Azure infrastructure.

Overview

Deployment E2E tests extend the CLI E2E testing patterns with actual Azure deployments. They use the Hex1b terminal automation library to drive the Aspire CLI and verify that deployed applications work correctly.

Location: tests/Aspire.Deployment.EndToEnd.Tests/

Supported Platforms: Linux only (Hex1b requirement).

Prerequisites:

  • Azure subscription with appropriate permissions
  • OIDC authentication (CI) or Azure CLI authentication (local)

Relationship to CLI E2E Tests

Deployment tests build on the CLI E2E testing skill. Before working with deployment tests, familiarize yourself with:

Key differences from CLI E2E tests:

AspectCLI E2E TestsDeployment E2E Tests
Duration5-15 minutes15-45 minutes
ResourcesLocal onlyAzure resources
AuthenticationNoneAzure OIDC/CLI
CleanupTemp directoriesAzure resource groups
TriggersPR, pushNightly, manual, deploy-test/*

Key Components

Core Classes

  • DeploymentE2ETestHelpers (Helpers/DeploymentE2ETestHelpers.cs): Terminal factory and environment helpers
  • DeploymentE2EAutomatorHelpers (Helpers/DeploymentE2EAutomatorHelpers.cs): Async extension methods on Hex1bTerminalAutomator for deployment scenarios
  • Hex1bAutomatorTestHelpers (shared): Common async extension methods on Hex1bTerminalAutomator (WaitForSuccessPromptAsync, AspireNewAsync, etc.)
  • AzureAuthenticationHelpers (Helpers/AzureAuthenticationHelpers.cs): Azure auth and resource naming
  • DeploymentReporter (Helpers/DeploymentReporter.cs): GitHub step summary reporting
  • SequenceCounter (Helpers/SequenceCounter.cs): Prompt tracking (same as CLI E2E)

Test Architecture

Each deployment test:

  1. Validates Azure authentication (skip if not available locally)
  2. Generates a unique resource group name
  3. Creates a project using aspire new
  4. Deploys using aspire deploy
  5. Verifies deployed endpoints work
  6. Reports results to GitHub step summary
  7. Cleans up Azure resources

Test Structure

public sealed class MyDeploymentTests(ITestOutputHelper output)
{
    [Fact]
    public async Task DeployMyScenario()
    {
        // 1. Validate prerequisites
        var subscriptionId = AzureAuthenticationHelpers.TryGetSubscriptionId();
        if (string.IsNullOrEmpty(subscriptionId))
        {
            Assert.Skip("Azure subscription not configured.");
        }

        if (!AzureAuthenticationHelpers.IsAzureAuthAvailable())
        {
            if (DeploymentE2ETestHelpers.IsRunningInCI)
            {
                Assert.Fail("Azure auth not available in CI.");
            }
            Assert.Skip("Azure auth not available. Run 'az login'.");
        }

        // 2. Setup
        var resourceGroupName = AzureAuthenticationHelpers.GenerateResourceGroupName("my-scenario");
        var workspace = TemporaryWorkspace.Create(output);
        var startTime = DateTime.UtcNow;

        try
        {
            // 3. Build terminal and run deployment
            using var terminal = DeploymentE2ETestHelpers.CreateTestTerminal();
            var pendingRun = terminal.RunAsync(TestContext.Current.CancellationToken);

            var counter = new SequenceCounter();
            var auto = new Hex1bTerminalAutomator(terminal, defaultTimeout: TimeSpan.FromSeconds(500));

            await auto.PrepareEnvironmentAsync(workspace, counter);
            if (DeploymentE2ETestHelpers.IsRunningInCI)
            {
                await auto.SourceAspireCliEnvironmentAsync(counter);
            }
            await auto.AspireNewAsync("MyProject", counter, useRedisCache: false);
            // ... deployment steps ...

            await auto.TypeAsync("exit");
            await auto.EnterAsync();
            await pendingRun;

            // 4. Report success
            var duration = DateTime.UtcNow - startTime;
            DeploymentReporter.ReportDeploymentSuccess(
                nameof(DeployMyScenario),
                resourceGroupName,
                deploymentUrls,
                duration);
        }
        catch (Exception ex)
        {
            DeploymentReporter.ReportDeploymentFailure(
                nameof(DeployMyScenario),
                resourceGroupName,
                ex.Message);
            throw;
        }
        finally
        {
            // 5. Cleanup Azure resources
            await CleanupResourceGroupAsync(resourceGroupName);
        }
    }
}

Extension Methods

DeploymentE2EAutomatorHelpers Extensions on Hex1bTerminalAutomator

MethodDescription
PrepareEnvironmentAsync(workspace, counter)Sets up the terminal environment with custom prompt and workspace directory
InstallAspireCliFromPullRequestAsync(prNumber, counter)Downloads and installs the Aspire CLI from a PR build artifact
InstallAspireCliReleaseAsync(counter)Installs the latest released Aspire CLI
SourceAspireCliEnvironmentAsync(counter)Adds ~/.aspire/bin to PATH so the aspire command is available

These extend Hex1bTerminalAutomator and are used alongside the shared Hex1bAutomatorTestHelpers methods (WaitForSuccessPromptAsync, AspireNewAsync, etc.) documented in the CLI E2E Testing Skill.

Azure Authentication

In CI (GitHub Actions)

Tests use OIDC (Workload Identity Federation) for authentication:

- name: Azure Login (OIDC)
  uses: azure/login@v2
  with:
    client-id: ${{ secrets.AZURE_CLIENT_ID }}
    tenant-id: ${{ secrets.AZURE_TENANT_ID }}
    subscription-id: ${{ vars.ASPIRE_DEPLOYMENT_TEST_SUBSCRIPTION }}

The test code automatically detects CI and uses DefaultAzureCredential which picks up the OIDC session.

Local Development

Authenticate with Azure CLI before running tests:

# Login to Azure
az login

# Set your subscription
az account set --subscription "your-subscription-id"

# Set environment variable
export ASPIRE_DEPLOYMENT_TEST_SUBSCRIPTION="your-subscription-id"

# Run tests
dotnet test tests/Aspire.Deployment.EndToEnd.Tests/

Authentication Helpers

// Check if auth is available
if (!AzureAuthenticationHelpers.IsAzureAuthAvailable())
{
    Assert.Skip("Azure auth not available");
}

// Get subscription ID
var subscriptionId = AzureAuthenticationHelpers.GetSubscriptionId();

// Generate unique resource group name
var rgName = AzureAuthenticationHelpers.GenerateResourceGroupName("my-test");
// Result: "aspire-e2e-my-test-20240115-abc12345"

// Check auth type
if (AzureAuthenticationHelpers.IsOidcConfigured())
{
    // Using OIDC (CI)
}
else
{
    // Using Azure CLI (local)
}

Resource Group Naming

Resource groups are named with a consistent pattern for easy identification and cleanup:

{prefix}-{testname}-{date}-{runid}

Example: aspire-e2e-aca-starter-20240115-12345678

Components:

  • prefix: From ASPIRE_DEPLOYMENT_TEST_RG_PREFIX (default: aspire-e2e)
  • testname: Sanitized test name (lowercase, alphanumeric, hyphens)
  • date: UTC date in YYYYMMDD format
  • runid: GitHub run ID or random GUID suffix

Reporting Results

GitHub Step Summary

Tests automatically write to the GitHub step summary:

// Report success with URLs
DeploymentReporter.ReportDeploymentSuccess(
    testName: "DeployStarterToACA",
    resourceGroupName: "aspire-e2e-...",
    deploymentUrls: new Dictionary<string, string>
    {
        ["Dashboard"] = "https://dashboard.azurecontainerapps.io",
        ["Web Frontend"] = "https://webfrontend.azurecontainerapps.io"
    },
    duration: TimeSpan.FromMinutes(15));

// Report failure
DeploymentReporter.ReportDeploymentFailure(
    testName: "DeployStarterToACA",
    resourceGroupName: "aspire-e2e-...",
    errorMessage: "Deployment timed out",
    logs: "Full deployment logs...");

Asciinema Recordings

Tests generate recordings for debugging:

var recordingPath = DeploymentE2ETestHelpers.GetTestResultsRecordingPath(nameof(MyTest));
// CI: $GITHUB_WORKSPACE/testresults/recordings/MyTest.cast
// Local: /tmp/aspire-deployment-e2e/recordings/MyTest.cast

Cleanup

Always cleanup Azure resources in a finally block:

private static async Task CleanupResourceGroupAsync(string resourceGroupName)
{
    var process = new Process
    {
        StartInfo = new ProcessStartInfo
        {
            FileName = "az",
            Arguments = $"group delete --name {resourceGroupName} --yes --no-wait",
            RedirectStandardOutput = true,
            RedirectStandardError = true,
            UseShellExecute = false
        }
    };

    process.Start();
    await process.WaitForExitAsync();

    if (process.ExitCode != 0)
    {
        var error = await process.StandardError.ReadToEndAsync();
        throw new InvalidOperationException($"Cleanup failed: {error}");
    }
}

Workflow Triggers

Deployment tests are triggered by:

  1. Nightly schedule (03:00 UTC) - Runs on main
  2. Manual dispatch - Via GitHub Actions UI
  3. Push to deploy-test/* - For rapid iteration

Iterating on Tests

To iterate quickly during development:

# Create a protected branch
git checkout -b deploy-test/my-feature

# Make changes
# ...

# Push to trigger workflow
git push origin deploy-test/my-feature

Environment Variables

VariableRequiredDescription
ASPIRE_DEPLOYMENT_TEST_SUBSCRIPTIONYesAzure subscription ID
ASPIRE_DEPLOYMENT_TEST_RG_PREFIXNoResource group prefix (default: aspire-e2e)
`AZUR

Content truncated.

When not to use it

  • Testing local-only Aspire functionality
  • Environments without Azure subscription access

Prerequisites

Azure subscriptionAzure CLI or OIDC authentication

Limitations

  • Linux-only platform requirement
  • Long execution duration of 15-45 minutes

How it compares

This approach automates end-to-end cloud deployment lifecycles rather than just testing local CLI commands.

Compared to similar skills

deployment-e2e-testing side by side with the closest alternatives in the catalog.

SkillInstallsUpdatedSafetyDifficulty
deployment-e2e-testing (this skill)32moReviewAdvanced
microsoft-docs03moReviewBeginner
deployment-pipeline-design62moReviewAdvanced
terraform-module-library74moNo flagsAdvanced

Try saying

Example prompts that trigger this skill in your AI assistant.

You might also like

microsoft-docs

SilverPham08091998

Understand Microsoft technologies by querying official documentation. Use whenever the user asks how something works, wants tutorials, needs configuration options, limits, quotas, or best practices for any Microsoft technology (Azure, .NET, M365, Windows, Power Platform, etc.)—even if they don't men

00

deployment-pipeline-design

wshobson

Design multi-stage CI/CD pipelines with approval gates, security checks, and deployment orchestration. Use when architecting deployment workflows, setting up continuous delivery, or implementing GitOps practices.

670

terraform-module-library

wshobson

Build reusable Terraform modules for AWS, Azure, and GCP infrastructure following infrastructure-as-code best practices. Use when creating infrastructure modules, standardizing cloud provisioning, or implementing reusable IaC components.

759

csharp-pro

sickn33

Write modern C# code with advanced features like records, pattern matching, and async/await. Optimizes .NET applications, implements enterprise patterns, and ensures comprehensive testing. Use PROACTIVELY for C# refactoring, performance optimization, or complex .NET solutions.

953

vercel-deployment

davila7

Expert knowledge for deploying to Vercel with Next.js Use when: vercel, deploy, deployment, hosting, production.

359

performance-benchmark

dotnet

Generate and run ad hoc performance benchmarks to validate code changes. Use this when asked to benchmark, profile, or validate the performance impact of a code change in dotnet/runtime.

328

Search skills

Search the agent skills registry