Skip to content

Latest commit

 

History

History

ActuatorApi

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Steeltoe Management Sample - Actuators, Administrative Tasks, Metrics and Tracing

ActuatorWeb and ActuatorApi form an ASP.NET Core-powered sample application that demonstrates how to use several Steeltoe libraries on their own and with additional tools.

In order to avoid duplicating a significant amount of content, the ActuatorWeb Readme contains the shared information and this document only holds content unique to ActuatorApi.

Running locally

Be sure to follow the ActuatorWeb Readme to the point where that application is running before continuing here.

MySQL

This application depends on a MySQL database. Refer to Common Tasks to start a server that matches the credentials defined in appsettings.Development.json.

Administrative Tasks (initialize the database)

In order to demonstrate Steeltoe Management Tasks, the database schema and its contents are managed as administrative tasks.

  1. Apply Entity Framework Core database schema migration scripts:

    dotnet run --runtask=MigrateDatabase
  2. Run ForecastTask to predict weather for the next 7 days:

    dotnet run --runtask=ForecastWeather

    Optional - Add forecast data starting from a specific date and/or number of days:

    dotnet run --runtask=ForecastWeather --fromDate=10/18/2024 --days=30

Note

For the fromDate parameter, use values formatted as yyyy-dd-MM or MM/dd/yyyy.

Tip

The task ResetTask can be used to remove all forecast data: dotnet run --runtask=ResetWeather

  1. Use your preferred IDE or dotnet run to start the application.

Running on Tanzu Platform for Cloud Foundry

  1. Create a MySQL service instance in an org/space

    cf target -o your-org -s your-space
    • When using VMware MySQL for Tanzu Application Service:

      cf create-service p.mysql db-small sampleMySqlService
    • When using the Cloud Service Broker for Azure:

      cf create-service csb-azure-mysql small sampleMySqlService
    • When using the Cloud Service Broker for GCP:

      cf create-service csb-google-mysql your-plan sampleMySqlService
  2. Wait for the service to become ready (you can check with cf services)

  3. Run the cf push command to deploy from source (you can monitor logs with cf logs actuator-api-management-sample)

    • When deploying to Windows, binaries must be built locally before push. Use the following commands instead:

      dotnet publish -r win-x64 --self-contained
      cf push -f manifest-windows.yml -p bin/Release/net8.0/win-x64/publish
  4. Copy the value of routes in the output and open in your browser. The app should start and respond to requests, but the database still needs to be configured with the tasks listed in the next section.

Note

The provided manifest will create an app named actuator-api-management-sample and attempt to bind it to the MySql service sampleMySqlService.

Running Tasks

Depending on the steps taken to push the application to Cloud Foundry, the commands below may require customization (for example, if the application was not published before pushing to a Linux cell, the path for the command might be ./bin/Debug/net8.0/linux-x64/Steeltoe.Samples.ActuatorApi)

  1. Apply Entity Framework Core database migration scripts:

    cf run-task actuator-api-management-sample --command "./Steeltoe.Samples.ActuatorApi runtask=MigrateDatabase" 
  2. Run ForecastTask to predict weather for the next 7 days:

    cf run-task actuator-api-management-sample --command "./Steeltoe.Samples.ActuatorApi runtask=ForecastWeather" 

Tip

To remove all forecast data, run ResetTask:

cf run-task actuator-api-management-sample --command "./Steeltoe.Samples.ActuatorApi runtask=ResetWeather" 

See the Official Steeltoe Management Documentation for more detailed information.