Skip to content

This is a collection of community contributed libraries for .NET Aspire

License

Notifications You must be signed in to change notification settings

aliencube/aspire-contribs

Repository files navigation

Aspire Contribs

This is a collection of community contributed libraries for .NET Aspire

Prerequisites

For Java App

Download OpenTelemetry agent

  1. First of all, you should have OpenTelemetry Agent for Java. You can download it to your local machine by running the following commands:

    # Bash
    mkdir -p ./agents
    wget -P ./agents \
        https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar
    
    # PowerShell
    New-item -type Directory -Path ./downloaded -Force
    Invoke-WebRequest `
        -OutFile "./agents/opentelemetry-javaagent.jar" `
        -Uri "https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/latest/download/opentelemetry-javaagent.jar"

Build container image

  1. Build the Spring app with Maven:

    pushd ./src/Aspire.Contribs.Spring.Maven
    
    ./mvnw clean package
    
    popd
  2. Build a container image for the Spring app:

    pushd ./src/Aspire.Contribs.Spring.Maven
    
    docker build . -t aspire-spring-maven-sample:latest
    
    popd
  3. Push the container image to Docker Hub under your organisation. This sample uses aliencube:

    docker tag aspire-spring-maven-sample:latest aliencube/aspire-spring-maven-sample:latest
    docker push aliencube/aspire-spring-maven-sample:latest

    NOTE: You need to log in to Docker Hub before pushing the image.

Run .NET Aspire

  1. If you want to integrate the containerised Spring app built above, open src/Aspire.Contribs.AppHost/Program.cs and update the following line:

    var containerapp = builder.AddSpringApp("containerapp",
                               new JavaAppContainerResourceOptions()
                               {
                                   // ⬇️⬇️⬇️ Update this line with your container image
                                   ContainerImageName = "aliencube/aspire-spring-maven-sample",
                                   // ⬆️⬆️⬆️ Update this line with your container image
                                   OtelAgentPath = "/agents"
                               });
  2. Run .NET Aspire dashboard:

    dotnet watch run --project ./src/Aspire.Contribs.AppHost
  3. Check the dashboard that both containerised app and executable app are up and running.

    Aspire Dashboard

  4. Open the web app in your browser and navigate to the /weather page and see the weather information from ASP.NET Core Web API app, Spring container app and Spring executable app.

    Weather Page

For Azure API Management

TBD

Deployment to Azure

  1. Get the Azure environment name ready:

    # Bash
    AZURE_ENV_NAME="contribs$((RANDOM%9000+1000))"
    
    # PowerShell
    $AZURE_ENV_NAME="contribs$((Get-Random -Minimum 1000 -Maximum 9999))"
  2. Run the following command to deploy the app to Azure:

    azd up -e $AZURE_ENV_NAME

    Follow the instruction for the rest of the deployment process.