This is the code repository for the NCEA Classifier Microservice codebase.
| Endpoint | Method | Parameters | Usage | |
|---|---|---|---|---|
| /api/vocabulary | GET | Returns Classifier Hierarchy with all levels | BE ETL Enricher Service | |
| /api/classifiers | GET | Level={int | required}, Parents={string | optional} |
- Both the endpoints are Azure Entra ID Protected
- HealthCheck Endpoint : /api/isAlive
| Table Name | Column Names | Remark |
|---|---|---|
| Themes | Id, Code, Name Definition, CreatedAt, UpdatedAt | |
| Categories | Id, Code, Name Definition, ThemeCode, CreatedAt, UpdatedAt | |
| SubCategories | Id, Code, Name Definition, CategoryCode, CreatedAt, UpdatedAt | |
| SearchPageContnetBlocks | Id, Key, Value, ThemeCode, Step, CreatedAt, UpdatedAt |
-
dotnet ef migrations add InitialCreate --project ncea-classifier-microservice-data -s ncea-classifier-microservice --context AppDbContext
-
dotnet ef migrations remove --project ncea-classifier-microservice-data -s ncea-classifier-microservice --context AppDbContext
-
dotnet ef database update --project ncea-classifier-microservice-data -s ncea-classifier-microservice --context AppDbContext
Before proceeding, ensure you have the following installed:
- .NET 8 SDK: You can download and install it from dotnet.microsoft.com.
Database Configurations: ConnectionStrings to connect to Azure PostgreSQL database, to store and retrieve classifier vocabulary
"ConnectionStrings": {
"DefaultConnection": "Server=[Azure Postgres Database Instance Name].postgres.database.azure.com;Database=ncea-classifier;Port=5432;Username=[username];Ssl Mode=Require"
},
KeyVault Configurations: KeyVaultUri to access Azure KeyVault and to access secrets and connection strings.
"KeyVaultUri": "https://[Azure KeyVault Name].vault.azure.net/"
ApplicationInsights Configuration: ApplicationInsights to enable logging and monitoring.
"ApplicationInsights": {
"LogLevel": {
"Default": "Trace",
"System": "Trace",
"Microsoft": "Trace",
"Microsoft.Hosting.Lifetime": "Information",
"System.Net.Http.HttpClient": "Trace"
}
}
"Logging": {
"LogLevel": {
"Default": "Trace",
"System": "Trace",
"Microsoft": "Trace",
"Microsoft.Hosting.Lifetime": "Information",
"System.Net.Http.HttpClient": "Trace"
}
}
Configurations to connect
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "Enter_the_AzureADTenanat_Id_Here",
"ClientId": "Enter_the_Application_Id_Here",
"Scopes": "Api.Read Api.Write"
}
The variables on helm Chart value file (ncea-classifier-ms\values\values.yaml) will be replaced during Helm Deploy with environment specific values
| Variable name | Variable Group | Notes |
|---|---|---|
| containerRepositoryFullPath | classifierMicroserviceVariables | |
| imageTag | imageTag value is calculated dynamically variables-global.yml file | |
| serviceAccountEnricher | classifierMicroserviceVariables | |
| keyVaultUri | azureVariables | |
| autoScalingEnabled | classifierMicroserviceVariables | |
| autoScalingReplicas | classifierMicroserviceVariables | |
| hostName | classifierMicroserviceVariables |
-
azure-pipelines.yaml
-
Stage : Build
-
steps-build-and-test.yaml
- task: UseDotNet@2 | version: '8.x'
- task: DotNetCoreCLI@2 | command: 'restore'
- task: DotNetCoreCLI@2 | command: 'build'
- task: DotNetCoreCLI@2 | command: 'dotnet test'
- task: PublishCodeCoverageResults@1 | codeCoverageTool: 'Cobertura'
- task: SonarCloudAnalyze@1
- task: SonarCloudPublish@1
-
steps-build-and-push-docker-images.yaml
- task: AzureCLI@2 | To build and push docker images to DEV ACR
-
steps-package-and-push-helm-charts.yaml
- task: HelmDeploy@0 | command: package
- task: PublishPipelineArtifact@1 | Saves the Helm Chart as Pipeline Artifact
-
-
Stage : dev
- steps-deploy-helm-charts.yaml
- task: DownloadPipelineArtifact@2 | Downloads Helm Chart
- task: ExtractFiles@1 | Extracts files from Helm Chart
- task: HelmDeploy@0 | command: 'upgrade'
- steps-deploy-helm-charts.yaml
-
Stage : tst
- steps-deploy-helm-charts.yaml
- task: DownloadPipelineArtifact@2 | Downloads Helm Chart
- task: ExtractFiles@1 | Extracts files from Helm Chart
- task: HelmDeploy@0 | command: 'upgrade'
- steps-deploy-helm-charts.yaml
-
Stage : pre
-
steps-import-docker-images.yaml
- task: AzureCLI@2 | Import Docker Image from Dev ACR to Pre ACR
-
steps-deploy-helm-charts.yaml
- task: DownloadPipelineArtifact@2 | Downloads Helm Chart
- task: ExtractFiles@1 | Extracts files from Helm Chart
- task: HelmDeploy@0 | command: 'upgrade'
-
- dev: AZR-NCE-DEV1
- tst: AZR-NCE-TST
- pre: AZR-NCE-PRE
- dev | tst : DEFRA-COMMON-ubuntu2204-SSV3
- pre : DEFRA-COMMON-ubuntu2204-SSV5
pipelineVariables
- acrConatinerRegistry
- acrContainerRegistryPre
- acrContainerRegistryPreShort
- acrContainerRegistryDevResourceId
- acrContainerRepositoryClassifierMicroservice
- acrName
- acrUser
- acrResourceGroupName
- azureSubscriptionDev
- azureSubscriptionTest
- azureSubscriptionPre
- sonarCloudOrganization
- sonarProjectKeyClassifierMicroservice
- sonarProjectNameClassifierMicroservice
azureVariables-[dev/test/sandbox/...]
- aksNamespace
- aksResourceGroupName
- acrResourceGroupName
- aksClusterName
- keyVaultUri
EnricherServiceVariables-[dev/test/sandbox/...]
- autoScalingEnabled
- autoScalingReplicas
- classifierApiBaseUri
- containerRepostitoryFullPath
- serviceAccountEnricher
-
At present, Classifier API uses API Key Authentication. And the API keys are stored on Azure KeyVaults in respective environments.
-
In future, To enable Azure AD/ OAUTH authentications use the following AppSettings.
-
Futher details available on User Story 448011: Implement OAUTH Security for Classifier API.
-
You can find the branch name and draft PR details in the comment section of this user story
Configurations to enable AzureAD Authentication for classifier api. Client Id and Client Secrets are stored Azure KeyVault and dynamically replaced during runtime. And the Tenant Id will be set as via Azure Pipleine variables during deployment.
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "Enter_the_AzureADTenanat_Id_Here",
"ClientId": "Enter_the_Application_Id_Here",
"Scopes": "Api.Read Api.Write"
}