Skip to content

equinor/SubSurfAppManagementMonitoringNuGet

Repository files navigation

intro-logo

SCM Compliance

SubsurfAppManagementMonitoringNuget contains software designed to be impemented by APIs that are to be integrated with our monitoring solution.

This package is first and foremost for our own Amplify applications (with some exceptions). If you have an issue or find any bugs, create an issue in Github as we don't accept PRs from contributors outside of the Amplify team.

SubsurfAppManagementMonitoringNuget

About

This Repository is a nuget package responsible standardizing HVS (Health Vulnerability and security) for subsurface applications. The package is hosted in the github registry.

github nuget registry documentation

Setup

Personal access token

The personal access token is used in place of password when pulling/pushing nuget packages with github.

Generate personal access token in github

Note: This only applies if you haven't got a PAT token with the permissions as listed below with authorization to Equinor. If you do then feel free to you that one instead of creating another one.

settings -> developer settings -> personal access token -> Tokens (classic) -> generate new classic token and select the package read premissions.

then configure SSO and authorize it for equinor.

Adding github to your nuget sources

to equinors github as a nuget source with the dotnet cli run:

dotnet nuget add source https://nuget.pkg.github.com/equinor/index.json -n equinor -u GITHUB_USERNAME -p PERSONAL_ACCESS_TOKEN --store-password-in-clear-text

Replace PERSONAL_ACCESS_TOKEN with the value of your personal access token, generated by GitHub. Replace GITHUB_USERNAME with your GitHub username.

How to use

Assumptions

  • Assumes you are using Application Insight and that it is configured for recieving telemetry with for example:
services.AddApplicationInsightsTelemetry(Configuration);

Configure services:

  • Use the Configure method:
Equinor.SubSurfAppManagementMonitoringNuGet.Configure(services, Configuration);

This will ensure that necessary Telemetry is sent to Application Insights

Steps for HealthChecks

This AddDefaultHealthController extension method is designed to simplify the integration of a default health checker service into your application. It registers the necessary components and provides health-checking capabilities with a controller endpoint

  • In your Startup.cs or Program.cs (depending on your project type), add one of the health checkers (controllers) to the IServiceCollection: Example:
services.AddDefaultHealthController(Configuration, Configuration["ApplicationConfig:AppName"]!)
  .AddSqlServer(....
  • If you are using some of the default HealthCheckServices such as the SmdaHealthCheck you need to create an implementation of the IAccessTokenService Example:
    public class TempTokenService : IAccessTokenService
    {
        private readonly someTokenService _someTokenService;
        public TempTokenService(SomeTokenService someTokenService)
        {
            _someTokenService = someTokenService;
        }
        public async Task<string> GetAccessTokenAsync(string resourceId)
        {
            return await _someTokenService.GetAccessTokenAsync(resourceId);
        }

        public async Task<string> GetAccessTokenOnBehalfOfAsync(string resourceId)
        {
            return await _someTokenService.GetAccessTokenOnBehalfOfAsync(resourceId);
        }
    }
  • Example how to use:
.AddSmdaHealthChecks<TempTokenService>(
                    requestUrl: Configuration["SmdaApi:ApiUrl"]!,
...

Uploading new version of the nuget package

In the github repository, Click Create new release. Create a tag in the fromat v#.#.#, where # are one or more numbers. Upon publishing the release Github actions will pack and upload a new package with version v#.#.#.

Dockerfile

In the dockerfile Make sure to add the nuget source before runnning dotnet restore. GIT_USER is your github username, and GIT_TOKEN_NUGET_READ is your github classic token with at least nuget read premissions. like shown below you also need to decode from base64 because thats how radix passes build secrets.

# ADD nuget source
ARG GIT_TOKEN_NUGET_READ
ARG GIT_USER
RUN TOKEN=$(echo $GIT_TOKEN_NUGET_READ|base64 -d) && \
USER=$(echo $GIT_USER|base64 -d) && \
dotnet nuget add source https://nuget.pkg.github.com/equinor/index.json -n equinor -u $USER -p $TOKEN --store-password-in-clear-text

Radix Configuration

You will need to declere GIT_USER and GIT_TOKEN_NUGET_READ as build secrets in the radixconfig.yaml

apiVersion: radix.equinor.com/v1
kind: RadixApplication
metadata:
  name: ...
spec:
  build:
    secrets:
      - GIT_TOKEN_NUGET_READ
      - GIT_USER
  environments:
  ...

Preview Release

To make a preview release create a release with a tag in the following format v#.#.#-preview#.#.#.

About

No description, website, or topics provided.

Resources

License

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Languages