Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Azure_Pipelines/_deploy_all_services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ jobs:
repoName: dataacquisition-worker
containerName: data-worker
healthUrl: https://$(env)-data.nhsnlink.org/health
dmrp:
serviceName: dmrp
repoName: dmrp
containerName: dmrp
healthUrl: https://$(env)-dmrp.nhsnlink.org/health
measure-eval:
serviceName: measure
repoName: measureeval
Expand Down
103 changes: 103 additions & 0 deletions Azure_Pipelines/azure-pipelines.dmrp.cd.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
resources:
pipelines:
- pipeline: pipeline-trigger
source: Build_And_Push_All
trigger: true

trigger:
branches:
include:
- dev
- release/*
- linkathon/*
paths:
include:
- DotNet/DMRP/*
- DotNet/Shared/*
exclude:
- '*'

pr: none

pool:
vmImage: 'ubuntu-latest'

variables:
- group: link-cloud-variables
- name: project
value: 'DotNet/DMRP/DMRP.csproj'
- name: testProject
value: 'DotNet/ServiceTests/ServiceTests.csproj'
- name: registry-repo-Name
value: 'link-dmrp'
- name: dockerPath
value: '**/DotNet/DMRP/Dockerfile'
- name: serviceName
value: 'DMRP'
- name: projectDir
value: 'DotNet/DMRP'

steps:
- task: DotNetCoreCLI@2
displayName: Restore
inputs:
command: restore
projects: '$(project)'

- task: Bash@3
inputs:
targetType: 'inline'
script: |
GIT_COMMIT=$(git rev-parse --short HEAD)
echo "GIT_COMMIT: ${GIT_COMMIT}"
echo "##vso[task.setvariable variable=GIT_COMMIT]${GIT_COMMIT}"

- task: PythonScript@0
displayName: "Inject Service Info"
inputs:
scriptSource: 'filePath'
scriptPath: '$(Build.SourcesDirectory)/Scripts/set_service_info.py'
workingDirectory: '$(Build.SourcesDirectory)'
arguments: './ "$(projectDir)" "$(GIT_COMMIT)" "$(Build.BuildNumber)"'

- task: DotNetCoreCLI@2
displayName: Build
inputs:
command: build
projects: '$(project)'

- task: DotNetCoreCLI@2
inputs:
command: 'test'
projects: '$(testProject)'
displayName: 'Run Tests'

- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
if ("$(Build.SourceBranch)" -like "*release/*") {
$myTag1 = "release-$(Build.SourceBranchName)-$(GIT_COMMIT)"
}
else {
$myTag1 = "$(Build.SourceBranchName)-$(GIT_COMMIT)"
}
Write-Host "##vso[task.setvariable variable=MyTag]$myTag1"
Write-Host "Set MyTag to: $myTag1"
- task: Docker@2
displayName: "Build & Push DMRP Docker Image"
condition: always()
inputs:
containerRegistry: $(containerRegistry) # Variable Group
repository: $(registry-repo-name)
command: 'buildAndPush'
Dockerfile: $(dockerPath)
tags: |
latest
$(MyTag)
buildContext: '$(Build.Repository.LocalPath)'

Comment thread
smailliwcs marked this conversation as resolved.
Outdated
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifact: 'manifest'
1 change: 1 addition & 0 deletions Azure_Pipelines/deploy_tags_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ parameters:
- Census
- DataAcquisition
# - Demo-app
- DMRP
# - Measureeval
- Normalization
- Notification
Expand Down
65 changes: 65 additions & 0 deletions DotNet/Admin.BFF/Application/Clients/DmrpService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
ο»Ώusing LantanaGroup.Link.LinkAdmin.BFF.Application.Models.Health;
using LantanaGroup.Link.LinkAdmin.BFF.Infrastructure.Logging;
using LantanaGroup.Link.Shared.Application.Models.Configs;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Options;
using System.Net.Http.Headers;

namespace LantanaGroup.Link.LinkAdmin.BFF.Application.Clients
{
public class DmrpService
{
private readonly ILogger<DmrpService> _logger;
private readonly HttpClient _client;
private readonly IOptions<ServiceRegistry> _serviceRegistry;

public DmrpService(ILogger<DmrpService> logger, HttpClient client, IOptions<ServiceRegistry> serviceRegistry)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_client = client ?? throw new ArgumentNullException(nameof(client));
_serviceRegistry = serviceRegistry ?? throw new ArgumentNullException(nameof(serviceRegistry));

InitHttpClient();
}

public async Task<HttpResponseMessage> ServiceHealthCheck(CancellationToken cancellationToken)
{
// HTTP GET
HttpResponseMessage response = await _client.GetAsync($"health", cancellationToken);

return response;
}

public async Task<LinkServiceHealthReport> LinkServiceHealthCheck(CancellationToken cancellationToken)
{
// HTTP GET
try
{
var response = await _client.GetAsync($"health", cancellationToken);
var healthResult = await response.Content.ReadFromJsonAsync<LinkServiceHealthReport>(cancellationToken: cancellationToken);
if (healthResult is not null) healthResult.Service = "DMRP";

return healthResult;
}
catch (Exception ex)
{
_logger.LogError(ex, "DMRP service health check failed");
return new LinkServiceHealthReport { Service = "DMRP", Status = HealthStatus.Unhealthy };
}
}

private void InitHttpClient()
{
//check if the service uri is set
if (string.IsNullOrEmpty(_serviceRegistry.Value.DmrpServiceUrl))
{
_logger.LogGatewayServiceUriException("DMRP", "DMRP service uri is not set");
throw new ArgumentNullException("DMRP Service URL is missing.");
}

_client.BaseAddress = new Uri(_serviceRegistry.Value.DmrpServiceUrl);
_client.DefaultRequestHeaders.Accept.Clear();
_client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public static IServiceCollection AddLinkClients(this IServiceCollection services
services.AddHttpClient<AuditService>();
services.AddHttpClient<CensusService>();
services.AddHttpClient<DataAcquisitionService>();
services.AddHttpClient<DmrpService>();
services.AddHttpClient<MeasureEvalService>();
services.AddHttpClient<NormalizationService>();
services.AddHttpClient<NotificationService>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public ValueTask<ClusterConfig> ConfigureClusterAsync(ClusterConfig origCluster,
"AuditService" => _serviceRegistry.AuditServiceUrl ?? string.Empty,
"CensusService" => _serviceRegistry.CensusServiceUrl ?? string.Empty,
"DataAcquisitionService" => _serviceRegistry.DataAcquisitionServiceUrl ?? string.Empty,
"DmrpService" => _serviceRegistry.DmrpServiceUrl ?? string.Empty,
"MeasureEvaluationService" => _serviceRegistry.MeasureServiceUrl ?? string.Empty,
"NormalizationService" => _serviceRegistry.NormalizationServiceUrl ?? string.Empty,
"NotificationService" => _serviceRegistry.NotificationServiceUrl ?? string.Empty,
Expand Down
47 changes: 47 additions & 0 deletions DotNet/Admin.BFF/Infrastructure/Health/DmrpServiceHealthCheck.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
ο»Ώusing LantanaGroup.Link.LinkAdmin.BFF.Application.Clients;
using LantanaGroup.Link.LinkAdmin.BFF.Infrastructure.Logging;
using Microsoft.Extensions.Diagnostics.HealthChecks;

namespace LantanaGroup.Link.LinkAdmin.BFF.Infrastructure.Health
{
public class DmrpServiceHealthCheck : IHealthCheck
{
private readonly ILogger<DmrpServiceHealthCheck> _logger;
private readonly DmrpService _dmrpService;

public DmrpServiceHealthCheck(ILogger<DmrpServiceHealthCheck> logger, DmrpService dmrpService)
{
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_dmrpService = dmrpService ?? throw new ArgumentNullException(nameof(dmrpService));
}

public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = default)
{
try
{
// make a request to the DMRP service health check
var response = await _dmrpService.ServiceHealthCheck(cancellationToken);

if (response.IsSuccessStatusCode)
{
return HealthCheckResult.Healthy();
}
else
{
return new HealthCheckResult(HealthStatus.Unhealthy, description: "DMRP service is not healthy");
}

}
catch (HttpRequestException ex)
{
_logger.LogLinkServiceRequestException("DMRP", ex.Message);
return new HealthCheckResult(HealthStatus.Unhealthy, description: "HTTP request error.");
}
catch (Exception ex)
{
_logger.LogLinkServiceRequestException("DMRP", ex.Message);
return new HealthCheckResult(HealthStatus.Unhealthy, description: "Failed to determine health status of the DMRP service.");
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public static async Task<IResult> Handle(HttpContext context,
AuditService auditService,
CensusService censusService,
DataAcquisitionService dataAcquisitionService,
DmrpService dmrpService,
NormalizationService normalizationService,
QueryDispatchService queryDispatchService,
ReportService reportService,
Expand All @@ -28,6 +29,7 @@ public static async Task<IResult> Handle(HttpContext context,
auditService.LinkServiceHealthCheck(context.RequestAborted),
censusService.LinkServiceHealthCheck(context.RequestAborted),
dataAcquisitionService.LinkServiceHealthCheck(context.RequestAborted),
dmrpService.LinkServiceHealthCheck(context.RequestAborted),
normalizationService.LinkServiceHealthCheck(context.RequestAborted),
queryDispatchService.LinkServiceHealthCheck(context.RequestAborted),
reportService.LinkServiceHealthCheck(context.RequestAborted),
Expand Down
6 changes: 6 additions & 0 deletions DotNet/Admin.BFF/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ static void RegisterServices(WebApplicationBuilder builder)
.AddCheck<AuditServiceHealthCheck>(nameof(HealthCheckType.Service))
.AddCheck<CensusServiceHealthCheck>(nameof(HealthCheckType.Service))
.AddCheck<DataAcquisitionHealthCheck>(nameof(HealthCheckType.Service))
.AddCheck<DmrpServiceHealthCheck>(nameof(HealthCheckType.Service))
.AddCheck<MeasureEvaluationServiceHealthCheck>(nameof(HealthCheckType.Service))
.AddCheck<NormalizationServiceHealthCheck>(nameof(HealthCheckType.Service))
.AddCheck<NotificationServiceHealthCheck>(nameof(HealthCheckType.Service))
Expand Down Expand Up @@ -438,6 +439,11 @@ static void SetupMiddleware(WebApplication app)
serviceRegistry.PublicDataAcquisitionServiceUrl,
"/data/info", logger));

if (!string.IsNullOrEmpty(serviceRegistry.DmrpServiceApiUrl))
tasks.Add(ServiceInformation.GetServiceInformation(client, "DMRP", serviceRegistry.DmrpServiceApiUrl,
serviceRegistry.PublicDmrpServiceUrl,
"/dmrp/info", logger));

if (!string.IsNullOrEmpty(serviceRegistry.MeasureServiceApiUrl))
tasks.Add(ServiceInformation.GetServiceInformation(client, "Measure Evaluation", serviceRegistry.MeasureServiceApiUrl,
serviceRegistry.PublicMeasureServiceUrl,
Expand Down
2 changes: 2 additions & 0 deletions DotNet/Admin.BFF/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"ServiceRegistry__AuditServiceUrl": "http://localhost:8062",
"ServiceRegistry__CensusServiceUrl": "http://localhost:8064",
"ServiceRegistry__DataAcquisitionServiceUrl": "http://localhost:8065",
"ServiceRegistry__DmrpServiceUrl": "http://localhost:8077",
"ServiceRegistry__MeasureServiceUrl": "http://localhost:8067",
"ServiceRegistry__NormalizationServiceUrl": "http://localhost:8068",
"ServiceRegistry__ReportServiceUrl": "http://localhost:8072",
Expand All @@ -27,6 +28,7 @@
"ReverseProxy__Clusters__AuditService__Destinations__destination1__Address": "http://localhost:8062",
"ReverseProxy__Clusters__CensusService__Destinations__destination1__Address": "http://localhost:8064",
"ReverseProxy__Clusters__DataAcquisitionService__Destinations__destination1__Address": "http://localhost:8065",
"ReverseProxy__Clusters__DmrpService__Destinations__destination1__Address": "http://localhost:8077",
"ReverseProxy__Clusters__MeasureEvaluationService__Destinations__destination1__Address": "http://localhost:8067",
"ReverseProxy__Clusters__NormalizationService__Destinations__destination1__Address": "http://localhost:8068",
"ReverseProxy__Clusters__NotificationService__Destinations__destination1__Address": "http://localhost:8069",
Expand Down
1 change: 1 addition & 0 deletions DotNet/Admin.BFF/appsettings.Development.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"AuditServiceUrl": "http://localhost:7344",
"CensusServiceUrl": "http://localhost:5234",
"DataAcquisitionServiceUrl": "http://localhost:5194",
"DmrpServiceUrl": "http://localhost:8077",
"MeasureServiceUrl": "http://localhost:5135",
"NormalizationServiceUrl": "http://localhost:5038",
"NotificationServiceUrl": "http://localhost:7434",
Expand Down
2 changes: 2 additions & 0 deletions DotNet/Admin.BFF/appsettings.Docker.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
"PublicCensusServiceUrl": "http://localhost:8064",
"DataAcquisitionServiceUrl": "http://dataacq:8065",
"PublicDataAcquisitionServiceUrl": "http://localhost:8065",
"DmrpServiceUrl": "http://dmrp:8077",
"PublicDmrpServiceUrl": "http://localhost:8077",
"MeasureServiceUrl": "http://measureeval:8067",
"PublicMeasureServiceUrl": "http://localhost:8067",
"NormalizationServiceUrl": "http://normalization:8068",
Expand Down
14 changes: 14 additions & 0 deletions DotNet/Admin.BFF/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,13 @@
"Match": {
"Path": "api/terminology/{**catch-all}"
}
},
"route15": {
"ClusterId": "DmrpService",
"AuthorizationPolicy": "AuthenticatedUser",
"Match": {
"Path": "api/dmrp/{**catch-all}"
}
}
},
"Clusters": {
Expand Down Expand Up @@ -290,6 +297,13 @@
}
}
},
"DmrpService": {
"Destinations": {
"destination1": {
"Address": ""
}
}
},
"MeasureEvaluationService": {
"Destinations": {
"destination1": {
Expand Down
Loading
Loading