Skip to content

Commit 8cdafb8

Browse files
authored
Abzu 197389 cd printing (#249)
* Abzu-197389-Added azure table to store AIO job configuration - Added `azurerm_storage_table` resource for AIO configurations in Terraform. - Introduced new output variables for storage account access key and connection string. - Added variables for AIO job configurations in `variables.tf`. - Updated `main.tf` to include AIO weekly and printing configurations. - Added `InsertAioJobConfigurationEntityInTable` job in `app-deploy.yml`. - Enhanced `continuous-deployment.yml` with steps for AIO job variables and config transformations. - Updated `build-test-publish.yml` for publishing AIO Fulfilment Service code. - Modified `terraform_conditional_run.ps1` to set new output variables. - Updated `Program.cs` to include `Microsoft.Extensions.Azure` and configuration adjustments. - Added AIO job configuration properties to `appsettings.json`. - Changed schedule in `settings.job`. - Updated `FssServiceTests.cs` to mock `IAzureTableStorageHelper`. - Added properties to `AzureStorageConfiguration.cs` for AIO table names. - Enhanced `AzureTableStorageHelper.cs` to use new table names and fetch AIO job configurations. - Updated `FssService.cs` to use `IAzureTableStorageHelper` for AIO configurations. - Added `AioJobConfigurationEntities` class for AIO job entities in Azure Table Storage. - Minor formatting and consistency adjustments across various files. * Update storage, variables, and CI configuration - Updated `azurerm_storage_account` resource `pos_storage` to include an additional subnet ID in `virtual_network_subnet_ids`. - Modified `azurerm_storage_table` resource `aio_config_table` to use `var.aio_config_table_name` for its `name` attribute. - Updated `agent_2204_subnet` variable and renamed `table_name` to `aio_config_table_name` in `variables.tf`. - Removed `aio_weekly_configuration` and `aio_printing_configuration` variables from `webapp_service` module in `main.tf` and added `aio_config_table_name`. - Updated `continuous-deployment.yml` to remove environment variables related to `aio_weekly_configuration` and `aio_printing_configuration`, and added `TF_VAR_aio_config_table_name`. * Add tests for CreateBatch and clean up code Added new test cases in `FssServiceTests.cs` to verify the `CreateBatch` method for different batch types and configurations. Updated `using` directives in `FssServiceTests.cs` and `AzureTableStorageHelper.cs` to include necessary namespaces and remove unused ones. Removed a commented-out constant in `AzureTableStorageHelper.cs`. Cleaned up `AioJobConfigurationEntities.cs` by removing unnecessary `using` directives. Marked `AddBatchAttributesForAio` method in `FssService.cs` with `[ExcludeFromCodeCoverage]`. * Updated product version details table in app setting and schedule time in settings.job
1 parent 486339a commit 8cdafb8

File tree

19 files changed

+315
-38
lines changed

19 files changed

+315
-38
lines changed

Deployment/src/Modules/Storage/main.tf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ resource "azurerm_storage_account" "pos_storage" {
1515
}
1616
}
1717

18+
resource "azurerm_storage_table" "aio_config_table" {
19+
name = var.aio_config_table_name
20+
storage_account_name = azurerm_storage_account.pos_storage.name
21+
}
22+
1823
resource "azurerm_storage_account" "bess_storage" {
1924
name = lower("${var.service_name_bess}${var.env_name}storageukho")
2025
resource_group_name = var.resource_group_name
@@ -35,4 +40,5 @@ resource "azurerm_storage_account" "bess_storage" {
3540
resource "azurerm_storage_container" "bess_config_container" {
3641
name = var.container_name
3742
storage_account_name = azurerm_storage_account.bess_storage.name
38-
}
43+
}
44+

Deployment/src/Modules/Storage/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ output pos_storage_name {
22
value = azurerm_storage_account.pos_storage.name
33
}
44

5+
output pos_storage_access_key {
6+
value = azurerm_storage_account.pos_storage.primary_access_key
7+
sensitive = true
8+
}
9+
510
output pos_storage_connection_string {
611
value = azurerm_storage_account.pos_storage.primary_connection_string
712
sensitive = true

Deployment/src/Modules/Storage/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,7 @@ variable "agent_2204_subnet" {
4444
variable "agent_prd_subnet" {
4545
type = string
4646
}
47+
48+
variable "aio_config_table_name" {
49+
type = string
50+
}

Deployment/src/main.tf

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,20 @@ locals {
9898
}
9999

100100
module "storage" {
101-
source = "./Modules/Storage"
102-
resource_group_name = azurerm_resource_group.webapp_rg.name
103-
location = azurerm_resource_group.webapp_rg.location
104-
allowed_ips = var.allowed_ips
105-
m_spoke_subnet = data.azurerm_subnet.main_subnet.id
106-
mock_spoke_subnet = local.mock_main_subnet_id
107-
agent_2204_subnet = var.agent_2204_subnet
108-
agent_prd_subnet = var.agent_prd_subnet
109-
env_name = local.env_name
110-
service_name = local.service_name
111-
service_name_bess = local.service_name_bess
112-
container_name = local.container_name
113-
tags = local.tags
101+
source = "./Modules/Storage"
102+
resource_group_name = azurerm_resource_group.webapp_rg.name
103+
location = azurerm_resource_group.webapp_rg.location
104+
allowed_ips = var.allowed_ips
105+
m_spoke_subnet = data.azurerm_subnet.main_subnet.id
106+
mock_spoke_subnet = local.mock_main_subnet_id
107+
agent_2204_subnet = var.agent_2204_subnet
108+
agent_prd_subnet = var.agent_prd_subnet
109+
env_name = local.env_name
110+
service_name = local.service_name
111+
service_name_bess = local.service_name_bess
112+
container_name = local.container_name
113+
tags = local.tags
114+
aio_config_table_name = var.aio_config_table_name
114115
}
115116

116117
module "key_vault" {

Deployment/src/outputs.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@ output "pos_storage_name" {
3838
value = module.storage.pos_storage_name
3939
}
4040

41+
output pos_storage_access_key {
42+
value = module.storage.pos_storage_access_key
43+
sensitive = true
44+
}
45+
4146
output "pos_storage_connection_string"{
4247
value = module.storage.pos_storage_connection_string
4348
sensitive = true

Deployment/src/variables.tf

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,8 @@ variable "agent_prd_subnet" {
8181
variable "BessContainerName" {
8282
type = string
8383
}
84+
85+
variable "aio_config_table_name" {
86+
type = string
87+
default = "aiojobconfiguration"
88+
}

Deployment/templates/app-deploy.yml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,33 @@ jobs:
3030
AzureSubscription: ${{parameters.AzureSubscription}}
3131
RunTests: ${{parameters.RunTests}}
3232

33+
- job: InsertAioJobConfigurationEntityInTable
34+
displayName: "Insert AIO job configuration in Table"
35+
dependsOn: DeployApp
36+
variables:
37+
- name: AccountName
38+
value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.AioAzureStorageAccountName'] ]
39+
- name: AccountKey
40+
value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.AioAzureStorageAccountKey'] ]
41+
steps:
42+
- task: AzureCLI@2
43+
displayName: "Insert Weekly job configuration in Table"
44+
inputs:
45+
azureSubscription: ${{parameters.AzureSubscription}}
46+
scriptType: 'pscore'
47+
scriptLocation: 'inlineScript'
48+
inlineScript: |
49+
az storage entity insert --entity PartitionKey=weekly RowKey=$(AioJobIdWeekly) BusinessUnit=$(AioJobIdWeekly.BusinessUnit) ReadUsers=$(AioJobIdWeekly.ReadUser) ReadGroups=$(AioJobIdWeekly.ReadGroup) IsEnabled=true IsEnabled@odata.type=Edm.Boolean WeeksToIncrement=$(AioJobIdWeekly.WeeksToIncrement) WeeksToIncrement@odata.type=Edm.Int32 --account-name $(AccountName) --account-key $(AccountKey) --if-exists replace --table-name $(AioJobConfigurationTableName)
50+
51+
- task: AzureCLI@2
52+
displayName: "Insert Printing job configuration in Table"
53+
inputs:
54+
azureSubscription: ${{parameters.AzureSubscription}}
55+
scriptType: 'pscore'
56+
scriptLocation: 'inlineScript'
57+
inlineScript: |
58+
az storage entity insert --entity PartitionKey=printing RowKey=$(AioJobIdPrinting) BusinessUnit=$(AioJobIdPrinting.BusinessUnit) ReadUsers=$(AioJobIdPrinting.ReadUser) ReadGroups=$(AioJobIdPrinting.ReadGroup) IsEnabled=true IsEnabled@odata.type=Edm.Boolean WeeksToIncrement=$(AioJobIdPrinting.WeeksToIncrement) WeeksToIncrement@odata.type=Edm.Int32 --account-name $(AccountName) --account-key $(AccountKey) --if-exists replace --table-name $(AioJobConfigurationTableName)
59+
3360
- job: CheckInfra
3461
displayName: "Check Infrastructure Health"
3562
dependsOn: DeployApp
@@ -81,6 +108,8 @@ jobs:
81108
filePath: '$(Build.SourcesDirectory)/Deployment/check_health_endpoint.ps1'
82109
arguments: "-healthEndPointUrl $(FMHealthEndpoint)/health-check -waitTimeInMinute $(waitTimeInMinute)"
83110

111+
112+
84113
- job: Setup
85114
displayName: "Set Webjob Configuration"
86115
condition: not(${{parameters.RunTests}}) # Run only if tests are not running
@@ -277,4 +306,4 @@ jobs:
277306
scriptType: 'pscore'
278307
scriptLocation: 'scriptPath'
279308
scriptPath: "$(Build.SourcesDirectory)/terraformartifact/swap_container_config.ps1"
280-
arguments: '-containername $(BessContainerForWebjob) -resourcegroup $(RGName) -webappname $(WEB_APP_NAME)'
309+
arguments: '-containername $(BessContainerForWebjob) -resourcegroup $(RGName) -webappname $(WEB_APP_NAME)'

Deployment/templates/build-test-publish.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,17 @@ jobs:
140140
zipAfterPublish: false
141141
modifyOutputPath: false
142142

143+
- task: DotNetCoreCLI@2
144+
displayName: "Publish AIO Fulfilment Service Code"
145+
inputs:
146+
command: "publish"
147+
publishWebProjects: false
148+
projects: "**/*UKHO.AdmiraltyInformationOverlay.Fulfilment.csproj"
149+
arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\App_Data\jobs\triggered\AIOFulfilmentWebJobPrinting'
150+
zipAfterPublish: false
151+
modifyOutputPath: false
152+
153+
143154
- task: DotNetCoreCLI@2
144155
displayName: "Publish BESS Configuration Service Code"
145156
inputs:
@@ -365,4 +376,4 @@ jobs:
365376
displayName: "Publish PKSWireMock WebAPI Artifact"
366377
inputs:
367378
PathtoPublish: '$(Build.ArtifactStagingDirectory)\PKSWireMockWebAPI'
368-
ArtifactName: PKSWireMockWebAPI
379+
ArtifactName: PKSWireMockWebAPI

Deployment/templates/continuous-deployment.yml

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ steps:
3333
TF_VAR_agent_2204_subnet: $(agent2204SubnetId)
3434
TF_VAR_agent_prd_subnet: $(agentprdSubnetId)
3535
TF_VAR_BessContainerName: $(BessContainerForWebjob)
36+
TF_VAR_aio_config_table_name: $(AioJobConfigurationTableName)
3637

3738
- task: FileTransform@2
3839
displayName: "File Transform: Mock API WebApp"
@@ -66,7 +67,47 @@ steps:
6667
inputs:
6768
folderPath: '$(Pipeline.Workspace)/PeriodicOutputService/*.zip'
6869
xmlTransformationRules:
69-
jsonTargetFiles: '**/appsettings.json'
70+
jsonTargetFiles: |
71+
**/POS*/appsettings.json
72+
**/BESS*/appsettings.json
73+
74+
- bash: |
75+
echo "##vso[task.setvariable variable=schedule]$(AioJobIdWeekly.Schedule)"
76+
echo "##vso[task.setvariable variable=AioJobId]$(AioJobIdWeekly)"
77+
echo "##vso[task.setvariable variable=AzureStorageConfiguration.AioProductVersionDetailsTableName]$(AioJobIdWeekly.AioProductVersionDetailsTableName)"
78+
echo "##vso[task.setvariable variable=FSSApiConfiguration.AioBusinessUnit]$(AioJobIdWeekly.BusinessUnit)"
79+
echo "##vso[task.setvariable variable=FSSApiConfiguration.AioPosReadGroups]$(AioJobIdWeekly.ReadGroup)"
80+
echo "##vso[task.setvariable variable=FSSApiConfiguration.AioPosReadUsers]$(AioJobIdWeekly.ReadUser)"
81+
echo "##vso[task.setvariable variable=WeeksToIncrement]$(AioJobIdWeekly.WeeksToIncrement)"
82+
displayName: "Set AIO weekly job variables"
83+
84+
- task: FileTransform@2
85+
displayName: "File Transform: AIO weekly settings Config"
86+
inputs:
87+
folderPath: '$(Pipeline.Workspace)/PeriodicOutputService/*.zip'
88+
xmlTransformationRules:
89+
jsonTargetFiles: |
90+
**/AIOFulfilmentWebJob/settings.job
91+
**/AIOFulfilmentWebJob/appsettings.json
92+
93+
- bash: |
94+
echo "##vso[task.setvariable variable=schedule]$(AioJobIdPrinting.Schedule)"
95+
echo "##vso[task.setvariable variable=AioJobId]$(AioJobIdPrinting)"
96+
echo "##vso[task.setvariable variable=AzureStorageConfiguration.AioProductVersionDetailsTableName]$(AioJobIdPrinting.AioProductVersionDetailsTableName)"
97+
echo "##vso[task.setvariable variable=FSSApiConfiguration.AioBusinessUnit]$(AioJobIdPrinting.BusinessUnit)"
98+
echo "##vso[task.setvariable variable=FSSApiConfiguration.AioPosReadGroups]$(AioJobIdPrinting.ReadGroup)"
99+
echo "##vso[task.setvariable variable=FSSApiConfiguration.AioPosReadUsers]$(AioJobIdPrinting.ReadUser)"
100+
echo "##vso[task.setvariable variable=WeeksToIncrement]$(AioJobIdPrinting.WeeksToIncrement)"
101+
displayName: "Set AIO printing job variables"
102+
103+
- task: FileTransform@2
104+
displayName: "File Transform: AIO printing settings Config"
105+
inputs:
106+
folderPath: '$(Pipeline.Workspace)/PeriodicOutputService/*.zip'
107+
xmlTransformationRules:
108+
jsonTargetFiles: |
109+
**/AIOFulfilmentWebJobPrinting/settings.job
110+
**/AIOFulfilmentWebJobPrinting/appsettings.json
70111
71112
- task: AzureWebApp@1
72113
displayName: "Azure LXS App Deploy: pos-$(Environment)-lxs-webapp"

Deployment/templates/variables.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ variables:
1717
- name: "ESSApiConfiguration.AutoTestClientSecret"
1818
value: $(AutoTestClientSecret_Authed)
1919
- name: "ESSApiConfiguration.EssClientId"
20-
value: $(ESSClientId)
20+
value: $(ESSClientId)

0 commit comments

Comments
 (0)