diff --git a/QALiveDeployment/add-lease.ps1 b/Deployment/add-lease.ps1 similarity index 100% rename from QALiveDeployment/add-lease.ps1 rename to Deployment/add-lease.ps1 diff --git a/DevDeployment/check_health_endpoint.ps1 b/Deployment/check_health_endpoint.ps1 similarity index 100% rename from DevDeployment/check_health_endpoint.ps1 rename to Deployment/check_health_endpoint.ps1 diff --git a/QALiveDeployment/check_health_endpoint_fm_live.ps1 b/Deployment/check_health_endpoint_fm_live.ps1 similarity index 100% rename from QALiveDeployment/check_health_endpoint_fm_live.ps1 rename to Deployment/check_health_endpoint_fm_live.ps1 diff --git a/DevDeployment/check_service_status_webjob.ps1 b/Deployment/check_service_status_webjob.ps1 similarity index 100% rename from DevDeployment/check_service_status_webjob.ps1 rename to Deployment/check_service_status_webjob.ps1 diff --git a/vNextE2EDeployment/mock_api_deployment.ps1 b/Deployment/mock_api_deployment.ps1 similarity index 100% rename from vNextE2EDeployment/mock_api_deployment.ps1 rename to Deployment/mock_api_deployment.ps1 diff --git a/QALiveDeployment/set_stub_configuration.ps1 b/Deployment/set_stub_configuration.ps1 similarity index 100% rename from QALiveDeployment/set_stub_configuration.ps1 rename to Deployment/set_stub_configuration.ps1 diff --git a/Deployment/set_subnet_configuration.ps1 b/Deployment/set_subnet_configuration.ps1 new file mode 100644 index 00000000..589c1fc0 --- /dev/null +++ b/Deployment/set_subnet_configuration.ps1 @@ -0,0 +1,15 @@ +param ( + [Parameter(Mandatory = $true)] [string] $mockresourcegroup, + [Parameter(Mandatory = $true)] [string] $mockwebappname, + [Parameter(Mandatory = $true)] [string] $subscriptionid, + [Parameter(Mandatory = $true)] [string] $vnetresourcegroup, + [Parameter(Mandatory = $true)] [string] $vnetname, + [Parameter(Mandatory = $true)] [string] $subnetname +) + +Write-Output "Set Subnet in Mock Network Configuration ..." +az webapp config access-restriction add -g $mockresourcegroup -n $mockwebappname --action Allow --subnet "/subscriptions/$subscriptionid/resourceGroups/$vnetresourcegroup/providers/Microsoft.Network/virtualNetworks/$vnetname/subnets/$subnetname" --priority 65000 --scm-site false -i + + + + diff --git a/QALiveDeployment/set_webjob_configuration.ps1 b/Deployment/set_webjob_configuration.ps1 similarity index 100% rename from QALiveDeployment/set_webjob_configuration.ps1 rename to Deployment/set_webjob_configuration.ps1 diff --git a/DevDeployment/src/Modules/AppInsights/main.tf b/Deployment/src/Modules/AppInsights/main.tf similarity index 100% rename from DevDeployment/src/Modules/AppInsights/main.tf rename to Deployment/src/Modules/AppInsights/main.tf diff --git a/DevDeployment/src/Modules/AppInsights/outputs.tf b/Deployment/src/Modules/AppInsights/outputs.tf similarity index 100% rename from DevDeployment/src/Modules/AppInsights/outputs.tf rename to Deployment/src/Modules/AppInsights/outputs.tf diff --git a/QALiveDeployment/src/Modules/AppInsights/variables.tf b/Deployment/src/Modules/AppInsights/variables.tf similarity index 100% rename from QALiveDeployment/src/Modules/AppInsights/variables.tf rename to Deployment/src/Modules/AppInsights/variables.tf diff --git a/DevDeployment/src/Modules/EventHub/main.tf b/Deployment/src/Modules/EventHub/main.tf similarity index 100% rename from DevDeployment/src/Modules/EventHub/main.tf rename to Deployment/src/Modules/EventHub/main.tf diff --git a/DevDeployment/src/Modules/EventHub/outputs.tf b/Deployment/src/Modules/EventHub/outputs.tf similarity index 100% rename from DevDeployment/src/Modules/EventHub/outputs.tf rename to Deployment/src/Modules/EventHub/outputs.tf diff --git a/DevDeployment/src/Modules/EventHub/variables.tf b/Deployment/src/Modules/EventHub/variables.tf similarity index 100% rename from DevDeployment/src/Modules/EventHub/variables.tf rename to Deployment/src/Modules/EventHub/variables.tf diff --git a/DevDeployment/src/Modules/KeyVault/main.tf b/Deployment/src/Modules/KeyVault/main.tf similarity index 100% rename from DevDeployment/src/Modules/KeyVault/main.tf rename to Deployment/src/Modules/KeyVault/main.tf diff --git a/DevDeployment/src/Modules/KeyVault/outputs.tf b/Deployment/src/Modules/KeyVault/outputs.tf similarity index 100% rename from DevDeployment/src/Modules/KeyVault/outputs.tf rename to Deployment/src/Modules/KeyVault/outputs.tf diff --git a/DevDeployment/src/Modules/KeyVault/variables.tf b/Deployment/src/Modules/KeyVault/variables.tf similarity index 100% rename from DevDeployment/src/Modules/KeyVault/variables.tf rename to Deployment/src/Modules/KeyVault/variables.tf diff --git a/DevDeployment/src/Modules/MockWebApp/main.tf b/Deployment/src/Modules/MockWebApp/main.tf similarity index 99% rename from DevDeployment/src/Modules/MockWebApp/main.tf rename to Deployment/src/Modules/MockWebApp/main.tf index c1ddf972..4d8125e9 100644 --- a/DevDeployment/src/Modules/MockWebApp/main.tf +++ b/Deployment/src/Modules/MockWebApp/main.tf @@ -94,4 +94,4 @@ resource "azurerm_windows_web_app" "pks_mock_webapp_service" { resource "azurerm_app_service_virtual_network_swift_connection" "pks_mock_webapp_vnet_integration" { app_service_id = azurerm_windows_web_app.pks_mock_webapp_service.id subnet_id = var.subnet_id -} +} \ No newline at end of file diff --git a/DevDeployment/src/Modules/MockWebApp/outputs.tf b/Deployment/src/Modules/MockWebApp/outputs.tf similarity index 99% rename from DevDeployment/src/Modules/MockWebApp/outputs.tf rename to Deployment/src/Modules/MockWebApp/outputs.tf index cbe5fc0f..0a333b7c 100644 --- a/DevDeployment/src/Modules/MockWebApp/outputs.tf +++ b/Deployment/src/Modules/MockWebApp/outputs.tf @@ -8,4 +8,4 @@ output "web_app_tenant_id" { output "default_site_hostname" { value = azurerm_windows_web_app.mock_webapp_service.default_hostname -} +} \ No newline at end of file diff --git a/DevDeployment/src/Modules/MockWebApp/variables.tf b/Deployment/src/Modules/MockWebApp/variables.tf similarity index 100% rename from DevDeployment/src/Modules/MockWebApp/variables.tf rename to Deployment/src/Modules/MockWebApp/variables.tf diff --git a/QALiveDeployment/src/Modules/Storage/main.tf b/Deployment/src/Modules/Storage/main.tf similarity index 92% rename from QALiveDeployment/src/Modules/Storage/main.tf rename to Deployment/src/Modules/Storage/main.tf index 256cc71b..fc0797c2 100644 --- a/QALiveDeployment/src/Modules/Storage/main.tf +++ b/Deployment/src/Modules/Storage/main.tf @@ -28,7 +28,7 @@ resource "azurerm_storage_account" "bess_storage" { default_action = "Deny" ip_rules = var.allowed_ips bypass = ["Logging", "Metrics", "AzureServices"] - virtual_network_subnet_ids = [var.m_spoke_subnet, var.agent_2204_subnet, var.agent_prd_subnet] + virtual_network_subnet_ids = compact([var.m_spoke_subnet, var.mock_spoke_subnet, var.agent_2204_subnet, var.agent_prd_subnet]) } } diff --git a/DevDeployment/src/Modules/Storage/outputs.tf b/Deployment/src/Modules/Storage/outputs.tf similarity index 100% rename from DevDeployment/src/Modules/Storage/outputs.tf rename to Deployment/src/Modules/Storage/outputs.tf diff --git a/DevDeployment/src/Modules/Storage/variables.tf b/Deployment/src/Modules/Storage/variables.tf similarity index 100% rename from DevDeployment/src/Modules/Storage/variables.tf rename to Deployment/src/Modules/Storage/variables.tf diff --git a/DevDeployment/src/Modules/WebApp/main.tf b/Deployment/src/Modules/WebApp/main.tf similarity index 99% rename from DevDeployment/src/Modules/WebApp/main.tf rename to Deployment/src/Modules/WebApp/main.tf index d64f8c94..d111594b 100644 --- a/DevDeployment/src/Modules/WebApp/main.tf +++ b/Deployment/src/Modules/WebApp/main.tf @@ -41,4 +41,4 @@ resource "azurerm_windows_web_app" "webapp_service" { resource "azurerm_app_service_virtual_network_swift_connection" "webapp_vnet_integration" { app_service_id = azurerm_windows_web_app.webapp_service.id subnet_id = var.subnet_id -} +} \ No newline at end of file diff --git a/vNextE2EDeployment/src/Modules/Webapp/outputs.tf b/Deployment/src/Modules/WebApp/outputs.tf similarity index 99% rename from vNextE2EDeployment/src/Modules/Webapp/outputs.tf rename to Deployment/src/Modules/WebApp/outputs.tf index a6b555d0..b82bc82d 100644 --- a/vNextE2EDeployment/src/Modules/Webapp/outputs.tf +++ b/Deployment/src/Modules/WebApp/outputs.tf @@ -17,4 +17,4 @@ output "username" { output "password" { value = azurerm_windows_web_app.webapp_service.site_credential[0].password sensitive = true -} +} \ No newline at end of file diff --git a/vNextE2EDeployment/src/Modules/MockWebApp/variables.tf b/Deployment/src/Modules/WebApp/variables.tf similarity index 82% rename from vNextE2EDeployment/src/Modules/MockWebApp/variables.tf rename to Deployment/src/Modules/WebApp/variables.tf index 1322466d..920f3a09 100644 --- a/vNextE2EDeployment/src/Modules/MockWebApp/variables.tf +++ b/Deployment/src/Modules/WebApp/variables.tf @@ -19,7 +19,6 @@ variable "app_settings" { } variable "tags" { - } variable "env_name" { @@ -30,10 +29,14 @@ variable "subnet_id" { type = string } -variable "main_subnet_id" { - type = string +variable "allowed_ips" { } -variable "allowed_ips" { +variable "agent_2204_subnet" { + type = string +} + +variable "agent_prd_subnet" { + type = string } diff --git a/DevDeployment/src/azure.tf b/Deployment/src/azure.tf similarity index 100% rename from DevDeployment/src/azure.tf rename to Deployment/src/azure.tf diff --git a/DevDeployment/src/main.tf b/Deployment/src/main.tf similarity index 89% rename from DevDeployment/src/main.tf rename to Deployment/src/main.tf index 6c6785a5..d2113ab5 100644 --- a/DevDeployment/src/main.tf +++ b/Deployment/src/main.tf @@ -5,21 +5,12 @@ data "azurerm_subnet" "main_subnet" { } data "azurerm_subnet" "mock_main_subnet" { + count = "${local.env_name}" == "dev" ? 1 : 0 name = var.mock_spoke_subnet_name virtual_network_name = var.spoke_vnet_name resource_group_name = var.spoke_rg } -data "azurerm_app_service_plan" "essft_asp" { - name = "essft-qc-yh3r1-asp" - resource_group_name = "essft-qc-webapp-rg" -} - -data "azurerm_app_service_plan" "ess_asp" { - name = "ess-${local.env_name}-lxs-1-asp" - resource_group_name = "ess-${local.env_name}-rg" -} - module "app_insights" { source = "./Modules/AppInsights" name = "${local.service_name}-${local.env_name}-insights" @@ -37,15 +28,27 @@ module "eventhub" { env_name = local.env_name } +data "azurerm_app_service_plan" "essft_asp" { + count = "${local.env_name}" == "dev" ? 1 : 0 + name = "essft-qc-yh3r1-asp" + resource_group_name = "essft-qc-webapp-rg" +} + +data "azurerm_app_service_plan" "ess_asp" { + name = "ess-${local.env_name}-lxs-1-asp" + resource_group_name = "ess-${local.env_name}-rg" +} + module "mock_webapp_service" { + count = "${local.env_name}" == "dev" ? 1 : 0 source = "./Modules/MockWebApp" name = local.mock_web_app_name pks_name = local.pks_mock_web_app_name env_name = local.env_name resource_group_name = azurerm_resource_group.mock_webapp_rg.name - service_plan_id = data.azurerm_app_service_plan.essft_asp.id + service_plan_id = data.azurerm_app_service_plan.essft_asp[0].id location = azurerm_resource_group.mock_webapp_rg.location - subnet_id = data.azurerm_subnet.mock_main_subnet.id + subnet_id = data.azurerm_subnet.mock_main_subnet[0].id main_subnet_id = data.azurerm_subnet.main_subnet.id app_settings = { "ASPNETCORE_ENVIRONMENT" = local.env_name @@ -65,11 +68,13 @@ module "webapp_service" { env_name = local.env_name location = azurerm_resource_group.webapp_rg.location subnet_id = data.azurerm_subnet.main_subnet.id + agent_2204_subnet = var.agent_2204_subnet + agent_prd_subnet = var.agent_prd_subnet app_settings = { "EventHubLoggingConfiguration:Environment" = local.env_name "EventHubLoggingConfiguration:MinimumLoggingLevel" = "Warning" "EventHubLoggingConfiguration:UkhoMinimumLoggingLevel" = "Information" - "APPINSIGHTS_INSTRUMENTATIONKEY" = module.app_insights.instrumentation_key + "APPLICATIONINSIGHTS_CONNECTION_STRING" = module.app_insights.connection_string "ASPNETCORE_ENVIRONMENT" = local.env_name "WEBSITE_RUN_FROM_PACKAGE" = "1" "WEBSITE_ENABLE_SYNC_UPDATE_SITE" = "true" @@ -90,13 +95,17 @@ module "webapp_service" { allowed_ips = var.allowed_ips } +locals { + mock_main_subnet_id = (length(data.azurerm_subnet.mock_main_subnet) > 0 ? data.azurerm_subnet.mock_main_subnet[0].id : null) +} + module "storage" { source = "./Modules/Storage" resource_group_name = azurerm_resource_group.webapp_rg.name location = azurerm_resource_group.webapp_rg.location allowed_ips = var.allowed_ips m_spoke_subnet = data.azurerm_subnet.main_subnet.id - mock_spoke_subnet = data.azurerm_subnet.mock_main_subnet.id + mock_spoke_subnet = data.azurerm_subnet.mock_main_subnet[0].id agent_2204_subnet = var.agent_2204_subnet agent_prd_subnet = var.agent_prd_subnet env_name = local.env_name @@ -113,7 +122,7 @@ module "key_vault" { env_name = local.env_name tenant_id = module.webapp_service.web_app_tenant_id allowed_ips = var.allowed_ips - allowed_subnet_ids = [data.azurerm_subnet.main_subnet.id, var.agent_2204_subnet,var.agent_prd_subnet] + allowed_subnet_ids = [data.azurerm_subnet.main_subnet.id, var.agent_2204_subnet, var.agent_prd_subnet] location = azurerm_resource_group.webapp_rg.location agent_2204_subnet = var.agent_2204_subnet agent_prd_subnet = var.agent_prd_subnet diff --git a/DevDeployment/src/outputs.tf b/Deployment/src/outputs.tf similarity index 92% rename from DevDeployment/src/outputs.tf rename to Deployment/src/outputs.tf index 4ccaca6d..8113da07 100644 --- a/DevDeployment/src/outputs.tf +++ b/Deployment/src/outputs.tf @@ -7,7 +7,7 @@ output "pks_mock_webappname" { } output "fm_mock_web_app_url" { -value = "https://${module.mock_webapp_service.default_site_hostname}" +value = length(module.mock_webapp_service) > 0 ? "https://${module.mock_webapp_service[0].default_site_hostname}" : null } output "mock_webapp_rg" { diff --git a/vNextE2EDeployment/src/resource-group.tf b/Deployment/src/resource-group.tf similarity index 100% rename from vNextE2EDeployment/src/resource-group.tf rename to Deployment/src/resource-group.tf diff --git a/vNextIATDeployment/src/variables.tf b/Deployment/src/variables.tf similarity index 86% rename from vNextIATDeployment/src/variables.tf rename to Deployment/src/variables.tf index 79627282..2f8ff77f 100644 --- a/vNextIATDeployment/src/variables.tf +++ b/Deployment/src/variables.tf @@ -24,7 +24,7 @@ locals { SERVICE_OWNER = "UKHO" RESPONSIBLE_TEAM = "Abzu" CALLOUT_TEAM = "On-Call_N/A" - COST_CENTRE = "A.008.02" + COST_CENTRE = local.env_name == "dev" || local.env_name == "qa" || local.env_name == "prod" ? "A.008.02" : "A.011.08" } } @@ -40,6 +40,14 @@ variable "spoke_subnet_name" { type = string } +variable "agent_rg" { + type = string +} + +variable "agent_vnet_name" { + type = string +} + variable "mock_spoke_subnet_name" { type = string } @@ -58,15 +66,15 @@ variable "elastic_apm_server_url" { variable "elastic_apm_api_key" { } -variable "agent_2204_subnet" { +variable "permitdecryptionhardwareid" { type = string } -variable "agent_prd_subnet" { +variable "agent_2204_subnet" { type = string } -variable "permitdecryptionhardwareid" { +variable "agent_prd_subnet" { type = string } diff --git a/DevDeployment/swap_container_config.ps1 b/Deployment/swap_container_config.ps1 similarity index 100% rename from DevDeployment/swap_container_config.ps1 rename to Deployment/swap_container_config.ps1 diff --git a/Deployment/templates/app-deploy.yml b/Deployment/templates/app-deploy.yml new file mode 100644 index 00000000..2a6c55bc --- /dev/null +++ b/Deployment/templates/app-deploy.yml @@ -0,0 +1,280 @@ +parameters: +- name: RunTests + type: boolean + default: false +- name: Environment + type: string +- name: AzureSubscription + type: string +- name: ContinueEvenIfResourcesAreGettingDestroyed + type: boolean + default: false +- name: Container + type: string + +jobs: +- deployment: DeployApp + displayName: "${{parameters.Environment}} - Deploy Terraform and Dotnet App" + environment: "Ess-${{parameters.Environment}}" + pool: $(DeploymentPool) + container: ${{parameters.Container}} + workspace: + clean: all + strategy: + runOnce: + deploy: + steps: + - template: continuous-deployment.yml + parameters: + ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} + AzureSubscription: ${{parameters.AzureSubscription}} + RunTests: ${{parameters.RunTests}} + +- job: CheckInfra + displayName: "Check Infrastructure Health" + dependsOn: DeployApp + variables: + - name: WEB_APP_NAME + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.WEBAPP'] ] + - name: RGName + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.ResourceGroup'] ] + steps: + - task: AzureCLI@2 + displayName: "Check Infrastructure is healthy" + inputs: + azureSubscription: ${{parameters.AzureSubscription}} + scriptType: 'pscore' + scriptLocation: 'scriptPath' + scriptPath: '$(Build.SourcesDirectory)/Deployment/check_service_status_webjob.ps1' + arguments: '-RGName $(RGName) -webAppName $(WEB_APP_NAME) -waitTimeInMinute $(waitTimeInMinute)' + +- job: CheckFSS + displayName: "Check FSS Health" + dependsOn: DeployApp + steps: + - task: PowerShell@2 + displayName: "Check FSS Health endpoint is healthy" + inputs: + targetType: filePath + filePath: "$(Build.SourcesDirectory)/Deployment/check_health_endpoint.ps1" + arguments: "-healthEndPointUrl $(FSSHealthEndpoint)/heartbeat -waitTimeInMinute $(waitTimeInMinute)" + +- job: CheckESS + displayName: "Check ESS Health" + dependsOn: DeployApp + steps: + - task: PowerShell@2 + displayName: "Check ESS Health endpoint is healthy" + inputs: + targetType: filePath + filePath: '$(Build.SourcesDirectory)/Deployment/check_health_endpoint.ps1' + arguments: "-healthEndPointUrl $(ESSHealthEndpoint)/health -waitTimeInMinute $(waitTimeInMinute)" + +- job: CheckFM + displayName: "Check Fleet Manager Health" + dependsOn: DeployApp + steps: + - task: PowerShell@2 + displayName: "Check FM Health endpoint is healthy" + inputs: + targetType: filePath + filePath: '$(Build.SourcesDirectory)/Deployment/check_health_endpoint.ps1' + arguments: "-healthEndPointUrl $(FMHealthEndpoint)/health-check -waitTimeInMinute $(waitTimeInMinute)" + +- job: Setup + displayName: "Set Webjob Configuration" + condition: not(${{parameters.RunTests}}) # Run only if tests are not running + dependsOn: DeployApp + variables: + - name: WEB_APP_NAME + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.WEBAPP'] ] + - name: RGName + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.ResourceGroup'] ] + steps: + - task: AzureCLI@2 + displayName: "Swap Webjob Configuration" + condition: always() + inputs: + azureSubscription: ${{parameters.AzureSubscription}} + scriptType: 'pscore' + scriptLocation: 'scriptPath' + scriptPath: "$(Build.SourcesDirectory)/Deployment/set_webjob_configuration.ps1" + arguments: '-essapibaseurl $(ESSApiConfiguration.BaseUrl) -fssapibaseurl $(FSSApiConfiguration.BaseUrl) -fleetmanagerbaseurl $(FleetManagerB2BApiConfiguration.BaseUrl) -ftrunning false -fssapipollingcutoffime $(FSSApiConfiguration.BatchStatusPollingCutoffTime) -fssapipollingdelaytime $(FSSApiConfiguration.BatchStatusPollingDelayTime) -resourcegroup $(RGName) -webappname $(WEB_APP_NAME)' + +- job: POSFunctionalTests + condition: and(succeeded(), eq('${{ parameters.RunTests }}', 'true')) + dependsOn: + - DeployApp + - CheckInfra + - CheckFSS + - CheckESS + - CheckFM + pool: NautilusBuild + displayName: "POS Functional Automated Tests" + variables: + - name: POSWebjobApiConfiguration.UserName + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.webJobUsername'] ] + - name: POSWebjobApiConfiguration.Password + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.webJobPassword'] ] + - name: mockWebAppName + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.mockWebApp'] ] + - name: mockWebAppResourceGroup + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.mockWebAppResourceGroupName'] ] + steps: + # - task: AzureCLI@2 + # displayName: "Set Subnet Configuration" + # inputs: + # azureSubscription: ${{parameters.AzureSubscription}} + # scriptType: 'pscore' + # scriptLocation: 'scriptPath' + # scriptPath: '$(Build.SourcesDirectory)/Deployment/set_subnet_configuration.ps1' + # arguments: '-mockresourcegroup $(mockWebAppResourceGroup) -mockwebappname $(mockWebAppName) -subscriptionid $(POSESSQASubscriptionId) -vnetresourcegroup $(spokeRG) -vnetname $(POSESSQAspokeVnetName) -subnetname $(POSESSspokeSubnetName)' + + - task: DownloadBuildArtifacts@0 + displayName: "Download POS Functional test Artifact" + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'posfunctionaltests' + downloadPath: '$(Build.SourcesDirectory)' + + - task: FileTransform@2 + displayName: "File Transform: functionaltests" + inputs: + folderPath: '$(Build.SourcesDirectory)/posfunctionaltests/' + xmlTransformationRules: + jsonTargetFiles: '**/appsettings.json' + + - task: UseDotNet@2 + displayName: 'Use .NET SDK' + inputs: + packageType: sdk + version: 6.0.x + + - task: DotNetCoreCLI@2 + displayName: "Run POS Functional tests" + inputs: + command: "test" + projects: | + **/*FunctionalTest*.dll + !**/*TestAdapter.dll + !**/obj/** + arguments: '--filter Category~CallEssEndPoint|Category~GetAVCSCatalogue|Category~POSEndToEndScenarioFullAvcsPollingTimeOut|Category~POSEndToEndScenarioUpdatePollingTimeOut|Category~POSEndToEndScenarioWithInvalidProductIdentifier|Category~POSEndToEndValidFunctionalScenarios|Category~POSAIOValidFunctionalScenarios|Category~POSAIOScenarioWithInvalidProductIdentifier|Category~POSAIOScenarioPollingTimeOut' + testRunTitle: "${{parameters.Environment}}-POSAutomationTests" + workingDirectory: '$(Build.SourcesDirectory)/posfunctionaltests' + +- job: BESSFunctionalTests + condition: and(succeeded(), eq('${{ parameters.RunTests }}', 'true')) + dependsOn: + - DeployApp + - CheckInfra + - CheckFSS + - CheckESS + - CheckFM + - POSFunctionalTests + pool: NautilusBuild + displayName: "BESS Functional Automated Tests" + variables: + - name: AzureWebJobsStorage + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.AzureWebJobsStorageName'] ] + - name: WEB_APP_NAME + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.WEBAPP'] ] + - name: mockWebAppName + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.mockWebApp'] ] + - name: mockWebAppResourceGroup + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.mockWebAppResourceGroupName'] ] + - name: RGName + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.ResourceGroup'] ] + - name: BessStorageConfiguration.ConnectionString + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.AzureWebJobsStorageName'] ] + steps: + - task: DownloadBuildArtifacts@0 + displayName: "Download Terraform Artifact" + condition: always() + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'terraformartifact' + downloadPath: '$(Build.SourcesDirectory)' + + - task: AzureCLI@2 + displayName: "Swap Storage Container Configuration" + condition: always() + inputs: + azureSubscription: ${{parameters.AzureSubscription}} + scriptType: 'pscore' + scriptLocation: 'scriptPath' + scriptPath: "$(Build.SourcesDirectory)/terraformartifact/swap_container_config.ps1" + arguments: '-containername $(BessContainerForFT) -resourcegroup $(RGName) -webappname $(WEB_APP_NAME)' + + - task: DownloadBuildArtifacts@0 + displayName: "Download BESS Functional test Artifact" + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'bessfunctionaltests' + downloadPath: '$(Build.SourcesDirectory)' + + - task: FileTransform@2 + displayName: "File Transform: functionaltests" + inputs: + folderPath: '$(Build.SourcesDirectory)/bessfunctionaltests/' + xmlTransformationRules: + jsonTargetFiles: '**/appsettings.json' + + - task: UseDotNet@2 + displayName: 'Use .NET SDK' + inputs: + packageType: sdk + version: 6.0.x + + - task: DotNetCoreCLI@2 + displayName: "Run BESS Functional tests" + inputs: + command: "test" + projects: | + **/*FunctionalTest*.dll + !**/*TestAdapter.dll + !**/obj/** + testRunTitle: "${{parameters.Environment}}-BESSAutomationTests" + workingDirectory: '$(Build.SourcesDirectory)/bessfunctionaltests' + +- job: SwapAppConfigsconfiguration + condition: and(succeeded(), eq('${{ parameters.RunTests }}', 'true')) + dependsOn: + - DeployApp + - POSFunctionalTests + - BESSFunctionalTests + pool: NautilusBuild + displayName: "Swap App Configs configuration" + variables: + - name: WEB_APP_NAME + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.WEBAPP'] ] + - name: RGName + value: $[ dependencies.DeployApp.outputs['DeployApp.TerraformDeploy.ResourceGroup'] ] + steps: + - task: DownloadBuildArtifacts@0 + displayName: "Download Terraform Artifact" + condition: always() + inputs: + buildType: 'current' + downloadType: 'single' + artifactName: 'terraformartifact' + downloadPath: '$(Build.SourcesDirectory)' + + - task: PowerShell@2 + displayName: "Print Resource Group Name" + inputs: + targetType: 'inline' + script: | + Write-Output "Resource Group Name: $(RGName)" + + - task: AzureCLI@2 + displayName: "Swap Storage Container Configuration" + condition: always() + inputs: + azureSubscription: ${{parameters.AzureSubscription}} + scriptType: 'pscore' + scriptLocation: 'scriptPath' + scriptPath: "$(Build.SourcesDirectory)/terraformartifact/swap_container_config.ps1" + arguments: '-containername $(BessContainerForWebjob) -resourcegroup $(RGName) -webappname $(WEB_APP_NAME)' \ No newline at end of file diff --git a/Deployment/templates/build-test-publish.yml b/Deployment/templates/build-test-publish.yml new file mode 100644 index 00000000..8b235bcb --- /dev/null +++ b/Deployment/templates/build-test-publish.yml @@ -0,0 +1,373 @@ +parameters: +# Disable the NVD dependency check job. +- name: DisableDependencyCheck + type: boolean + default: false + +- name: DotNetVersion + type: string + default: '6.0.x' + +jobs: +- job: Dependencychecker + condition: eq('${{ parameters.DisableDependencyCheck }}', false) + workspace: + clean: all + displayName: "Dependencychecker" + steps: + - task: UseDotNet@2 + displayName: 'Use .NET SDK' + inputs: + packageType: sdk + version: $(SdkVersion) + + - task: DotNetCoreCLI@2 + displayName: ".Net Core - NuGet restore non test projects only" + inputs: + command: "restore" + projects: | + **/*.csproj + !**/*Tests.csproj + feedsToUse: config + noCache: true + nugetConfigPath: '$(Build.SourcesDirectory)\BuildNuget.config' + workingDirectory: '$(Build.SourcesDirectory)\UKHO.PeriodicOutputService' + packagesDirectory: '$(Build.SourcesDirectory)\UKHO.PeriodicOutputService\packages' + + - template: dependency-checker/windows-dependency-checker.yaml@UKHOTemplates + parameters: + scanName: 'Periodic-Output-Service - $(Build.SourceBranchName)' + scanPath: '$(Build.SourcesDirectory)\UKHO.PeriodicOutputService' + suppressionPath: '$(Build.SourcesDirectory)\NVDSuppressions.xml' + +- job: UnitTestsAndCodeCoverage + workspace: + clean: all + displayName: "Dotnet Test and Publish Code Coverage" + steps: + - task: UseDotNet@2 + displayName: 'Use .NET SDK' + inputs: + packageType: sdk + useGlobalJson: true + workingDirectory: '$(Build.SourcesDirectory)' + + - task: DotNetCoreCLI@2 + displayName: ".Net Core - NuGet restore test projects only" + inputs: + command: "restore" + projects: "**/*Tests.csproj" + feedsToUse: config + noCache: true + nugetConfigPath: '$(Build.SourcesDirectory)\BuildNuget.config' + workingDirectory: '$(Build.SourcesDirectory)\UKHO.PeriodicOutputService' + packagesDirectory: '$(Build.SourcesDirectory)\UKHO.PeriodicOutputService\packagesForTests' + + - task: DotNetCoreCLI@2 + displayName: "dotnet test - Perform Unit Tests" + inputs: + command: "test" + projects: "**/*UnitTests.csproj" + arguments: '--configuration $(BuildConfiguration) --settings "$(Build.SourcesDirectory)\test.runsettings" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura' + publishTestResults: true + testRunTitle: "UnitTests" + + - task: PowerShell@2 + displayName: "Generate code coverage report" + inputs: + targetType: filePath + filePath: '$(Build.SourcesDirectory)\CodeCoverageReport.ps1' + arguments: '-source "$(Build.SourcesDirectory)" -reportFolder "$(Build.ArtifactStagingDirectory)"' + + - task: PublishBuildArtifacts@1 + displayName: "Publish Code coverage" + inputs: + PathtoPublish: "$(Build.ArtifactStagingDirectory)/codecoveragereport" + ArtifactName: codecoveragereport + +- job: BuildAndPublishWebJob + workspace: + clean: all + displayName: "Dotnet Build publish WebJob" + steps: + - task: PowerShell@2 + displayName: "Set assembly version numbers based on build ID" + inputs: + targetType: filePath + filePath: '$(Build.SourcesDirectory)\Apply-AssemblyVersionAndDefaults.ps1' + arguments: '-buildNumber "$(Build.BuildNumber)" -solutionDirectory "$(Build.SourcesDirectory)\UKHO.PeriodicOutputService\" -UKHOAssemblyCompany "$env:UKHOAssemblyCompany" -UKHOAssemblyCopyright "$(UKHOAssemblyCopyright)" -UKHOAssemblyVersionPrefix "$env:UKHOAssemblyVersionPrefix" -UKHOAssemblyProduct "$env:UKHOAssemblyProduct"' + + - task: UseDotNet@2 + displayName: 'Use .NET SDK' + inputs: + packageType: sdk + useGlobalJson: true + workingDirectory: '$(Build.SourcesDirectory)' + + - task: DotNetCoreCLI@2 + displayName: ".Net Core - NuGet restore" + inputs: + command: restore + projects: | + **/*.csproj + feedsToUse: config + noCache: true + nugetConfigPath: '$(Build.SourcesDirectory)\BuildNuget.config' + workingDirectory: '$(Build.SourcesDirectory)\UKHO.PeriodicOutputService' + + - task: DotNetCoreCLI@2 + displayName: "dotnet build task" + inputs: + command: "build" + projects: "**/*.csproj" + arguments: '--configuration $(BuildConfiguration) --output $(Build.BinariesDirectory)' + + - task: DotNetCoreCLI@2 + displayName: "Publish POS Fulfilment Service Code" + inputs: + command: "publish" + publishWebProjects: false + projects: "**/*UKHO.PeriodicOutputService.Fulfilment.csproj" + arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\App_Data\jobs\triggered\POSFulfilmentWebJob' + zipAfterPublish: false + modifyOutputPath: false + + - task: DotNetCoreCLI@2 + displayName: "Publish AIO Fulfilment Service Code" + inputs: + command: "publish" + publishWebProjects: false + projects: "**/*UKHO.AdmiraltyInformationOverlay.Fulfilment.csproj" + arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\App_Data\jobs\triggered\AIOFulfilmentWebJob' + zipAfterPublish: false + modifyOutputPath: false + + - task: DotNetCoreCLI@2 + displayName: "Publish BESS Configuration Service Code" + inputs: + command: "publish" + publishWebProjects: false + projects: "**/*UKHO.BESS.ConfigurationService.csproj" + arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\App_Data\jobs\continuous\BESSConfigurationServiceWebJob' + zipAfterPublish: false + modifyOutputPath: false + + - task: DotNetCoreCLI@2 + displayName: "Publish BESS Builder Service Code" + inputs: + command: "publish" + publishWebProjects: false + projects: "**/*UKHO.BESS.BuilderService.csproj" + arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\App_Data\jobs\continuous\BESSBuilderServiceWebJob' + zipAfterPublish: false + modifyOutputPath: false + + - task: DotNetCoreCLI@2 + displayName: "Publish BESS CleanUp Service Code" + inputs: + command: "publish" + publishWebProjects: false + projects: "**/*UKHO.BESS.CleanUpJob.csproj" + arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\App_Data\jobs\triggered\BESSCleanUpWebJob' + zipAfterPublish: false + modifyOutputPath: false + + - task: ArchiveFiles@2 + displayName: "Zip POS fulfilment service" + inputs: + rootFolderOrFile: '$(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\' + includeRootFolder: false + archiveType: "zip" + archiveFile: '$(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\PeriodicOutputFulfilmentService.zip' + replaceExistingArchive: true + + - task: PublishBuildArtifacts@1 + displayName: "Publish PeriodicOutputFulfilmentService Artifact" + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService' + ArtifactName: PeriodicOutputService + + - task: PowerShell@2 + displayName: "Generate event id runbook" + inputs: + targetType: filePath + filePath: '$(Build.SourcesDirectory)\Utility\XmlToRtfTransformation.ps1' + arguments: '-xmlFilePath $(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\App_Data\jobs\triggered\POSFulfilmentWebJob\UKHO.PeriodicOutputService.Common.xml -xsltFilePath $(Build.SourcesDirectory)\Utility\EventIdXmlTransformation.xslt -outputFileName Runbook-EventId' + + - task: PublishBuildArtifacts@1 + displayName: "Publish event id runbook" + inputs: + PathtoPublish: '$(Build.SourcesDirectory)\Utility\Runbook-EventId.rtf' + ArtifactName: Runbook + +- job: PublishTerraformArtifacts + workspace: + clean: all + displayName: "Publish Terraform Artifacts" + steps: + - task: PublishBuildArtifacts@1 + displayName: "Publish terraform Artifacts" + inputs: + PathtoPublish: '$(Build.SourcesDirectory)\Deployment' + ArtifactName: terraformartifact + +- job: PublishFunctionalTests + workspace: + clean: all + displayName: "Publish Functional Tests" + steps: + - task: UseDotNet@2 + displayName: 'Use .NET SDK' + inputs: + packageType: sdk + useGlobalJson: true + workingDirectory: '$(Build.SourcesDirectory)' + + - task: DotNetCoreCLI@2 + displayName: ".Net Core - NuGet restore" + inputs: + command: restore + projects: | + **/*.csproj + feedsToUse: config + noCache: true + nugetConfigPath: '$(Build.SourcesDirectory)\BuildNuget.config' + workingDirectory: '$(Build.SourcesDirectory)\UKHO.PeriodicOutputService' + + - task: DotNetCoreCLI@2 + displayName: "Publish POS functional test" + inputs: + command: "publish" + publishWebProjects: false + projects: "**/*UKHO.PeriodicOutputService.API.FunctionalTests.csproj" + arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\UKHO.PeriodicOutputService.API.FunctionalTests' + zipAfterPublish: false + + - task: PublishBuildArtifacts@1 + displayName: "Publish POS Functional test Artifact" + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)\UKHO.PeriodicOutputService.API.FunctionalTests' + ArtifactName: posfunctionaltests + + - task: DotNetCoreCLI@2 + displayName: "Publish BESS functional test" + inputs: + command: "publish" + publishWebProjects: false + projects: "**/*UKHO.BESS.API.FunctionalTests.csproj" + arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\UKHO.BESS.API.FunctionalTests' + zipAfterPublish: false + + - task: PublishBuildArtifacts@1 + displayName: "Publish BESS Functional test Artifact" + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)\UKHO.BESS.API.FunctionalTests' + ArtifactName: bessfunctionaltests + +- job: BuildAndPublishMockAPI + workspace: + clean: all + displayName: "Build and Publish Mock API" + steps: + - task: PowerShell@2 + displayName: "Set assembly version numbers based on build ID" + inputs: + targetType: filePath + filePath: '$(Build.SourcesDirectory)\Apply-AssemblyVersionAndDefaults.ps1' + arguments: '-buildNumber "$(Build.BuildNumber)" -solutionDirectory "$(Build.SourcesDirectory)\UKHO.FmEssFssMock.API\" -UKHOAssemblyCompany "$env:UKHOAssemblyCompany" -UKHOAssemblyCopyright "$(UKHOAssemblyCopyright)" -UKHOAssemblyVersionPrefix "$env:UKHOAssemblyVersionPrefix" -UKHOAssemblyProduct "$(UKHOAssemblyProduct) Mock"' + + - task: UseDotNet@2 + displayName: 'Use .NET SDK' + inputs: + packageType: sdk + useGlobalJson: true + workingDirectory: '$(Build.SourcesDirectory)' + + - task: DotNetCoreCLI@2 + displayName: ".Net Core - NuGet restore" + inputs: + command: restore + projects: | + **/*.csproj + feedsToUse: config + noCache: true + nugetConfigPath: '$(Build.SourcesDirectory)\BuildNuget.config' + workingDirectory: '$(Build.SourcesDirectory)\UKHO.FmEssFssMock.API' + + - task: DotNetCoreCLI@2 + displayName: "dotnet build task" + inputs: + command: "build" + projects: "**/*UKHO.FmEssFssMock.API.csproj" + arguments: '--configuration $(BuildConfiguration) --output $(Build.BinariesDirectory)' + workingDirectory: '$(Build.SourcesDirectory)\UKHO.FmEssFssMock.API' + + - task: DotNetCoreCLI@2 + displayName: "Publish MockWebAPI" + inputs: + command: "publish" + publishWebProjects: false + projects: '**/*UKHO.FmEssFssMock.API.csproj' + arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\MockWebAPI' + zipAfterPublish: true + modifyOutputPath: true + + - task: PublishBuildArtifacts@1 + displayName: "Publish WebAPI Artifact" + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)\MockWebAPI' + ArtifactName: MockWebAPI + +- job: BuildAndPublishPKSWireMockAPI + workspace: + clean: all + displayName: "Build and Publish PKSWireMock API" + steps: + - task: PowerShell@2 + displayName: "Set assembly version numbers based on build ID" + inputs: + targetType: filePath + filePath: '$(Build.SourcesDirectory)\Apply-AssemblyVersionAndDefaults.ps1' + arguments: '-buildNumber "$(Build.BuildNumber)" -solutionDirectory "$(Build.SourcesDirectory)\UKHO.PKSWireMockService.API\" -UKHOAssemblyCompany "$env:UKHOAssemblyCompany" -UKHOAssemblyCopyright "$(UKHOAssemblyCopyright)" -UKHOAssemblyVersionPrefix "$env:UKHOAssemblyVersionPrefix" -UKHOAssemblyProduct "$(UKHOAssemblyProduct) Mock"' + + - task: UseDotNet@2 + displayName: 'Use .NET SDK' + inputs: + packageType: sdk + useGlobalJson: true + workingDirectory: '$(Build.SourcesDirectory)' + + - task: DotNetCoreCLI@2 + displayName: ".Net Core - NuGet restore" + inputs: + command: restore + projects: | + **/*.csproj + feedsToUse: config + noCache: true + nugetConfigPath: '$(Build.SourcesDirectory)\BuildNuget.config' + workingDirectory: '$(Build.SourcesDirectory)\UKHO.PKSWireMockService.API' + + - task: DotNetCoreCLI@2 + displayName: "dotnet build task" + inputs: + command: "build" + projects: "**/*UKHO.PKSWireMock.API.csproj" + arguments: '--configuration $(BuildConfiguration) --output $(Build.BinariesDirectory)' + workingDirectory: '$(Build.SourcesDirectory)\UKHO.PKSWireMockService.API' + + - task: DotNetCoreCLI@2 + displayName: "Publish PKSWireMock WebAPI" + inputs: + command: "publish" + publishWebProjects: false + projects: '**/*UKHO.PKSWireMock.API.csproj' + arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\PKSWireMockWebAPI' + zipAfterPublish: true + modifyOutputPath: true + + - task: PublishBuildArtifacts@1 + displayName: "Publish PKSWireMock WebAPI Artifact" + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)\PKSWireMockWebAPI' + ArtifactName: PKSWireMockWebAPI \ No newline at end of file diff --git a/DevDeployment/templates/continuous-deployment.yml b/Deployment/templates/continuous-deployment.yml similarity index 81% rename from DevDeployment/templates/continuous-deployment.yml rename to Deployment/templates/continuous-deployment.yml index 574f7a61..b3d27b9e 100644 --- a/DevDeployment/templates/continuous-deployment.yml +++ b/Deployment/templates/continuous-deployment.yml @@ -4,21 +4,26 @@ parameters: default: false - name: AzureSubscription type: string + - name: RunTests + type: boolean + default: false steps: - - task: PowerShell@2 displayName: "Terraform $(Environment)deploy" name: TerraformDeploy inputs: targetType: filePath - filePath: '$(Pipeline.Workspace)/devterraformartifact/terraform_conditional_run.ps1' - arguments: '-deploymentResourceGroupName $(DeploymentResourceGroupName) -deploymentStorageAccountName $(DeploymentStorageAccountName) -workSpace $(Environment) -continueEvenIfResourcesAreGettingDestroyed $${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} -terraformJsonOutputFile $(Pipeline.Workspace)/devterraformartifact/terraform_output.json -elasticApmServerUrl $(ElasticAPM_ServerURL) -elasticApmApiKey $(ElasticAPM_ApiKey)' + filePath: '$(Pipeline.Workspace)/terraformartifact/terraform_conditional_run.ps1' + arguments: '-deploymentResourceGroupName $(DeploymentResourceGroupName) -deploymentStorageAccountName $(DeploymentStorageAccountName) -workSpace $(Environment) -continueEvenIfResourcesAreGettingDestroyed $${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} -terraformJsonOutputFile $(Pipeline.Workspace)/terraformartifact/terraform_output.json -elasticApmServerUrl $(ElasticAPM_ServerURL) -elasticApmApiKey $(ElasticAPM_ApiKey)' env: ARM_CLIENT_ID: $(TERRAFORM-CLIENT-ID) ARM_CLIENT_SECRET: $(TERRAFORM-CLIENT-SECRET) ARM_TENANT_ID: $(TERRAFORM-TENANT-ID) ARM_SUBSCRIPTION_ID: $(TERRAFORM-SUBSCRIPTION-ID) + TF_VAR_agent_rg: $(agentRG) + TF_VAR_agent_vnet_name: $(agentVnetName) + TF_VAR_agent_subscription_id: $(agentSubscriptionId) TF_VAR_spoke_rg: $(spokeRG) TF_VAR_spoke_vnet_name: $(spokeVnetName) TF_VAR_spoke_subnet_name: $(POSESSspokeSubnetName) @@ -27,7 +32,6 @@ steps: TF_VAR_permitdecryptionhardwareid: $(PermitDecryptionHardwareId) TF_VAR_agent_2204_subnet: $(agent2204SubnetId) TF_VAR_agent_prd_subnet: $(agentprdSubnetId) - TF_VAR_agent_subscription_id: $(agentSubscriptionId) TF_VAR_BessContainerName: $(BessContainerForWebjob) - task: FileTransform@2 @@ -38,21 +42,23 @@ steps: jsonTargetFiles: '**/appsettings.json' - task: AzureCLI@2 + condition: ${{parameters.RunTests}} displayName: "Mock API WebApp deployment" inputs: azureSubscription: "${{ parameters.AzureSubscription }}" scriptType: 'pscore' scriptLocation: 'scriptPath' - scriptPath: '$(Pipeline.Workspace)/devterraformartifact/mock_api_deployment.ps1' + scriptPath: '$(Pipeline.Workspace)/terraformartifact/mock_api_deployment.ps1' arguments: '-mockWebAppName $(mockWebAppName) -mockApipackagePath "$(Pipeline.Workspace)/MockWebAPI/UKHO.FmEssFssMock.API.zip" -mockWebAppResourceGroup $(mockWebAppResourceGroup)' - task: AzureCLI@2 + condition: ${{parameters.RunTests}} displayName: "PKSMock API WebApp deployment" inputs: azureSubscription: "${{ parameters.AzureSubscription }}" scriptType: 'pscore' scriptLocation: 'scriptPath' - scriptPath: '$(Pipeline.Workspace)/devterraformartifact/mock_api_deployment.ps1' + scriptPath: '$(Pipeline.Workspace)/terraformartifact/mock_api_deployment.ps1' arguments: '-mockWebAppName $(pksMockWebAppName) -mockApipackagePath "$(Pipeline.Workspace)/PKSWireMockWebAPI/UKHO.PKSWireMockService.API.zip" -mockWebAppResourceGroup $(mockWebAppResourceGroup)' - task: FileTransform@2 diff --git a/QALiveDeployment/templates/retain-pipeline.yml b/Deployment/templates/retain-pipeline.yml similarity index 87% rename from QALiveDeployment/templates/retain-pipeline.yml rename to Deployment/templates/retain-pipeline.yml index 2479bb05..3a47069b 100644 --- a/QALiveDeployment/templates/retain-pipeline.yml +++ b/Deployment/templates/retain-pipeline.yml @@ -4,7 +4,7 @@ steps: displayName: Retain Live Release inputs: targetType: filePath - filePath: "$(Build.SourcesDirectory)/QALiveDeployment/add-lease.ps1" + filePath: "$(Build.SourcesDirectory)/Deployment/add-lease.ps1" arguments: "-daysValid 365 -accessToken '$(System.AccessToken)' -definitionId $(System.DefinitionId) diff --git a/Deployment/templates/variables.yml b/Deployment/templates/variables.yml new file mode 100644 index 00000000..9637fea0 --- /dev/null +++ b/Deployment/templates/variables.yml @@ -0,0 +1,20 @@ +parameters: + - name: Environment + type: string + +variables: +- group: "ESS-${{parameters.Environment}}-Variables" +- group: "ESS-Deployment-Variables-${{parameters.Environment}}" +- group: "POS-${{parameters.Environment}}-Variables" +- name: "ElasticAPM_ServerURL" + value: $(ElasticAPM.ServerURL) +- name: "ElasticAPM_ApiKey" + value: $(ElasticAPM.ApiKey) +- name: "ESSApiConfiguration.TenantId" + value: $(TenantId) +- name: "ESSApiConfiguration.AutoTestClientId" + value: $(AutoTestClientId_Authed) +- name: "ESSApiConfiguration.AutoTestClientSecret" + value: $(AutoTestClientSecret_Authed) +- name: "ESSApiConfiguration.EssClientId" + value: $(ESSClientId) \ No newline at end of file diff --git a/DevDeployment/terraform_conditional_run.ps1 b/Deployment/terraform_conditional_run.ps1 similarity index 98% rename from DevDeployment/terraform_conditional_run.ps1 rename to Deployment/terraform_conditional_run.ps1 index 5c7e4400..027f2ff8 100644 --- a/DevDeployment/terraform_conditional_run.ps1 +++ b/Deployment/terraform_conditional_run.ps1 @@ -8,7 +8,7 @@ param ( [Parameter(Mandatory = $true)] [string] $elasticApmApiKey ) -cd $env:AGENT_BUILDDIRECTORY/devterraformartifact/src +cd $env:AGENT_BUILDDIRECTORY/terraformartifact/src terraform --version diff --git a/DevDeployment/mock_api_deployment.ps1 b/DevDeployment/mock_api_deployment.ps1 deleted file mode 100644 index 7bd91f97..00000000 --- a/DevDeployment/mock_api_deployment.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -param ( - [Parameter(Mandatory = $true)] [string] $mockWebAppName, - [Parameter(Mandatory = $true)] [string] $mockApipackagePath, - [Parameter(Mandatory = $true)] [string] $mockWebAppResourceGroup -) - -echo "mockApipackagePath : $mockApipackagePath" -echo "mockWebAppName : $mockWebAppName" -echo "ResourceGroup : $mockWebAppResourceGroup" - -function DeployWebApp($webAppName, $package, $webAppRGroup){ - - echo "Function DeployWebApp called with params $webAppName, $package, $webAppRGroup ..." - - az webapp deployment source config-zip -g $webAppRGroup -n $webAppName --src $package - - if ( !$? ) { echo "Error while deplying webapp $webAppName" ; throw $_ } -} - -echo "Deploying mock api ..." -DeployWebApp $mockWebAppName $mockApipackagePath $mockWebAppResourceGroup - -if ( !$? ) { echo "Error while deploying mock api webapp" ; throw $_ } - -echo "Deploying mock api done ..." - diff --git a/DevDeployment/set_qa_subnet_configuration.ps1 b/DevDeployment/set_qa_subnet_configuration.ps1 deleted file mode 100644 index a1d092e8..00000000 --- a/DevDeployment/set_qa_subnet_configuration.ps1 +++ /dev/null @@ -1,15 +0,0 @@ -param ( - [Parameter(Mandatory = $true)] [string] $mockresourcegroup, - [Parameter(Mandatory = $true)] [string] $mockwebappname, - [Parameter(Mandatory = $true)] [string] $qasubscriptionid, - [Parameter(Mandatory = $true)] [string] $qavnetresourcegroup, - [Parameter(Mandatory = $true)] [string] $qavnetname, - [Parameter(Mandatory = $true)] [string] $qasubnetname -) - -Write-Output "Set QA Subnet in Mock Network Configuration ..." -az webapp config access-restriction add -g $mockresourcegroup -n $mockwebappname --action Allow --subnet "/subscriptions/$qasubscriptionid/resourceGroups/$qavnetresourcegroup/providers/Microsoft.Network/virtualNetworks/$qavnetname/subnets/$qasubnetname" --priority 65000 --scm-site false -i - - - - diff --git a/DevDeployment/set_stub_webjob_configuration.ps1 b/DevDeployment/set_stub_webjob_configuration.ps1 deleted file mode 100644 index 7a6aa6f0..00000000 --- a/DevDeployment/set_stub_webjob_configuration.ps1 +++ /dev/null @@ -1,21 +0,0 @@ -param ( - [Parameter(Mandatory = $true)] [string] $essapibaseurl, - [Parameter(Mandatory = $true)] [string] $resourcegroup, - [Parameter(Mandatory = $true)] [string] $mockresourcegroup, - [Parameter(Mandatory = $true)] [string] $webappname, - [Parameter(Mandatory = $true)] [string] $mockwebappname, - [Parameter(Mandatory = $true)] [string] $fssapibaseurl, - [Parameter(Mandatory = $true)] [string] $fleetmanagerbaseurl, - [Parameter(Mandatory = $true)] [string] $fleetmanagerfilepath, - [Parameter(Mandatory = $true)] [string] $ftrunning, - [Parameter(Mandatory = $true)] [string] $fssapipollingcutoffime, - [Parameter(Mandatory = $true)] [string] $fssapipollingdelaytime -) - -Write-Output "Set Stub Configuration in appsetting..." -az webapp config appsettings set -g $mockresourcegroup -n $mockwebappname --settings FleetManagerB2BApiConfiguration:GetCatalogueResponseFilePath=$fleetmanagerfilepath IsFTRunning=$ftrunning -az webapp restart --name $mockwebappname --resource-group $mockresourcegroup - -Write-Output "Set Webjob Configuration in appsetting..." -az webapp config appsettings set -g $resourcegroup -n $webappname --settings ESSApiConfiguration:BaseUrl=$essapibaseurl FSSApiConfiguration:BaseUrl=$fssapibaseurl FleetManagerB2BApiConfiguration:BaseUrl=$fleetmanagerbaseurl IsFTRunning=$ftrunning FSSApiConfiguration:BatchStatusPollingCutoffTime=$fssapipollingcutoffime FSSApiConfiguration:BatchStatusPollingDelayTime=$fssapipollingdelaytime -az webapp restart --name $webappname --resource-group $resourcegroup diff --git a/DevDeployment/src/Modules/AppInsights/variables.tf b/DevDeployment/src/Modules/AppInsights/variables.tf deleted file mode 100644 index 9c44bd70..00000000 --- a/DevDeployment/src/Modules/AppInsights/variables.tf +++ /dev/null @@ -1,15 +0,0 @@ -variable "name" { - type = string -} - -variable "resource_group_name" { - type = string -} - -variable "location" { - type = string -} - -variable "tags" { - -} diff --git a/DevDeployment/src/Modules/Storage/main.tf b/DevDeployment/src/Modules/Storage/main.tf deleted file mode 100644 index 266f3fe5..00000000 --- a/DevDeployment/src/Modules/Storage/main.tf +++ /dev/null @@ -1,38 +0,0 @@ -resource "azurerm_storage_account" "pos_storage" { - name = lower("${var.service_name}${var.env_name}storageukho") - resource_group_name = var.resource_group_name - location = var.location - account_tier = "Standard" - account_replication_type = "LRS" - account_kind = "StorageV2" - - tags = var.tags - network_rules { - default_action = "Deny" - ip_rules = var.allowed_ips - bypass = ["Logging", "Metrics", "AzureServices"] - virtual_network_subnet_ids = [var.m_spoke_subnet, var.agent_2204_subnet, var.agent_prd_subnet] -} -} - -resource "azurerm_storage_account" "bess_storage" { - name = lower("${var.service_name_bess}${var.env_name}storageukho") - resource_group_name = var.resource_group_name - location = var.location - account_tier = "Standard" - account_replication_type = "LRS" - account_kind = "StorageV2" - - tags = var.tags - network_rules { - default_action = "Deny" - ip_rules = var.allowed_ips - bypass = ["Logging", "Metrics", "AzureServices"] - virtual_network_subnet_ids = [var.m_spoke_subnet,var.mock_spoke_subnet,var.agent_2204_subnet, var.agent_prd_subnet] -} -} - -resource "azurerm_storage_container" "bess_config_container" { - name = var.container_name - storage_account_name = azurerm_storage_account.bess_storage.name -} diff --git a/DevDeployment/src/Modules/WebApp/outputs.tf b/DevDeployment/src/Modules/WebApp/outputs.tf deleted file mode 100644 index a6b555d0..00000000 --- a/DevDeployment/src/Modules/WebApp/outputs.tf +++ /dev/null @@ -1,20 +0,0 @@ -output "web_app_object_id" { - value = azurerm_windows_web_app.webapp_service.identity.0.principal_id -} - -output "web_app_tenant_id" { - value = azurerm_windows_web_app.webapp_service.identity.0.tenant_id -} - -output "default_site_hostname" { - value = azurerm_windows_web_app.webapp_service.default_hostname -} - -output "username" { - value = azurerm_windows_web_app.webapp_service.site_credential[0].name -} - -output "password" { - value = azurerm_windows_web_app.webapp_service.site_credential[0].password - sensitive = true -} diff --git a/DevDeployment/src/Modules/WebApp/variables.tf b/DevDeployment/src/Modules/WebApp/variables.tf deleted file mode 100644 index 0fc55fae..00000000 --- a/DevDeployment/src/Modules/WebApp/variables.tf +++ /dev/null @@ -1,35 +0,0 @@ -variable "name" { - type = string -} - -variable "resource_group_name" { - type = string -} - -variable "service_plan_id" { - type = string -} - -variable "location" { - type = string -} - -variable "app_settings" { - type = map(string) -} - -variable "tags" { - -} - -variable "env_name" { - type = string -} - -variable "subnet_id" { - type = string -} - -variable "allowed_ips" { - -} diff --git a/DevDeployment/src/resource-group.tf b/DevDeployment/src/resource-group.tf deleted file mode 100644 index 175053cb..00000000 --- a/DevDeployment/src/resource-group.tf +++ /dev/null @@ -1,13 +0,0 @@ -resource "azurerm_resource_group" "webapp_rg" { - name = "${local.service_name}-${local.env_name}-rg" - location = var.location - tags = local.tags -} - -resource "azurerm_resource_group" "mock_webapp_rg" { - name = "${local.service_name}-${local.env_name}-mock-rg" - location = var.location - tags = local.tags -} - - diff --git a/DevDeployment/src/variables.tf b/DevDeployment/src/variables.tf deleted file mode 100644 index 79627282..00000000 --- a/DevDeployment/src/variables.tf +++ /dev/null @@ -1,75 +0,0 @@ -variable "location" { - type = string - default = "uksouth" -} - -variable "resource_group_name" { - type = string - default = "pos" -} - -locals { - env_name = lower(terraform.workspace) - service_name = "pos" - web_app_name = "${local.service_name}-${local.env_name}-lxs-webapp" - mock_web_app_name = "${local.service_name}-${local.env_name}-mock-webapp" - pks_mock_web_app_name = "${local.service_name}-${local.env_name}-pks-mock-webapp" - key_vault_name = "${local.service_name}-ukho-${local.env_name}-kv" - service_name_bess = "bess" - container_name = "bess-configs" - - tags = { - SERVICE = "Periodic Output Service" - ENVIRONMENT = local.env_name - SERVICE_OWNER = "UKHO" - RESPONSIBLE_TEAM = "Abzu" - CALLOUT_TEAM = "On-Call_N/A" - COST_CENTRE = "A.008.02" - } -} - -variable "spoke_rg" { - type = string -} - -variable "spoke_vnet_name" { - type = string -} - -variable "spoke_subnet_name" { - type = string -} - -variable "mock_spoke_subnet_name" { - type = string -} - -variable "agent_subscription_id" { - type = string -} - -variable "allowed_ips" { - type = list -} - -variable "elastic_apm_server_url" { -} - -variable "elastic_apm_api_key" { -} - -variable "agent_2204_subnet" { - type = string -} - -variable "agent_prd_subnet" { - type = string -} - -variable "permitdecryptionhardwareid" { - type = string -} - -variable "BessContainerName" { - type = string -} diff --git a/QALiveDeployment/check_health_endpoint.ps1 b/QALiveDeployment/check_health_endpoint.ps1 deleted file mode 100644 index d2476eac..00000000 --- a/QALiveDeployment/check_health_endpoint.ps1 +++ /dev/null @@ -1,52 +0,0 @@ -Param( - [Parameter(mandatory=$true)][string]$healthEndPointUrl, - [Parameter(mandatory=$true)][string]$waitTimeInMinute -) - -$sleepTimeInSecond = 15 -$isServiceActive = 'false' - -$stopWatch = New-Object -TypeName System.Diagnostics.Stopwatch -$timeSpan = New-TimeSpan -Minutes $waitTimeInMinute -$stopWatch.Start() - -do -{ - Write-Host "Polling url: $healthEndPointUrl ..." - try{ - $HttpRequest = [System.Net.WebRequest]::Create("$healthEndPointUrl") - $HttpResponse = $HttpRequest.GetResponse() - $HttpStatus = $HttpResponse.StatusCode - Write-Host "Status code of web is $HttpStatus ..." - - If ($HttpStatus -eq 200 ) { - Write-Host "Service is up. Stopping Polling ..." - $isServiceActive = 'true' - break - } - Else { - Write-Host "Service not yet Up. Status code: $HttpStatus re-checking after $sleepTimeInSecond sec ..." - } - } - catch [System.Net.WebException] - { - $HttpStatus = $_.Exception.Response.StatusCode - Write-Host "Service not yet Up.Status: $HttpStatus re-checking after $sleepTimeInSecond sec ..." - } - - Start-Sleep -Seconds $sleepTimeInSecond -} -until ($stopWatch.Elapsed -ge $timeSpan) - - -If ($HttpResponse -ne $null) { - $HttpResponse.Close() -} - -if ($isServiceActive -eq 'true' ) { - Write-Host "Service is up returning from script ..." -} -Else { - Write-Error "Service was not up in $waitTimeInMinute, error while deployment ..." - throw "Error" -} diff --git a/QALiveDeployment/check_service_status_webjob.ps1 b/QALiveDeployment/check_service_status_webjob.ps1 deleted file mode 100644 index 530fa994..00000000 --- a/QALiveDeployment/check_service_status_webjob.ps1 +++ /dev/null @@ -1,49 +0,0 @@ -Param( - [Parameter(mandatory=$true)][string]$RGName, - [Parameter(mandatory=$true)][string]$webAppName, - [Parameter(mandatory=$true)][string]$waitTimeInMinute -) - -$sleepTimeInSecond = 10 -$recheckTimeInSecond = 35 -$isServiceActive = 'false' - -$stopWatch = New-Object -TypeName System.Diagnostics.Stopwatch -$fullTimeSpan = New-TimeSpan -Minutes $waitTimeInMinute -$recheckTimeSpan = New-TimeSpan -Seconds $recheckTimeInSecond -$stopWatch.Start() - -do -{ - Write-Host "Polling AZ ..." - $StateRequest = az webapp show --name $webAppName --resource-group $RGName --query "state" - Write-Host "State of webjob is $StateRequest ..." - - If ($StateRequest -eq '"Running"') { - Write-Host "Webjob service is running..." - $isServiceActive = 'true' - If($stopWatch.Elapsed -ge $recheckTimeSpan) { - Write-Host "Stopping polling ..." - break - } - - } - ElseIf ($StateRequest -eq '"PendingRestart"'){ - Write-Host "Webjob has encountered an error. Webjob state: $StateRequest..." - throw "Error" - } - Else { - Write-Host "Webjob is not yet running. Webjob state: $StateRequest re-checking after $sleepTimeInSecond sec ..." - } - - Start-Sleep -Seconds $sleepTimeInSecond -} -until ($stopWatch.Elapsed -ge $fullTimeSpan) - -if ($isServiceActive -eq 'true' ) { - Write-Host "Webjob is running, returning from script ..." -} -Else { - Write-Error "Error: Webjob was not running within $waitTimeInMinute minutes..." - throw "Error" -} diff --git a/QALiveDeployment/src/Modules/AppInsights/main.tf b/QALiveDeployment/src/Modules/AppInsights/main.tf deleted file mode 100644 index 9f73e3b9..00000000 --- a/QALiveDeployment/src/Modules/AppInsights/main.tf +++ /dev/null @@ -1,17 +0,0 @@ -resource "azurerm_log_analytics_workspace" "logs_analytics_workspace" { - name = "${var.name}-workspace" - location = var.location - resource_group_name = var.resource_group_name - sku = "PerGB2018" - retention_in_days = 30 - tags = var.tags -} - -resource "azurerm_application_insights" "app_insights" { - name = var.name - location = var.location - resource_group_name = var.resource_group_name - application_type = "web" - workspace_id = azurerm_log_analytics_workspace.logs_analytics_workspace.id - tags = var.tags -} diff --git a/QALiveDeployment/src/Modules/AppInsights/outputs.tf b/QALiveDeployment/src/Modules/AppInsights/outputs.tf deleted file mode 100644 index ebebdb1b..00000000 --- a/QALiveDeployment/src/Modules/AppInsights/outputs.tf +++ /dev/null @@ -1,8 +0,0 @@ -output "instrumentation_key" { - value = azurerm_application_insights.app_insights.instrumentation_key -} - -output "connection_string" { - value = azurerm_application_insights.app_insights.connection_string - sensitive = true -} diff --git a/QALiveDeployment/src/Modules/EventHub/main.tf b/QALiveDeployment/src/Modules/EventHub/main.tf deleted file mode 100644 index 48f6c93b..00000000 --- a/QALiveDeployment/src/Modules/EventHub/main.tf +++ /dev/null @@ -1,50 +0,0 @@ -resource "azurerm_eventhub_namespace" "eventhub_namespace" { - name = "${var.name}-namespace" - location = var.location - resource_group_name = var.resource_group_name - sku = "Standard" - capacity = 1 - tags = var.tags -} - -resource "azurerm_eventhub" "eventhub" { - name = var.name - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - resource_group_name = var.resource_group_name - partition_count = 2 - message_retention = 7 -} - -resource "azurerm_eventhub_consumer_group" "logging_application_consumer_group" { - name = "loggingApplication" - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - eventhub_name = azurerm_eventhub.eventhub.name - resource_group_name = var.resource_group_name -} - -resource "azurerm_eventhub_consumer_group" "logstash_consumer_group" { - name = "logstash" - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - eventhub_name = azurerm_eventhub.eventhub.name - resource_group_name = var.resource_group_name -} - -resource "azurerm_eventhub_authorization_rule" "log" { - name = "logAccessKey" - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - eventhub_name = azurerm_eventhub.eventhub.name - resource_group_name = var.resource_group_name - listen = false - send = true - manage = false -} - -resource "azurerm_eventhub_authorization_rule" "logstash" { - name = "logstashAccessKey" - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - eventhub_name = azurerm_eventhub.eventhub.name - resource_group_name = var.resource_group_name - listen = true - send = false - manage = false -} diff --git a/QALiveDeployment/src/Modules/EventHub/outputs.tf b/QALiveDeployment/src/Modules/EventHub/outputs.tf deleted file mode 100644 index 0a570f8a..00000000 --- a/QALiveDeployment/src/Modules/EventHub/outputs.tf +++ /dev/null @@ -1,9 +0,0 @@ -output "log_primary_connection_string" { - value = azurerm_eventhub_authorization_rule.log.primary_connection_string - sensitive = true -} - -output "entity_path" { - value = azurerm_eventhub.eventhub.name - sensitive = true -} diff --git a/QALiveDeployment/src/Modules/EventHub/variables.tf b/QALiveDeployment/src/Modules/EventHub/variables.tf deleted file mode 100644 index b222f79b..00000000 --- a/QALiveDeployment/src/Modules/EventHub/variables.tf +++ /dev/null @@ -1,19 +0,0 @@ -variable "name" { - type = string -} - -variable "resource_group_name" { - type = string -} - -variable "location" { - type = string -} - -variable "tags" { - -} - -variable "env_name" { - type = string -} diff --git a/QALiveDeployment/src/Modules/KeyVault/main.tf b/QALiveDeployment/src/Modules/KeyVault/main.tf deleted file mode 100644 index 6dc84ec2..00000000 --- a/QALiveDeployment/src/Modules/KeyVault/main.tf +++ /dev/null @@ -1,69 +0,0 @@ -data "azurerm_client_config" "current" {} - -resource "azurerm_key_vault" "kv" { - name = var.name - location = var.location - resource_group_name = var.resource_group_name - enabled_for_disk_encryption = true - tenant_id = var.tenant_id - - sku_name = "standard" - - network_acls { - default_action = "Deny" - bypass = "AzureServices" - ip_rules = var.allowed_ips - virtual_network_subnet_ids = var.allowed_subnet_ids - } - - tags = var.tags - -} - -#access policy for terraform script service account -resource "azurerm_key_vault_access_policy" "kv_access_terraform" { - key_vault_id = azurerm_key_vault.kv.id - tenant_id = data.azurerm_client_config.current.tenant_id - object_id = data.azurerm_client_config.current.object_id - - key_permissions = [ - "Create", - "Get", - ] - - secret_permissions = [ - "Set", - "Get", - "Delete", - "Recover", - "Purge" - ] -} - -#access policy for read access (app service) -resource "azurerm_key_vault_access_policy" "kv_read_access" { - for_each = var.read_access_objects - key_vault_id = azurerm_key_vault.kv.id - tenant_id = var.tenant_id - object_id = each.value - - key_permissions = [ - "List", - "Get", - ] - - secret_permissions = [ - "List", - "Get" - ] -} - -resource "azurerm_key_vault_secret" "passed_in_secrets" { - count = length(var.secrets) - name = keys(var.secrets)[count.index] - value = values(var.secrets)[count.index] - key_vault_id = azurerm_key_vault.kv.id - tags = var.tags - - depends_on = [azurerm_key_vault_access_policy.kv_access_terraform] -} diff --git a/QALiveDeployment/src/Modules/KeyVault/outputs.tf b/QALiveDeployment/src/Modules/KeyVault/outputs.tf deleted file mode 100644 index 0772ec06..00000000 --- a/QALiveDeployment/src/Modules/KeyVault/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output keyvault_uri { - value = azurerm_key_vault.kv.vault_uri -} diff --git a/QALiveDeployment/src/Modules/KeyVault/variables.tf b/QALiveDeployment/src/Modules/KeyVault/variables.tf deleted file mode 100644 index ece331b2..00000000 --- a/QALiveDeployment/src/Modules/KeyVault/variables.tf +++ /dev/null @@ -1,39 +0,0 @@ -variable "name" { - type = string -} - -variable "resource_group_name" { - type = string -} - -variable "location" { - type = string -} - -variable "tenant_id" { - type = string -} - -variable "env_name" { - type = string -} - -variable "read_access_objects" { - type = map(string) -} - -variable "secrets" { - type = map(string) -} - -variable "tags" { - -} - -variable "allowed_subnet_ids" { - type = list -} - -variable "allowed_ips" { - -} diff --git a/QALiveDeployment/src/Modules/Storage/outputs.tf b/QALiveDeployment/src/Modules/Storage/outputs.tf deleted file mode 100644 index e2895b8c..00000000 --- a/QALiveDeployment/src/Modules/Storage/outputs.tf +++ /dev/null @@ -1,13 +0,0 @@ -output pos_storage_name { - value = azurerm_storage_account.pos_storage.name -} - -output pos_storage_connection_string { - value = azurerm_storage_account.pos_storage.primary_connection_string - sensitive = true -} - -output bess_storage_connection_string { - value = azurerm_storage_account.bess_storage.primary_connection_string - sensitive = true -} diff --git a/QALiveDeployment/src/Modules/Storage/variables.tf b/QALiveDeployment/src/Modules/Storage/variables.tf deleted file mode 100644 index 898a2f50..00000000 --- a/QALiveDeployment/src/Modules/Storage/variables.tf +++ /dev/null @@ -1,43 +0,0 @@ - -variable "resource_group_name" { - type = string -} - -variable "location" { - type = string -} - -variable "env_name" { - type = string -} - -variable "tags" { -} - -variable "service_name" { - type = string -} - -variable "service_name_bess" { - type = string -} - -variable "container_name" { - type = string -} - -variable "m_spoke_subnet" { - type = string -} - -variable "allowed_ips" { -} - -variable "agent_2204_subnet" { - type = string -} - -variable "agent_prd_subnet" { - type = string -} - diff --git a/QALiveDeployment/src/Modules/Webapp/main.tf b/QALiveDeployment/src/Modules/Webapp/main.tf deleted file mode 100644 index 8fa44a3f..00000000 --- a/QALiveDeployment/src/Modules/Webapp/main.tf +++ /dev/null @@ -1,44 +0,0 @@ -resource "azurerm_windows_web_app" "webapp_service" { - name = var.name - location = var.location - resource_group_name = var.resource_group_name - service_plan_id = var.service_plan_id - tags = var.tags - - site_config { - application_stack { - current_stack = "dotnet" - dotnet_version = "v6.0" - } - always_on = true - ftps_state = "Disabled" - - ip_restriction { - virtual_network_subnet_id = var.subnet_id - } - - dynamic "ip_restriction" { - for_each = var.allowed_ips - content { - ip_address = length(split("/",ip_restriction.value)) > 1 ? ip_restriction.value : "${ip_restriction.value}/32" - } - } - } - - app_settings = var.app_settings - - identity { - type = "SystemAssigned" - } - - lifecycle { - ignore_changes = [ virtual_network_subnet_id ] - } - - https_only = true -} - -resource "azurerm_app_service_virtual_network_swift_connection" "webapp_vnet_integration" { - app_service_id = azurerm_windows_web_app.webapp_service.id - subnet_id = var.subnet_id -} diff --git a/QALiveDeployment/src/Modules/Webapp/outputs.tf b/QALiveDeployment/src/Modules/Webapp/outputs.tf deleted file mode 100644 index a6b555d0..00000000 --- a/QALiveDeployment/src/Modules/Webapp/outputs.tf +++ /dev/null @@ -1,20 +0,0 @@ -output "web_app_object_id" { - value = azurerm_windows_web_app.webapp_service.identity.0.principal_id -} - -output "web_app_tenant_id" { - value = azurerm_windows_web_app.webapp_service.identity.0.tenant_id -} - -output "default_site_hostname" { - value = azurerm_windows_web_app.webapp_service.default_hostname -} - -output "username" { - value = azurerm_windows_web_app.webapp_service.site_credential[0].name -} - -output "password" { - value = azurerm_windows_web_app.webapp_service.site_credential[0].password - sensitive = true -} diff --git a/QALiveDeployment/src/Modules/Webapp/variables.tf b/QALiveDeployment/src/Modules/Webapp/variables.tf deleted file mode 100644 index 0fc55fae..00000000 --- a/QALiveDeployment/src/Modules/Webapp/variables.tf +++ /dev/null @@ -1,35 +0,0 @@ -variable "name" { - type = string -} - -variable "resource_group_name" { - type = string -} - -variable "service_plan_id" { - type = string -} - -variable "location" { - type = string -} - -variable "app_settings" { - type = map(string) -} - -variable "tags" { - -} - -variable "env_name" { - type = string -} - -variable "subnet_id" { - type = string -} - -variable "allowed_ips" { - -} diff --git a/QALiveDeployment/src/azure.tf b/QALiveDeployment/src/azure.tf deleted file mode 100644 index d4c8c2fc..00000000 --- a/QALiveDeployment/src/azure.tf +++ /dev/null @@ -1,24 +0,0 @@ -terraform { - required_providers { - azurerm = { - source = "hashicorp/azurerm" - version = "=3.116.0" - } - } - - required_version = "=1.9.6" - backend "azurerm" { - container_name = "tfstate" - key = "posterraform.deployment.tfplan" - } -} - -provider "azurerm" { - features {} -} - -provider "azurerm" { - features {} - alias = "build_agent" - subscription_id = var.agent_subscription_id -} diff --git a/QALiveDeployment/src/main.tf b/QALiveDeployment/src/main.tf deleted file mode 100644 index 89073356..00000000 --- a/QALiveDeployment/src/main.tf +++ /dev/null @@ -1,98 +0,0 @@ -data "azurerm_subnet" "main_subnet" { - name = var.spoke_subnet_name - virtual_network_name = var.spoke_vnet_name - resource_group_name = var.spoke_rg -} - -data "azurerm_app_service_plan" "ess_asp" { - name = "ess-${local.env_name}-lxs-1-asp" - resource_group_name = "ess-${local.env_name}-rg" -} - -module "app_insights" { - source = "./Modules/AppInsights" - name = "${local.service_name}-${local.env_name}-insights" - resource_group_name = azurerm_resource_group.webapp_rg.name - location = azurerm_resource_group.webapp_rg.location - tags = local.tags -} - -module "eventhub" { - source = "./Modules/EventHub" - name = "${local.service_name}-${local.env_name}-events" - resource_group_name = azurerm_resource_group.webapp_rg.name - location = azurerm_resource_group.webapp_rg.location - tags = local.tags - env_name = local.env_name -} - -module "webapp_service" { - source = "./Modules/Webapp" - name = local.web_app_name - resource_group_name = azurerm_resource_group.webapp_rg.name - service_plan_id = data.azurerm_app_service_plan.ess_asp.id - env_name = local.env_name - location = azurerm_resource_group.webapp_rg.location - subnet_id = data.azurerm_subnet.main_subnet.id - app_settings = { - "EventHubLoggingConfiguration:Environment" = local.env_name - "EventHubLoggingConfiguration:MinimumLoggingLevel" = "Warning" - "EventHubLoggingConfiguration:UkhoMinimumLoggingLevel" = "Information" - "APPINSIGHTS_INSTRUMENTATIONKEY" = module.app_insights.instrumentation_key - "ASPNETCORE_ENVIRONMENT" = local.env_name - "WEBSITE_RUN_FROM_PACKAGE" = "1" - "WEBSITE_ENABLE_SYNC_UPDATE_SITE" = "true" - "FSSApiConfiguration:BusinessUnit" = "AVCSData" - "FSSApiConfiguration:PosReadGroups" = "public" - "FSSApiConfiguration:PosReadUsers" = "" - "FSSApiConfiguration:AIOBusinessUnit" = "AVCSData" - "FSSApiConfiguration:AIOReadGroups" = "public" - "FSSApiConfiguration:AIOReadUsers" = "" - "ELASTIC_APM_SERVER_URL" = var.elastic_apm_server_url - "ELASTIC_APM_TRANSACTION_SAMPLE_RATE" = "1" - "ELASTIC_APM_ENVIRONMENT" = local.env_name - "ELASTIC_APM_SERVICE_NAME" = "POS Web Job" - "ELASTIC_APM_API_KEY" = var.elastic_apm_api_key - "BessStorageConfiguration:ContainerName" = var.BessContainerName - } - tags = local.tags - allowed_ips = var.allowed_ips -} - -module "storage" { - source = "./Modules/Storage" - resource_group_name = azurerm_resource_group.webapp_rg.name - location = azurerm_resource_group.webapp_rg.location - allowed_ips = var.allowed_ips - m_spoke_subnet = data.azurerm_subnet.main_subnet.id - env_name = local.env_name - service_name = local.service_name - service_name_bess = local.service_name_bess - container_name = local.container_name - tags = local.tags - agent_2204_subnet = var.agent_2204_subnet - agent_prd_subnet = var.agent_prd_subnet -} - -module "key_vault" { - source = "./Modules/KeyVault" - name = local.key_vault_name - resource_group_name = azurerm_resource_group.webapp_rg.name - env_name = local.env_name - tenant_id = module.webapp_service.web_app_tenant_id - allowed_ips = var.allowed_ips - allowed_subnet_ids = [data.azurerm_subnet.main_subnet.id, var.agent_2204_subnet, var.agent_prd_subnet] - location = azurerm_resource_group.webapp_rg.location - read_access_objects = { - "webapp_service" = module.webapp_service.web_app_object_id - } - secrets = { - "EventHubLoggingConfiguration--ConnectionString" = module.eventhub.log_primary_connection_string - "EventHubLoggingConfiguration--EntityPath" = module.eventhub.entity_path - "ApplicationInsights--ConnectionString" = module.app_insights.connection_string - "BessStorageConfiguration--ConnectionString" = module.storage.bess_storage_connection_string - "AzureWebJobsStorage" = module.storage.bess_storage_connection_string - "PKSApiConfiguration--PermitDecryptionHardwareId" = var.permitdecryptionhardwareid - } - tags = local.tags -} diff --git a/QALiveDeployment/src/outputs.tf b/QALiveDeployment/src/outputs.tf deleted file mode 100644 index 34f12649..00000000 --- a/QALiveDeployment/src/outputs.tf +++ /dev/null @@ -1,62 +0,0 @@ -output "web_app_name" { - value = local.web_app_name -} - -output "env_name" { - value = local.env_name -} - -output "webapp_rg" { - value = azurerm_resource_group.webapp_rg.name -} - -output "Website_Url" { - value = "https://${module.webapp_service.default_site_hostname}/" -} - -output "kv_name" { - value = local.key_vault_name -} - -output "pos_storage_name" { -value = module.storage.pos_storage_name -} - -output "pos_storage_connection_string"{ - value = module.storage.pos_storage_connection_string - sensitive = true -} - -output "bess_storage_connection_string"{ - value = module.storage.bess_storage_connection_string - sensitive = true -} - -output "log_primary_connection_string" { - value = module.eventhub.log_primary_connection_string - sensitive = true -} - -output "entity_path" { - value = module.eventhub.entity_path - sensitive = true -} - -output "webjob_username" { - value = module.webapp_service.username - sensitive = true -} - -output "webjob_password" { - value = module.webapp_service.password - sensitive = true -} - -output "connection_string" { - value = module.app_insights.connection_string - sensitive = true -} - -output "keyvault_uri"{ - value = module.key_vault.keyvault_uri -} diff --git a/QALiveDeployment/src/resource-group.tf b/QALiveDeployment/src/resource-group.tf deleted file mode 100644 index 2e5a9df5..00000000 --- a/QALiveDeployment/src/resource-group.tf +++ /dev/null @@ -1,5 +0,0 @@ -resource "azurerm_resource_group" "webapp_rg" { - name = "${local.service_name}-${local.env_name}-rg" - location = var.location - tags = local.tags -} diff --git a/QALiveDeployment/src/variables.tf b/QALiveDeployment/src/variables.tf deleted file mode 100644 index 832e5df9..00000000 --- a/QALiveDeployment/src/variables.tf +++ /dev/null @@ -1,71 +0,0 @@ -variable "location" { - type = string - default = "uksouth" -} - -variable "resource_group_name" { - type = string - default = "pos" -} - -locals { - env_name = lower(terraform.workspace) - service_name = "pos" - web_app_name = "${local.service_name}-${local.env_name}-lxs-webapp" - key_vault_name = "${local.service_name}-ukho-${local.env_name}-kv" - service_name_bess = "bess" - container_name = "bess-configs" - - tags = { - SERVICE = "Periodic Output Service" - ENVIRONMENT = local.env_name - SERVICE_OWNER = "UKHO" - RESPONSIBLE_TEAM = "Abzu" - CALLOUT_TEAM = "On-Call_N/A" - COST_CENTRE = "A.008.02" - } -} - -variable "spoke_rg" { - type = string -} - -variable "spoke_vnet_name" { - type = string -} - -variable "spoke_subnet_name" { - type = string -} - -variable "agent_subscription_id" { - type = string -} - -variable "allowed_ips" { - type = list -} - -variable "elastic_apm_server_url" { - -} - -variable "elastic_apm_api_key" { - -} - -variable "permitdecryptionhardwareid" { - type = string -} - -variable "agent_2204_subnet" { - type = string -} - -variable "agent_prd_subnet" { - type = string -} - -variable "BessContainerName" { - type = string -} diff --git a/QALiveDeployment/swap_container_config.ps1 b/QALiveDeployment/swap_container_config.ps1 deleted file mode 100644 index 4f20050e..00000000 --- a/QALiveDeployment/swap_container_config.ps1 +++ /dev/null @@ -1,9 +0,0 @@ -param ( - [Parameter(Mandatory = $true)] [string] $resourcegroup, - [Parameter(Mandatory = $true)] [string] $webappname, - [Parameter(Mandatory = $true)] [string] $containername -) - -Write-Output "Set Webjob Configuration in appsetting..." -az webapp config appsettings set -g $resourcegroup -n $webappname --settings BessStorageConfiguration:ContainerName=$containername -az webapp restart --name $webappname --resource-group $resourcegroup diff --git a/QALiveDeployment/templates/continuous-deployment.yml b/QALiveDeployment/templates/continuous-deployment.yml deleted file mode 100644 index 3cc432ad..00000000 --- a/QALiveDeployment/templates/continuous-deployment.yml +++ /dev/null @@ -1,47 +0,0 @@ -parameters: - - name: ContinueEvenIfResourcesAreGettingDestroyed - type: boolean - default: false - - name: AzureSubscription - type: string - -steps: - - - task: PowerShell@2 - displayName: "Terraform $(Environment)deploy" - name: TerraformDeploy - inputs: - targetType: filePath - filePath: '$(Pipeline.Workspace)/qaliveterraformartifact/terraform_conditional_run.ps1' - arguments: '-deploymentResourceGroupName $(DeploymentResourceGroupName) -deploymentStorageAccountName $(DeploymentStorageAccountName) -workSpace $(Environment) -continueEvenIfResourcesAreGettingDestroyed $${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} -terraformJsonOutputFile $(Pipeline.Workspace)/qaliveterraformartifact/terraform_output.json -elasticApmServerUrl $(ElasticAPM_ServerURL) -elasticApmApiKey $(ElasticAPM_ApiKey)' - env: - ARM_CLIENT_ID: $(TERRAFORM-CLIENT-ID) - ARM_CLIENT_SECRET: $(TERRAFORM-CLIENT-SECRET) - ARM_TENANT_ID: $(TERRAFORM-TENANT-ID) - ARM_SUBSCRIPTION_ID: $(TERRAFORM-SUBSCRIPTION-ID) - TF_VAR_spoke_rg: $(spokeRG) - TF_VAR_spoke_vnet_name: $(spokeVnetName) - TF_VAR_spoke_subnet_name: $(POSESSspokeSubnetName) - TF_VAR_allowed_ips: $(whiteListedIps) - TF_VAR_permitdecryptionhardwareid: $(PermitDecryptionHardwareId) - TF_VAR_agent_2204_subnet: $(agent2204SubnetId) - TF_VAR_agent_prd_subnet: $(agentprdSubnetId) - TF_VAR_agent_subscription_id: $(agentSubscriptionId) - TF_VAR_BessContainerName: $(BessContainerForWebjob) - - - task: FileTransform@2 - displayName: "File Transform: POS Config" - inputs: - folderPath: '$(Pipeline.Workspace)/PeriodicOutputService/*.zip' - xmlTransformationRules: - jsonTargetFiles: '**/appsettings.json' - - - task: AzureWebApp@1 - displayName: "Azure LXS App Deploy: pos-$(Environment)-lxs-webapp" - inputs: - azureSubscription: "${{ parameters.AzureSubscription }}" - appType: webApp - appName: "$(WEB_APP_NAME)" - package: "$(Pipeline.Workspace)/PeriodicOutputService/PeriodicOutputFulfilmentService.zip" - - diff --git a/QALiveDeployment/terraform_conditional_run.ps1 b/QALiveDeployment/terraform_conditional_run.ps1 deleted file mode 100644 index 8b9217f4..00000000 --- a/QALiveDeployment/terraform_conditional_run.ps1 +++ /dev/null @@ -1,73 +0,0 @@ -param ( - [Parameter(Mandatory = $true)] [string] $deploymentResourceGroupName, - [Parameter(Mandatory = $true)] [string] $deploymentStorageAccountName, - [Parameter(Mandatory = $true)] [string] $workSpace, - [Parameter(Mandatory = $true)] [boolean] $continueEvenIfResourcesAreGettingDestroyed, - [Parameter(Mandatory = $true)] [string] $terraformJsonOutputFile, - [Parameter(Mandatory = $true)] [string] $elasticApmServerUrl, - [Parameter(Mandatory = $true)] [string] $elasticApmApiKey -) - -cd $env:AGENT_BUILDDIRECTORY/qaliveterraformartifact/src - -terraform --version - -Write-output "Executing terraform scripts for deployment in $workSpace enviroment" -terraform init -backend-config="resource_group_name=$deploymentResourceGroupName" -backend-config="storage_account_name=$deploymentStorageAccountName" -backend-config="key=posterraform.deployment.tfplan" -if ( !$? ) { echo "Something went wrong during terraform initialization"; throw "Error" } - -Write-output "Selecting workspace" - -$ErrorActionPreference = 'SilentlyContinue' -terraform workspace new $WorkSpace 2>&1 > $null -$ErrorActionPreference = 'Continue' - -terraform workspace select $workSpace -if ( !$? ) { echo "Error while selecting workspace"; throw "Error" } - -Write-output "Validating terraform" -terraform validate -if ( !$? ) { echo "Something went wrong during terraform validation" ; throw "Error" } - -Write-output "Execute Terraform plan" -terraform plan -out "posterraform.deployment.tfplan" -var elastic_apm_server_url=$elasticApmServerUrl -var elastic_apm_api_key=$elasticApmApiKey | tee terraform_output.txt -if ( !$? ) { echo "Something went wrong during terraform plan" ; throw "Error" } - -$totalDestroyLines=(Get-Content -Path terraform_output.txt | Select-String -Pattern "destroy" -CaseSensitive | where {$_ -ne ""}).length -if($totalDestroyLines -ge 2) -{ - write-Host("Terraform is destroying some resources, please verify...................") - if ( !$ContinueEvenIfResourcesAreGettingDestroyed) - { - write-Host("exiting...................") - Write-Output $_ - exit 1 - } - write-host("Continue executing terraform apply - as continueEvenIfResourcesAreGettingDestroyed param is set to true in pipeline") -} - -Write-output "Executing terraform apply" -terraform apply "posterraform.deployment.tfplan" -if ( !$? ) { echo "Something went wrong during terraform apply" ; throw "Error" } - -Write-output "Terraform output as json" -$terraformOutput = terraform output -json | ConvertFrom-Json - -write-output "Set JSON output into pipeline variables" -Write-Host "##vso[task.setvariable variable=Website_Url]$($terraformOutput.Website_Url.value)" -Write-Host "##vso[task.setvariable variable=WEB_APP_NAME]$($terraformOutput.web_app_name.value)" -Write-Host "##vso[task.setvariable variable=RGName]$($terraformOutput.webapp_rg.value)" -Write-Host "##vso[task.setvariable variable=WEBAPP;isOutput=true]$($terraformOutput.web_app_name.value)" -Write-Host "##vso[task.setvariable variable=ResourceGroup;isOutput=true]$($terraformOutput.webapp_rg.value)" -Write-Host "##vso[task.setvariable variable=webJobUsername;isOutput=true]$($terraformOutput.webjob_username.value)" -Write-Host "##vso[task.setvariable variable=webJobPassword;issecret=true;isOutput=true]$($terraformOutput.webjob_password.value)" -Write-Host "##vso[task.setvariable variable=AzureStorageConfiguration.ConnectionString;issecret=true]$($terraformOutput.pos_storage_connection_string.value)" -Write-Host "##vso[task.setvariable variable=BessStorageConfiguration.ConnectionString;issecret=true]$($terraformOutput.bess_storage_connection_string.value)" -Write-Host "##vso[task.setvariable variable=EventHubLoggingConfiguration.ConnectionString;issecret=true]$($terraformOutput.log_primary_connection_string.value)" -Write-Host "##vso[task.setvariable variable=EventHubLoggingConfiguration.EntityPath;issecret=true]$($terraformOutput.entity_path.value)" -Write-Host "##vso[task.setvariable variable=ApplicationInsights.ConnectionString;issecret=true]$($terraformOutput.connection_string.value)" -Write-Host "##vso[task.setvariable variable=AzureWebJobsStorage;issecret=true]$($terraformOutput.bess_storage_connection_string.value)" -Write-Host "##vso[task.setvariable variable=AzureWebJobsStorageName;issecret=true;isOutput=true]$($terraformOutput.bess_storage_connection_string.value)" -Write-Host "##vso[task.setvariable variable=KeyVaultSettings.ServiceUri]$($terraformOutput.keyvault_uri.value)" - -$terraformOutput | ConvertTo-Json -Depth 5 > $terraformJsonOutputFile diff --git a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/BaseController.cs b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/BaseController.cs index 9a226534..3fa64a3c 100644 --- a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/BaseController.cs +++ b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/BaseController.cs @@ -7,7 +7,6 @@ namespace UKHO.FmEssFssMock.API.Controllers public class BaseController : ControllerBase { private readonly IHttpContextAccessor httpContextAccessor; - protected new HttpContext HttpContext => httpContextAccessor.HttpContext; public BaseController(IHttpContextAccessor httpContextAccessor) { diff --git a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/ExchangeSetServiceController.cs b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/ExchangeSetServiceController.cs index 5b3559fd..919634fc 100644 --- a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/ExchangeSetServiceController.cs +++ b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/ExchangeSetServiceController.cs @@ -29,11 +29,7 @@ public IActionResult GetProductDataSinceDateTime([FromQuery] string sinceDateTim if (string.IsNullOrEmpty(exchangeSetStandard) || exchangeSetStandard.Equals(ExchangeSetStandard.s63.ToString()) || exchangeSetStandard.Equals(ExchangeSetStandard.s57.ToString())) { - ExchangeSetServiceResponse? response = _exchangeSetService.CreateExchangeSetForGetProductDataSinceDateTime(sinceDateTime, exchangeSetStandard); - if (response == null) - { - return BadRequest(); - } + ExchangeSetServiceResponse response = _exchangeSetService.CreateExchangeSetForGetProductDataSinceDateTime(sinceDateTime, exchangeSetStandard); return Ok(response.ResponseBody); } } @@ -44,7 +40,7 @@ public IActionResult GetProductDataSinceDateTime([FromQuery] string sinceDateTim [Route("/ess/productData/productIdentifiers")] public IActionResult PostProductIdentifiers([FromBody] string[] productIdentifiers, [FromQuery] string? exchangeSetStandard) { - if (productIdentifiers != null && productIdentifiers.Any()) + if (productIdentifiers.Any()) { if (!string.IsNullOrEmpty(exchangeSetStandard)) { @@ -54,11 +50,7 @@ public IActionResult PostProductIdentifiers([FromBody] string[] productIdentifie if (string.IsNullOrEmpty(exchangeSetStandard) || exchangeSetStandard.Equals(ExchangeSetStandard.s63.ToString()) || exchangeSetStandard.Equals(ExchangeSetStandard.s57.ToString())) { ExchangeSetServiceResponse? response = _exchangeSetService.CreateExchangeSetForPostProductIdentifier(productIdentifiers, exchangeSetStandard); - if (response == null) - { - return BadRequest(); - } - return Ok(response.ResponseBody); + return Ok(response?.ResponseBody); } } return BadRequest(); @@ -68,7 +60,7 @@ public IActionResult PostProductIdentifiers([FromBody] string[] productIdentifie [Route("/ess/productData/productVersions")] public IActionResult PostProductVersions([FromBody] List productVersionRequest, [FromQuery] string? exchangeSetStandard) { - if (productVersionRequest != null && productVersionRequest.Any()) + if (productVersionRequest.Any()) { if (!string.IsNullOrEmpty(exchangeSetStandard)) { @@ -77,11 +69,7 @@ public IActionResult PostProductVersions([FromBody] List if (string.IsNullOrEmpty(exchangeSetStandard) || exchangeSetStandard.Equals(ExchangeSetStandard.s63.ToString()) || exchangeSetStandard.Equals(ExchangeSetStandard.s57.ToString()) && !productVersionRequest.Any(i => i.EditionNumber == null && i.UpdateNumber == null)) { - ExchangeSetServiceResponse? response = _exchangeSetService.CreateExchangeSetForPostProductVersion(productVersionRequest, exchangeSetStandard); - if (response == null) - { - return BadRequest(); - } + ExchangeSetServiceResponse response = _exchangeSetService.CreateExchangeSetForPostProductVersion(productVersionRequest, exchangeSetStandard); return Ok(response.ResponseBody); } } diff --git a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/FileShareServiceController.cs b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/FileShareServiceController.cs index 82c724e5..b62d5efe 100644 --- a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/FileShareServiceController.cs +++ b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/FileShareServiceController.cs @@ -15,9 +15,6 @@ public class _fileShareServiceController : BaseController { private readonly FileShareService _fileShareService; - private readonly IConfiguration _configuration; - private readonly IOptions _fssConfiguration; - public Dictionary ErrorsCreateBatch { get; set; } public Dictionary ErrorsPutBlocksInFile { get; set; } public Dictionary ErrorsCommitBatch { get; set; } @@ -28,7 +25,6 @@ public class _fileShareServiceController : BaseController public _fileShareServiceController(IHttpContextAccessor httpContextAccessor, FileShareService fileShareService, IConfiguration configuration, IOptions fssConfiguration) : base(httpContextAccessor) { _fileShareService = fileShareService; - _fssConfiguration = fssConfiguration; ErrorsCreateBatch = new Dictionary { @@ -50,8 +46,7 @@ public _fileShareServiceController(IHttpContextAccessor httpContextAccessor, Fil { "source","FileError" }, { "description","Error while creating file" } }; - _configuration = configuration; - _homeDirectoryPath = Path.Combine(_configuration["HOME"], _configuration["POSFolderName"]); + _homeDirectoryPath = Path.Combine(configuration["HOME"], configuration["POSFolderName"]); } @@ -59,13 +54,10 @@ public _fileShareServiceController(IHttpContextAccessor httpContextAccessor, Fil [Route("/fss/batch")] public IActionResult CreateBatch([FromBody] CreateBatchRequest batchRequest) { - if (batchRequest != null && !string.IsNullOrEmpty(batchRequest.BusinessUnit)) + if (!string.IsNullOrEmpty(batchRequest.BusinessUnit)) { - BatchResponse? response = _fileShareService.CreateBatch(batchRequest.Attributes, _homeDirectoryPath); - if (response != null) - { - return Created(string.Empty, response); - } + BatchResponse response = _fileShareService.CreateBatch(batchRequest.Attributes, _homeDirectoryPath); + return Created(string.Empty, response); } return BadRequest(); } @@ -77,18 +69,13 @@ public IActionResult GetBatchDetails([FromRoute] string batchId) if (!string.IsNullOrEmpty(batchId)) { string path = Path.Combine(_homeDirectoryPath, batchId); - if (Directory.Exists(path)) - { - BatchDetail response = _fileShareService.GetBatchDetails(batchId, _homeDirectoryPath); - if (response != null) - { - return Ok(response); - } - } - else + if (!Directory.Exists(path)) { return NotFound(); } + + BatchDetail response = _fileShareService.GetBatchDetails(batchId, _homeDirectoryPath); + return Ok(response); } return BadRequest(); } @@ -118,7 +105,7 @@ public IActionResult UploadBlockOfFile([FromRoute, SwaggerSchema(Format = "GUID" [FromHeader(Name = "Content-Type"), SwaggerSchema(Format = "MIME"), SwaggerParameter(Required = true)] string contentType, [FromBody] object data) { - if (!string.IsNullOrEmpty(batchId) && data != null && !string.IsNullOrEmpty(blockId)) + if (!string.IsNullOrEmpty(batchId) && !string.IsNullOrEmpty(blockId)) { bool response = _fileShareService.UploadBlockOfFile(batchId, _homeDirectoryPath, fileName); if (response) @@ -137,7 +124,7 @@ public IActionResult PutBlocksInFile([FromRoute, SwaggerSchema(Format = "GUID"), [FromRoute, SwaggerParameter(Required = true)] string fileName, [FromBody, SwaggerParameter(Required = true)] FileCommitPayload payload) { - if (!string.IsNullOrEmpty(batchId) && !string.IsNullOrEmpty(fileName) && payload != null) + if (!string.IsNullOrEmpty(batchId) && !string.IsNullOrEmpty(fileName)) { bool response = _fileShareService.CheckBatchWithFileExist(batchId, fileName, _homeDirectoryPath); if (response) @@ -154,7 +141,7 @@ public IActionResult PutBlocksInFile([FromRoute, SwaggerSchema(Format = "GUID"), [Produces("application/json")] public IActionResult CommitBatch([FromRoute] string batchId, [FromBody] List body) { - if (!string.IsNullOrEmpty(batchId) && body != null) + if (!string.IsNullOrEmpty(batchId)) { bool response = _fileShareService.CheckBatchWithFileExist(batchId, body.Select(a => a.FileName).FirstOrDefault(), _homeDirectoryPath); if (response) @@ -211,10 +198,7 @@ public IActionResult GetBatchResponse([FromQuery(Name = "$filter")] string filte { SearchBatchResponse response = _fileShareService.GetBatchResponse(filter, _homeDirectoryPath); - if (response != null) - { - return Ok(response); - } + return Ok(response); } return BadRequest(); } diff --git a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/FleetManagerController.cs b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/FleetManagerController.cs index 11d76670..7a5c97d5 100644 --- a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/FleetManagerController.cs +++ b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/FleetManagerController.cs @@ -21,8 +21,7 @@ public FleetManagerController(IOptions fmConfig { _fmConfiguration = fmConfiguration; _configuration = configuration; - - _homeDirectoryPath = Path.Combine(_configuration["HOME"], _configuration["POSFolderName"]); + _homeDirectoryPath = Path.Combine(configuration["HOME"], configuration["POSFolderName"]); } [HttpGet] diff --git a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/MockController.cs b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/MockController.cs index a8bf9cf6..ef9d21fe 100644 --- a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/MockController.cs +++ b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Controllers/MockController.cs @@ -18,7 +18,6 @@ public MockController(MockService mockService, IConfiguration configuration, Azu { this.mockService = mockService; this.azureStorageService = azureStorageService; - homeDirectoryPath = Path.Combine(configuration["HOME"], configuration["POSFolderName"]); } diff --git a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Helpers/FileHelper.cs b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Helpers/FileHelper.cs index 49b15857..ec9c5884 100644 --- a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Helpers/FileHelper.cs +++ b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Helpers/FileHelper.cs @@ -1,4 +1,5 @@ -using System.Security.Cryptography; +using System.Globalization; +using System.Security.Cryptography; using Newtonsoft.Json; namespace UKHO.FmEssFssMock.API.Helpers @@ -20,17 +21,6 @@ public static void CheckAndCreateFolder(string folderPath) Directory.CreateDirectory(folderPath); } - public static void CreateFileContentWithBytes(string uploadBlockFilePath, byte[] content) - { - if (ValidateFilePath(uploadBlockFilePath)) - { - using (FileStream output = File.OpenWrite(uploadBlockFilePath)) - { - output.Write(content, 0, content.Length); - } - } - } - public static bool CheckBatchWithFileExist(string filePathWithFileName) { return ValidateFilePath(filePathWithFileName) && File.Exists(filePathWithFileName); @@ -61,8 +51,34 @@ public static string GetFileMD5(FileInfo fileInfo) { using Stream? fileStream = fileInfo.OpenRead(); using var md5 = MD5.Create(); - byte[]? fileMd5Hash = md5.ComputeHash(fileStream); + byte[] fileMd5Hash = md5.ComputeHash(fileStream); return Convert.ToBase64String(fileMd5Hash); } + + public static void CopyAllFiles(string srcFile, string destFile) + { + string weekNumber = CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(DateTime.UtcNow, CalendarWeekRule.FirstFullWeek, DayOfWeek.Thursday).ToString().PadLeft(2, '0'); + string currentYear = DateTime.UtcNow.ToString("yy"); + // Ensure the destination directory exists + Directory.CreateDirectory(destFile); + + // Get all files from the source directory + string[] files = Directory.GetFiles(srcFile); + + foreach (string filePath in files) + { + // Get the file name + string fileName = Path.GetFileName(filePath); + if (fileName.Contains("WK")) + { + fileName = fileName.Replace("WK34_22", $"WK{weekNumber}_{currentYear}"); + } + // Create the destination file path + string destFilePath = Path.Combine(destFile, fileName); + + // Copy the file + File.Copy(filePath, destFilePath, overwrite: true); + } + } } } diff --git a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Services/ExchangeSetService.cs b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Services/ExchangeSetService.cs index f0ef8256..2adf77e3 100644 --- a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Services/ExchangeSetService.cs +++ b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Services/ExchangeSetService.cs @@ -53,7 +53,6 @@ public ExchangeSetServiceResponse CreateExchangeSetForGetProductDataSinceDateTim return null; } - public ExchangeSetServiceResponse CreateExchangeSetForPostProductIdentifier(string[] productIdentifiers, string exchangeSetStandard) { string productIdentifiersPattern = "productIdentifier-" + string.Join("-", productIdentifiers); @@ -157,8 +156,12 @@ public ExchangeSetServiceResponse CreateExchangeSetForPostProductVersion(List? responseData = FileHelper.ReadJsonFile>(_essConfiguration.Value.EssDataDirectoryPath + _essConfiguration.Value.PostProductIdentifiersResponseFileName); - ExchangeSetServiceResponse? selectedProductIdentifier = responseData?.FirstOrDefault(a => a.Id.ToLowerInvariant() == responseId.ToLowerInvariant()); + List responseData = FileHelper.ReadJsonFile>(_essConfiguration.Value.EssDataDirectoryPath + _essConfiguration.Value.PostProductIdentifiersResponseFileName); + ExchangeSetServiceResponse selectedProductIdentifier = responseData.FirstOrDefault(a => a.Id.ToLowerInvariant() == responseId.ToLowerInvariant()); + if(selectedProductIdentifier == null) + { + return null; + } selectedProductIdentifier.ResponseBody.ExchangeSetUrlExpiryDateTime = DateTime.UtcNow.AddDays(1).ToString("yyyy-MM-ddTHH:mm:ss.fffZ", CultureInfo.InvariantCulture); return selectedProductIdentifier; } diff --git a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Services/FileShareService.cs b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Services/FileShareService.cs index d9cc279e..e4788b6f 100644 --- a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Services/FileShareService.cs +++ b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/Services/FileShareService.cs @@ -1,4 +1,5 @@ using System.Globalization; +using System.Text.RegularExpressions; using Microsoft.Extensions.Options; using UKHO.FmEssFssMock.API.Common; using UKHO.FmEssFssMock.API.Helpers; @@ -10,7 +11,7 @@ namespace UKHO.FmEssFssMock.API.Services public class FileShareService { private readonly IOptions fssConfiguration; - private readonly string aioInfoFilesBatchId = "649C902D-5282-4CCF-924A-2B548EF42179"; + private readonly string aioInfoFilesBatchId = "649C902D-5282-4CCF-924A-2B548EF42179"; private readonly Dictionary mimeTypes = new() { { ".zip", "application/zip" }, @@ -59,13 +60,12 @@ public BatchResponse CreateBatch(IEnumerable> attri string batchFolderPath = Path.Combine(homeDirectoryPath, batchId); FileHelper.CheckAndCreateFolder(batchFolderPath); - return new BatchResponse() { BatchId = Guid.Parse(batchId) }; + return new BatchResponse { BatchId = Guid.Parse(batchId) }; } public BatchDetail GetBatchDetails(string batchId, string homeDirectoryPath) { batchId = batchId.ToLower(); - CultureInfo cultureInfo = CultureInfo.InvariantCulture; string currentWeek = CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(DateTime.UtcNow, CalendarWeekRule.FirstFullWeek, DayOfWeek.Thursday).ToString().PadLeft(2, '0'); string currentYear = DateTime.UtcNow.Year.ToString(); string path = Path.Combine(homeDirectoryPath, batchId); @@ -76,20 +76,20 @@ public BatchDetail GetBatchDetails(string batchId, string homeDirectoryPath) { FileInfo fileInfo = new(filePath); - files.Add(new BatchFile() + files.Add(new BatchFile { Attributes = new List { - new Models.Response.Attribute { Key = "Product Type", Value = aioBatchTypes.Contains(EnumHelper.GetValueFromDescription(batchId)) ? "AIO" : "AVCS" }, - new Models.Response.Attribute { Key = "File Name", Value = fileInfo.Name } + new () { Key = "Product Type", Value = aioBatchTypes.Contains(EnumHelper.GetValueFromDescription(batchId)) ? "AIO" : "AVCS" }, + new () { Key = "File Name", Value = fileInfo.Name } }, MimeType = mimeTypes.ContainsKey(fileInfo.Extension.ToLower()) ? mimeTypes[fileInfo.Extension.ToLower()] : DEFAULTMIMETYPE, FileSize = fileInfo.Length, Hash = FileHelper.GetFileMD5(fileInfo), Filename = fileInfo.Name, - Links = new Links() + Links = new Links { - Get = new Link() + Get = new Link { Href = "/batch/" + batchId + "/files/" + fileInfo.Name } @@ -227,24 +227,34 @@ public bool CheckBatchWithFileExist(string batchid, string fileName, string home public bool AddFile(string batchId, string fileName, string homeDirectoryPath) { string batchFolderPath = Path.Combine(homeDirectoryPath, batchId); + string batchFolderPathSanatized = Regex.Replace(batchFolderPath, "[^a-zA-Z0-9-_]", ""); + if (!FileHelper.CheckFolderExists(batchFolderPathSanatized)) + { + Directory.CreateDirectory(batchFolderPathSanatized); + } - if (FileHelper.CheckFolderExists(batchFolderPath)) + string srcFile = Path.Combine(Environment.CurrentDirectory, @"Data", batchId, RenameFiles(fileName)); + string destFile = Path.Combine(Path.Combine(homeDirectoryPath, batchId), fileName); + if (!string.Equals(srcFile, destFile)) { - string srcFile = Path.Combine(Environment.CurrentDirectory, @"Data", batchId, RenameFiles(fileName)); - string destFile = Path.Combine(Path.Combine(homeDirectoryPath, batchId), fileName); File.Copy(srcFile, destFile, true); - string permitXmlFile = Path.Combine(Environment.CurrentDirectory, @"Data", batchId, PERMITXMLFILENAME); - string permitTxtFile = Path.Combine(Environment.CurrentDirectory, @"Data", batchId, PERMITTXTFILENAME); + string permitXmlFile = + Path.Combine(Environment.CurrentDirectory, @"Data", batchId, PERMITXMLFILENAME); + string permitTxtFile = + Path.Combine(Environment.CurrentDirectory, @"Data", batchId, PERMITTXTFILENAME); if (File.Exists(permitXmlFile)) { - srcFile = Path.Combine(Environment.CurrentDirectory, @"Data", batchId, RenameFiles(PERMITXMLFILENAME)); + srcFile = Path.Combine(Environment.CurrentDirectory, @"Data", batchId, + RenameFiles(PERMITXMLFILENAME)); destFile = Path.Combine(Path.Combine(homeDirectoryPath, batchId), PERMITXMLFILENAME); File.Copy(srcFile, destFile, true); } + if (File.Exists(permitTxtFile)) { - srcFile = Path.Combine(Environment.CurrentDirectory, @"Data", batchId, RenameFiles(PERMITTXTFILENAME)); + srcFile = Path.Combine(Environment.CurrentDirectory, @"Data", batchId, + RenameFiles(PERMITTXTFILENAME)); destFile = Path.Combine(Path.Combine(homeDirectoryPath, batchId), PERMITTXTFILENAME); File.Copy(srcFile, destFile, true); } @@ -255,7 +265,7 @@ public bool AddFile(string batchId, string fileName, string homeDirectoryPath) private string RenameFiles(string fileName) { - return fileName.IndexOf("WK") > -1 ? fileName.Replace(fileName.Substring(fileName.IndexOf("WK"), 7), "WK34_22") : fileName; + return fileName.IndexOf("WK", StringComparison.Ordinal) > -1 ? fileName.Replace(fileName.Substring(fileName.IndexOf("WK", StringComparison.Ordinal), 7), "WK34_22") : fileName; } public BatchStatusResponse GetBatchStatus(string batchId, string homeDirectoryPath) @@ -282,21 +292,21 @@ public SearchBatchResponse GetBatchResponse(string filter, string homeDirectoryP { return GetSearchBatchResponse(homeDirectoryPath, fssConfiguration.Value.FssInfoResponseFileName, aioInfoFilesBatchId); } - else if (filter.ToUpper().Contains(BESPOKEREADME)) + if (filter.ToUpper().Contains(BESPOKEREADME)) { return GetSearchBatchResponse(homeDirectoryPath, fssConfiguration.Value.FssSingleReadMeResponseFileName, bessSingleReadmeFileBatchId); } - else if (filter.ToUpper().Contains(MULTIPLEFILES)) + if (filter.ToUpper().Contains(MULTIPLEFILES)) { return GetSearchBatchResponse(homeDirectoryPath, fssConfiguration.Value.FssMultipleReadMeResponseFileName, bessMultipleFilesBatchId); } - return new SearchBatchResponse() + return new SearchBatchResponse { Entries = new List(), - _Links = new PagingLinks() + _Links = new PagingLinks { - Self = new Link() + Self = new Link { Href = "/batch?limit=10&start=0&$filter=%24batch%28Content%29%20eq%20%27AIO%20CD%20INFO%27%20and%20%24batch%28Product%20Type%29%20eq%20%27%27" }, diff --git a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API.csproj b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API.csproj index 4cc217e1..bf5d3b2c 100644 --- a/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API.csproj +++ b/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API/UKHO.FmEssFssMock.API.csproj @@ -260,8 +260,4 @@ - - - - - + diff --git a/UKHO.PeriodicOutputService/UKHO.AdmiraltyInformationOverlay.Fulfilment/Services/FulfilmentDataService.cs b/UKHO.PeriodicOutputService/UKHO.AdmiraltyInformationOverlay.Fulfilment/Services/FulfilmentDataService.cs index d3b35293..546ce2eb 100644 --- a/UKHO.PeriodicOutputService/UKHO.AdmiraltyInformationOverlay.Fulfilment/Services/FulfilmentDataService.cs +++ b/UKHO.PeriodicOutputService/UKHO.AdmiraltyInformationOverlay.Fulfilment/Services/FulfilmentDataService.cs @@ -38,7 +38,7 @@ public class FulfilmentDataService : IFulfilmentDataService { ".sha1", "text/plain" } }; - private ITransaction _currentTransaction => Agent.Tracer.CurrentTransaction; + private ITransaction? _currentTransaction => Agent.Tracer.CurrentTransaction; public FulfilmentDataService(IFileSystemHelper fileSystemHelper, IEssService essService, @@ -61,26 +61,20 @@ public async Task CreateAioExchangeSetsAsync() { _fileSystemHelper.CreateDirectory(_homeDirectoryPath); - bool isSuccess = false; - _logger.LogInformation(EventIds.GetLatestProductVersionDetailsStarted.ToEventId(), "Getting latest product version details started | {DateTime} | _X-Correlation-ID : {CorrelationId}", DateTime.Now.ToUniversalTime(), CommonHelper.CorrelationID); var productVersionEntities = _azureTableStorageHelper.GetLatestProductVersionDetails(); _logger.LogInformation(EventIds.GetLatestProductVersionDetailsCompleted.ToEventId(), "Getting latest product version details completed | {DateTime} | _X-Correlation-ID : {CorrelationId}", DateTime.Now.ToUniversalTime(), CommonHelper.CorrelationID); - Task[] tasks = null; - - Task aioBaseExchangeSetTask = Task.Run(() => CreateAioBaseExchangeSet()); + Task aioBaseExchangeSetTask = Task.Run(CreateAioBaseExchangeSet); Task updateAioExchangeSetTask = Task.Run(() => CreateUpdateAIOExchangeSet(productVersionEntities)); - - tasks = new Task[] { aioBaseExchangeSetTask, updateAioExchangeSetTask }; - await Task.WhenAll(tasks); + Task[] tasks = { aioBaseExchangeSetTask, updateAioExchangeSetTask }; - isSuccess = true; + await Task.WhenAll(tasks); - return isSuccess; + return true; } private async Task CreateAioBaseExchangeSet() @@ -142,7 +136,7 @@ private async Task CreateAioBaseExchangeSet() span?.End(); } - + _logger.LogInformation(EventIds.AioBaseExchangeSetCreationCompleted.ToEventId(), "Creation of AIO base exchange set completed | {DateTime} | _X-Correlation-ID : {CorrelationId}", DateTime.Now.ToUniversalTime(), CommonHelper.CorrelationID); } @@ -309,7 +303,7 @@ private List RenameFiles(string downloadPath, List f foreach (FssBatchFile? file in files) { IFileInfo fileInfo = _fileSystemHelper.GetFileInfo(Path.Combine(downloadPath, file.FileName)); - string weekNumber = CommonHelper.GetCurrentWeekNumber(DateTime.UtcNow).ToString(); + string weekNumber = CommonHelper.GetCurrentWeekNumber(DateTime.UtcNow); string currentYear = DateTime.UtcNow.ToString("yy"); file.VolumeIdentifier = "V01X01"; if (batchType == Batch.EssAioBaseZipBatch) @@ -432,9 +426,9 @@ private async Task DownloadAioAncillaryFilesAsync(string batchId) IEnumerable fileDetails = await _fssService.GetAioInfoFolderFilesAsync(batchId, CommonHelper.CorrelationID.ToString()); - if (fileDetails != null && fileDetails.Any()) + if (fileDetails.Any()) { - string weekNumber = CommonHelper.GetCurrentWeekNumber(DateTime.UtcNow).ToString(); + string weekNumber = CommonHelper.GetCurrentWeekNumber(DateTime.UtcNow); string aioInfoFolderPath = string.Format(_configuration["AIOAdditionalContentFilePath"], weekNumber, DateTime.UtcNow.ToString("yy")); string aioExchangeSetInfoPath = Path.Combine(_homeDirectoryPath, batchId, aioInfoFolderPath); @@ -452,7 +446,7 @@ private async Task DownloadAioAncillaryFilesAsync(string batchId) private ProductVersionsRequest GetTheLatestUpdateNumber(string filePath, string[] aioCellNames) { - string weekNumber = CommonHelper.GetCurrentWeekNumber(DateTime.UtcNow).ToString(); + string weekNumber = CommonHelper.GetCurrentWeekNumber(DateTime.UtcNow); string aioInfoFolderPath = string.Format(_configuration["AioUpdateZipFileName"], weekNumber, DateTime.UtcNow.ToString("yy")); string aioExchangeSetInfoPath = Path.Combine(filePath, Path.GetFileNameWithoutExtension(aioInfoFolderPath)); diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/FunctionalTests/CallEssEndPoint.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/FunctionalTests/CallEssEndPoint.cs index eea94989..4cae50dc 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/FunctionalTests/CallEssEndPoint.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/FunctionalTests/CallEssEndPoint.cs @@ -40,7 +40,6 @@ public async Task WhenICallTheExchangeSetApiWithValidProductIdentifiers_ThenANon //verify model structure await apiResponse.CheckModelStructureForSuccessResponse(); - } [Test] @@ -58,7 +57,7 @@ public async Task WhenICallTheExchangeSetApiWithInValidProductIdentifiers_ThenVa //Check RequestedProductsNotInExchangeSet is not empty apiResponseData.RequestedProductsNotInExchangeSet.Should().NotBeEmpty(); - apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault(p => p.ProductName.Equals("ABCDEFGH")).Reason.Should().Be("invalidProduct"); + apiResponseData.RequestedProductsNotInExchangeSet.FirstOrDefault(p => p.ProductName.Equals("ABCDEFGH"))?.Reason.Should().Be("invalidProduct"); } [Test] diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/FunctionalTests/GetAVCSCatalogue.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/FunctionalTests/GetAVCSCatalogue.cs index 126389db..916c7afa 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/FunctionalTests/GetAVCSCatalogue.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/FunctionalTests/GetAVCSCatalogue.cs @@ -11,7 +11,6 @@ public class GetAVCSCatalogue : ObjectStorage [OneTimeSetUp] public Task Setup() { - //testConfiguration = new TestConfiguration(); getunp = new GetUNPResponse(); getcat = new GetCatalogue(); diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/AuthTokenProvider.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/AuthTokenProvider.cs index 315f69cd..992b3388 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/AuthTokenProvider.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/AuthTokenProvider.cs @@ -5,8 +5,8 @@ namespace UKHO.PeriodicOutputService.API.FunctionalTests.Helpers { public class AuthTokenProvider { - private static string EssAccessToken = null; - private static string FssAccessToken = null; + private static string EssAccessToken; + private static string FssAccessToken; private static readonly ESSApiConfiguration EssauthConfig = new TestConfiguration().EssConfig; private static readonly FSSApiConfiguration FssAuthConfig = new TestConfiguration().FssConfig; @@ -17,10 +17,10 @@ public async Task GetEssToken() return EssAccessToken; } - private static async Task GenerateEssToken(string ClientId, string ClientSecret, string Token) + private static async Task GenerateEssToken(string clientId, string clientSecret, string token) { string[] scopes = new string[] { $"{EssauthConfig.EssClientId}/.default" }; - if (Token == null) + if (token == null) { if (EssauthConfig.IsRunningOnLocalMachine) { @@ -31,21 +31,21 @@ private static async Task GenerateEssToken(string ClientId, string Clien AuthenticationResult tokenTask = await debugApp.AcquireTokenInteractive(scopes) .WithTenantIdFromAuthority(new Uri($"{EssauthConfig.MicrosoftOnlineLoginUrl}{EssauthConfig.TenantId}")) .ExecuteAsync(); - Token = tokenTask.AccessToken; + token = tokenTask.AccessToken; } else { - IConfidentialClientApplication app = ConfidentialClientApplicationBuilder.Create(ClientId) - .WithClientSecret(ClientSecret) + IConfidentialClientApplication app = ConfidentialClientApplicationBuilder.Create(clientId) + .WithClientSecret(clientSecret) .WithAuthority(new Uri($"{EssauthConfig.MicrosoftOnlineLoginUrl}{EssauthConfig.TenantId}")) .Build(); AuthenticationResult tokenTask = await app.AcquireTokenForClient(scopes).ExecuteAsync(); - Token = tokenTask.AccessToken; + token = tokenTask.AccessToken; } } - return Token; + return token; } public async Task GetFssToken() @@ -54,10 +54,10 @@ public async Task GetFssToken() return FssAccessToken; } - private static async Task GenerateFssToken(string ClientId, string ClientSecret, string Token) + private static async Task GenerateFssToken(string clientId, string clientSecret, string token) { - string[] scopes = new string[] { $"{FssAuthConfig.FssClientId}/.default" }; - if (Token == null) + string[] scopes = { $"{FssAuthConfig.FssClientId}/.default" }; + if (token == null) { if (FssAuthConfig.IsRunningOnLocalMachine) { @@ -68,21 +68,21 @@ private static async Task GenerateFssToken(string ClientId, string Clien AuthenticationResult tokenTask = await debugApp.AcquireTokenInteractive(scopes) .WithTenantIdFromAuthority(new Uri($"{EssauthConfig.MicrosoftOnlineLoginUrl}{EssauthConfig.TenantId}")) .ExecuteAsync(); - Token = tokenTask.AccessToken; + token = tokenTask.AccessToken; } else { - IConfidentialClientApplication app = ConfidentialClientApplicationBuilder.Create(ClientId) - .WithClientSecret(ClientSecret) + IConfidentialClientApplication app = ConfidentialClientApplicationBuilder.Create(clientId) + .WithClientSecret(clientSecret) .WithAuthority(new Uri($"{EssauthConfig.MicrosoftOnlineLoginUrl}{EssauthConfig.TenantId}")) .Build(); AuthenticationResult tokenTask = await app.AcquireTokenForClient(scopes).ExecuteAsync(); - Token = tokenTask.AccessToken; + token = tokenTask.AccessToken; } } - return Token; + return token; } } diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/CommonHelper.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/CommonHelper.cs index 2bf55ab0..4c66fb85 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/CommonHelper.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/CommonHelper.cs @@ -35,7 +35,7 @@ public static async Task ReadAsStringAsync(this HttpResponseMessage http public static dynamic XmlReadAsynch(string xmlreponse) { - XmlDocument doc = new XmlDocument(); + XmlDocument doc = new (); doc.LoadXml(xmlreponse); string jsonText = JsonConvert.SerializeXmlNode(doc); dynamic deserializeJsonText = JsonConvert.DeserializeObject(jsonText); @@ -60,7 +60,7 @@ public static async Task RunWebJob() WebJob = new POSWebJob(); if (!posWebJob.IsRunningOnLocalMachine) { - string POSWebJobUserCredentialsBytes = CommonHelper.GetBase64EncodedCredentials(posWebJob.UserName, posWebJob.Password); + string POSWebJobUserCredentialsBytes = GetBase64EncodedCredentials(posWebJob.UserName, posWebJob.Password); POSWebJobApiResponse = await WebJob.POSWebJobEndPoint(posWebJob.BaseUrl, POSWebJobUserCredentialsBytes); POSWebJobApiResponse.StatusCode.Should().Be((HttpStatusCode)202); @@ -74,7 +74,7 @@ public static async Task RunWebJobAio() WebJob = new POSWebJob(); if (!posWebJob.IsRunningOnLocalMachine) { - string POSWebJobUserCredentialsBytes = CommonHelper.GetBase64EncodedCredentials(posWebJob.UserName, posWebJob.Password); + string POSWebJobUserCredentialsBytes = GetBase64EncodedCredentials(posWebJob.UserName, posWebJob.Password); POSWebJobApiResponse = await WebJob.POSWebJobEndPoint(aioWebJob.BaseUrl, POSWebJobUserCredentialsBytes); POSWebJobApiResponse.StatusCode.Should().Be((HttpStatusCode)202); diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/FileContentHelper.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/FileContentHelper.cs index 525497f8..c0798f29 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/FileContentHelper.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/FileContentHelper.cs @@ -112,7 +112,7 @@ public static async Task> DownloadCatalogueXmlOrEncUpdatesListCsvFi public static async Task VerifyPosBatches(string fssJwtToken) { - string[] posBatchId = { posDetails.IsoSha1BatchId, posDetails.ZipFilesBatchId ,posDetails.CatalogueBatchId, posDetails.UpdateExchangeSetBatchId , posDetails.EncUpdateListCsvBatchId }; + string[] posBatchId = { posDetails.IsoSha1BatchId, posDetails.ZipFilesBatchId, posDetails.CatalogueBatchId, posDetails.UpdateExchangeSetBatchId, posDetails.EncUpdateListCsvBatchId }; foreach(string posBatchIdNumber in posBatchId) { @@ -126,7 +126,7 @@ public static async Task VerifyPosBatches(string fssJwtToken) string filename = "AIO_S631-1_CD_WK" + weekNumber + "_" + currentYear; var downloadFileUrl = $"{Config.FssConfig.BaseUrl}/batch/{batchId}/files/{filename}.zip"; - var extractDownloadedFolder = await FssBatchHelper.ExtractDownloadedAioFolder(downloadFileUrl.ToString(), FssJwtToken); + var extractDownloadedFolder = await FssBatchHelper.ExtractDownloadedAioFolder(downloadFileUrl, FssJwtToken); return extractDownloadedFolder; } diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/FssApiClient.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/FssApiClient.cs index fd7651ac..7d4c35ce 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/FssApiClient.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/FssApiClient.cs @@ -33,7 +33,6 @@ public async Task GetBatchStatusAsync(string uri, string ac /// public async Task GetFileDownloadAsync(string uri, string filerangeheader = null, string accessToken = null) { - using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri)) { if (filerangeheader != null) diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/FssBatchHelper.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/FssBatchHelper.cs index 12e261fe..7d81595b 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/FssBatchHelper.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/FssBatchHelper.cs @@ -8,7 +8,7 @@ namespace UKHO.PeriodicOutputService.API.FunctionalTests.Helpers { public static class FssBatchHelper { - private static FssApiClient FssApiClient { get; set; } + private static FssApiClient FssApiClient { get; } private static readonly POSFileDetails posDetails = new TestConfiguration().posFileDetails; private static readonly TestConfiguration config = new(); private static readonly string weekNumber = CultureInfo.InvariantCulture.Calendar.GetWeekOfYear(DateTime.UtcNow, CalendarWeekRule.FirstFullWeek, DayOfWeek.Thursday).ToString().PadLeft(2, '0'); diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/GetProductIdentifiers.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/GetProductIdentifiers.cs index 0015e9a4..87869205 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/GetProductIdentifiers.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/GetProductIdentifiers.cs @@ -5,7 +5,7 @@ namespace UKHO.PeriodicOutputService.API.FunctionalTests.Helpers { public class GetProductIdentifiers { - static HttpClient httpClient = new HttpClient(); + static HttpClient httpClient = new (); public async Task GetProductIdentifiersDataAsync(string baseUrl, List productIdentifierModel, string accessToken = null) { string uri = $"{baseUrl}/productData/productIdentifiers"; diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/POSWebJob.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/POSWebJob.cs index 92fce914..80a91e65 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/POSWebJob.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/POSWebJob.cs @@ -1,9 +1,8 @@ - -namespace UKHO.PeriodicOutputService.API.FunctionalTests.Helpers +namespace UKHO.PeriodicOutputService.API.FunctionalTests.Helpers { public class POSWebJob { - static readonly HttpClient httpClient = new HttpClient(); + static readonly HttpClient httpClient = new (); public async Task POSWebJobEndPoint(string baseUrl, string base64Credentials) { @@ -12,7 +11,9 @@ public async Task POSWebJobEndPoint(string baseUrl, string var httpRequestMessage = new HttpRequestMessage(HttpMethod.Post, uri); if (!string.IsNullOrEmpty(base64Credentials)) { httpRequestMessage.Headers.Add("Authorization", "Basic " + base64Credentials); } - return await httpClient.SendAsync(httpRequestMessage, CancellationToken.None); + { + return await httpClient.SendAsync(httpRequestMessage, CancellationToken.None); + } } } } diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/TestConfiguration.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/TestConfiguration.cs index af0e795a..106d2afc 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/TestConfiguration.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.API.FunctionalTests/Helpers/TestConfiguration.cs @@ -66,7 +66,6 @@ public class POSFileDetails public string AIOUpdateValidBatchId { get; set; } public string EncUpdateListCsvBatchId { get; set; } public string TempFolderName { get; set; } - public string UpdateExchangeSet { get; set; } public string PosAvcsZipFileName { get; set; } public string PosAvcsIsoFileName { get; set; } public string PosAvcsIsoSha1FileName { get; set; } @@ -78,11 +77,9 @@ public class POSFileDetails public string IsoFileMimeType { get; set; } public string Sha1FileMimeType { get; set; } public string ZipFileMimeType { get; set; } - public string PosDVDVolumeIdentifier { get; set; } public string AioExchangeSetBatchId { get; set; } public string InfoFolderName { get; set; } public string AioFolderName { get; set; } - } public class AioWebjobApiConfiguration @@ -91,7 +88,7 @@ public class AioWebjobApiConfiguration public int WebjobRunningStatusDelayTime { get; set; } } - public TestConfiguration() + public TestConfiguration() { ConfigurationRoot = new ConfigurationBuilder() .AddJsonFile("appsettings.json", false) diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Helpers/ISalesCatalogueClient.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Helpers/ISalesCatalogueClient.cs index ad0bf459..eff5504d 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Helpers/ISalesCatalogueClient.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Helpers/ISalesCatalogueClient.cs @@ -8,6 +8,6 @@ namespace UKHO.PeriodicOutputService.Common.Helpers { public interface ISalesCatalogueClient { - public Task CallSalesCatalogueServiceApi(HttpMethod method, string requestBody, string authToken, string uri); + public Task CallSalesCatalogueServiceApi(HttpMethod method, string? requestBody, string authToken, string uri); } } diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Helpers/SalesCatalogueClient.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Helpers/SalesCatalogueClient.cs index e21328bc..438ec409 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Helpers/SalesCatalogueClient.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Helpers/SalesCatalogueClient.cs @@ -14,12 +14,14 @@ public SalesCatalogueClient(IHttpClientFactory httpClientFactory) httpClient.Timeout = TimeSpan.FromMinutes(Convert.ToDouble(5)); } - public async Task CallSalesCatalogueServiceApi(HttpMethod method, string requestBody, string authToken, string uri) + public async Task CallSalesCatalogueServiceApi(HttpMethod method, string? requestBody, string authToken, string uri) { HttpContent content = null; if (requestBody != null) + { content = new StringContent(requestBody, Encoding.UTF8, "application/json"); + } using var httpRequestMessage = new HttpRequestMessage(method, uri); httpRequestMessage.Content = content; diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Services/EssService.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Services/EssService.cs index 8e751fb2..9dcdedf0 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Services/EssService.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Services/EssService.cs @@ -100,11 +100,9 @@ public EssService(ILogger logger, return exchangeSetResponseModel; } - else - { - _logger.LogError(EventIds.GetProductDataProductVersionFailed.ToEventId(), "Failed to create exchange set for product version | {DateTime} | StatusCode : {StatusCode} | _X-Correlation-ID : {CorrelationId}", DateTime.Now.ToUniversalTime(), httpResponse.StatusCode.ToString(), CommonHelper.GetCorrelationId(correlationId)); - throw new FulfilmentException(EventIds.GetProductDataProductVersionFailed.ToEventId()); - } + + _logger.LogError(EventIds.GetProductDataProductVersionFailed.ToEventId(), "Failed to create exchange set for product version | {DateTime} | StatusCode : {StatusCode} | _X-Correlation-ID : {CorrelationId}", DateTime.Now.ToUniversalTime(), httpResponse.StatusCode.ToString(), CommonHelper.GetCorrelationId(correlationId)); + throw new FulfilmentException(EventIds.GetProductDataProductVersionFailed.ToEventId()); } [ExcludeFromCodeCoverage] diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Services/SalesCatalogueService.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Services/SalesCatalogueService.cs index 38c410ae..ee950781 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Services/SalesCatalogueService.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/Services/SalesCatalogueService.cs @@ -51,9 +51,9 @@ private async Task CreateSalesCatalogueDataResponse( if (httpResponse.StatusCode != HttpStatusCode.OK) { - logger.LogError(EventIds.ScsGetSalesCatalogueDataNonOkResponse.ToEventId(), "Request to Sales Catalogue Service catalogue end point with uri:{RequestUri} FAILED.| {DateTime} | StatusCode : {StatusCode} | _X-Correlation-ID : {CorrelationId}", httpResponse.RequestMessage.RequestUri, DateTime.Now.ToUniversalTime(), httpResponse.StatusCode, CommonHelper.CorrelationID); + logger.LogError(EventIds.ScsGetSalesCatalogueDataNonOkResponse.ToEventId(), "Request to Sales Catalogue Service catalogue end point with uri:{RequestUri} FAILED.| {DateTime} | StatusCode : {StatusCode} | _X-Correlation-ID : {CorrelationId}", httpResponse.RequestMessage?.RequestUri, DateTime.Now.ToUniversalTime(), httpResponse.StatusCode, CommonHelper.CorrelationID); response.ResponseCode = httpResponse.StatusCode; - response.ResponseBody = null; + response.ResponseBody = null!; throw new FulfilmentException(EventIds.ScsGetSalesCatalogueDataNonOkResponse.ToEventId()); } else diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/UKHO.PeriodicOutputService.Common.csproj b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/UKHO.PeriodicOutputService.Common.csproj index 38adbb4e..e687dabb 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/UKHO.PeriodicOutputService.Common.csproj +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Common/UKHO.PeriodicOutputService.Common.csproj @@ -17,7 +17,7 @@ - + diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Fulfilment/Program.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Fulfilment/Program.cs index 8cb5ce26..f41072a1 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Fulfilment/Program.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Fulfilment/Program.cs @@ -1,4 +1,5 @@ -using System.Diagnostics.CodeAnalysis; +using System.Configuration; +using System.Diagnostics.CodeAnalysis; using System.IO.Abstractions; using System.Reflection; using Azure.Extensions.AspNetCore.Configuration.Secrets; @@ -21,6 +22,7 @@ using UKHO.PeriodicOutputService.Common.Services; using UKHO.PeriodicOutputService.Common.Utilities; using UKHO.PeriodicOutputService.Fulfilment.Services; +using Microsoft.Extensions.Logging.ApplicationInsights; namespace UKHO.PeriodicOutputService.Fulfilment { @@ -101,18 +103,17 @@ private static IConfigurationRoot BuildConfiguration() private static void ConfigureServices(IServiceCollection serviceCollection, IConfiguration configuration) { - + //Add logging serviceCollection.AddLogging(loggingBuilder => { - loggingBuilder.AddConfiguration(configuration.GetSection("Logging")); + loggingBuilder.AddConfiguration(configuration.GetSection("Logging")); + + loggingBuilder.AddApplicationInsights( + configureTelemetryConfiguration: (config) => config.ConnectionString = configuration["APPLICATIONINSIGHTS_CONNECTION_STRING"], + configureApplicationInsightsLoggerOptions: _ => { } + ); - string instrumentationKey = configuration["APPINSIGHTS_INSTRUMENTATIONKEY"]; - if (!string.IsNullOrEmpty(instrumentationKey)) - { - loggingBuilder.AddApplicationInsights(instrumentationKey); - } - #if DEBUG loggingBuilder.AddSerilog(new LoggerConfiguration() .WriteTo.File("Logs/UKHO.PeriodicOutputService.Fulfilment-Logs-.txt", rollingInterval: RollingInterval.Day, outputTemplate: "{Timestamp:yyyy-MM-dd HH:mm:ss} [{Level}] [{SourceContext}] {Message}{NewLine}{Exception}") @@ -157,19 +158,14 @@ private static void ConfigureServices(IServiceCollection serviceCollection, ICon var fssApiConfiguration = new FssApiConfiguration(); - if (configuration != null) - { - serviceCollection.Configure(configuration.GetSection("FleetManagerB2BApiConfiguration")); - serviceCollection.Configure(configuration.GetSection("ESSManagedIdentityConfiguration")); - serviceCollection.Configure(configuration.GetSection("FSSApiConfiguration")); - serviceCollection.Configure(configuration.GetSection("ESSApiConfiguration")); - serviceCollection.Configure(configuration.GetSection("AzureStorageConfiguration")); - serviceCollection.AddSingleton(configuration); - - configuration.Bind("FSSApiConfiguration", fssApiConfiguration); - - } + serviceCollection.Configure(configuration.GetSection("FleetManagerB2BApiConfiguration")); + serviceCollection.Configure(configuration.GetSection("ESSManagedIdentityConfiguration")); + serviceCollection.Configure(configuration.GetSection("FSSApiConfiguration")); + serviceCollection.Configure(configuration.GetSection("ESSApiConfiguration")); + serviceCollection.Configure(configuration.GetSection("AzureStorageConfiguration")); + serviceCollection.AddSingleton(configuration); + configuration.Bind("FSSApiConfiguration", fssApiConfiguration); serviceCollection.AddDistributedMemoryCache(); diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Fulfilment/Services/FulfilmentDataService.cs b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Fulfilment/Services/FulfilmentDataService.cs index 2420c262..9dd00449 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Fulfilment/Services/FulfilmentDataService.cs +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Fulfilment/Services/FulfilmentDataService.cs @@ -79,18 +79,14 @@ public async Task CreatePosExchangeSets() _logger.LogInformation(EventIds.GetLatestSinceDateTimeCompleted.ToEventId(), "Getting latest since datetime completed | {DateTime} | _X-Correlation-ID : {CorrelationId}", DateTime.Now.ToUniversalTime(), CommonHelper.CorrelationID); + Task fullAVCSExchangeSetTask = Task.Run(() => CreateFullAVCSExchangeSet()); + Task updateAVCSExchangeSetTask = Task.Run(() => CreateUpdateExchangeSet(sinceDateTime.ToString("R"))); + bool isSuccess = false; try { - Task[] tasks = null; - - Task fullAVCSExchangeSetTask = Task.Run(() => CreateFullAVCSExchangeSet()); - Task updateAVCSExchangeSetTask = Task.Run(() => CreateUpdateExchangeSet(sinceDateTime.ToString("R"))); - - tasks = new Task[] { fullAVCSExchangeSetTask, updateAVCSExchangeSetTask }; - - await Task.WhenAll(tasks); + await Task.WhenAll(fullAVCSExchangeSetTask, updateAVCSExchangeSetTask); isSuccess = true; diff --git a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Fulfilment/appsettings.json b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Fulfilment/appsettings.json index 653e8be0..5c349938 100644 --- a/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Fulfilment/appsettings.json +++ b/UKHO.PeriodicOutputService/UKHO.PeriodicOutputService.Fulfilment/appsettings.json @@ -1,5 +1,5 @@ { - "APPINSIGHTS_INSTRUMENTATIONKEY": "", + "APPLICATIONINSIGHTS_CONNECTION_STRING": "", "Logging": { "PathFormat": "Logs/UKHO.PeriodicOutputService.Fulfilment-{Date}.txt", "Json": true, @@ -7,6 +7,11 @@ "Default": "Debug", "Microsoft": "Information", "System": "Information" + }, + "ApplicationInsights": { + "LogLevel": { + "Default": "Error" + } } }, "EventHubLoggingConfiguration": { @@ -56,5 +61,5 @@ "IsFTRunning": true, "POSFolderName": "POS", "PosDVDVolumeIdentifier": "M0{0}X02", - "AIOFileName": "AIO.zip" + "AIOFileName": "AIO.zip" } diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f1c66fa2..2e6525d8 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -1,6 +1,6 @@ name: $(BuildDefinitionName)_$(SourceBranchName)_$(Date:yy)$(DayOfYear).$(BuildCounter) -parameters: +parameters: - name: ContinueEvenIfResourcesAreGettingDestroyed displayName: "Continue even if resources are getting destroyed" type: boolean @@ -9,6 +9,10 @@ parameters: displayName: "Disable Stryker" type: boolean default: false + - name: DisableDependencyCheck + displayName: "Disable OWASP dependency checking" + type: boolean + default: false trigger: - main @@ -40,6 +44,16 @@ variables: value: "ukhydrographicoffice/terraform-azure-powershell-unzip:1.9.6" - name: WindowPool value: "NautilusBuild" + - name: SdkVersion + value: "8.0.x" + +resources: + repositories: + - repository: UKHOTemplates + type: github + name: UKHO/devops-pipelinetemplates + endpoint: UKHO + ref: refs/heads/main stages: - stage: Stryker_Mutator @@ -91,855 +105,74 @@ stages: pwsh: true script: $(Agent.BuildDirectory)/tools/dotnet-stryker - - task: PublishMutationReport@0 + - task: PublishMutationReport@1 displayName: 'Publish Stryker Mutator Report' inputs: reportPattern: '**/mutation-report.html' - - stage: PERFORM_DEPENDENCYCHECK_DOTNETBUILD_DOTNETTEST_AND_PUBLISH - displayName: "Build (inc DependencyChecker, Dotnet Build , dotnet test and publish artifact )" + - stage: BuildTestPublish + displayName: "Build, test and publish" dependsOn: [] jobs: - - job: Dependencychecker - workspace: - clean: all - displayName: "Dependencychecker" - steps: - - task: UseDotNet@2 - displayName: 'Use .NET SDK' - inputs: - packageType: sdk - useGlobalJson: true - workingDirectory: '$(Build.SourcesDirectory)' - - - task: DotNetCoreCLI@2 - displayName: ".Net Core - NuGet restore non test projects only" - inputs: - command: "restore" - projects: | - **/*.csproj - !**/*Tests.csproj - feedsToUse: config - noCache: true - nugetConfigPath: '$(Build.SourcesDirectory)\BuildNuget.config' - workingDirectory: '$(Build.SourcesDirectory)\UKHO.PeriodicOutputService' - packagesDirectory: '$(Build.SourcesDirectory)\UKHO.PeriodicOutputService\packages' - - - task: CmdLine@1 - displayName: "Run OWASP Dependency Checker" - inputs: - filename: 'dependency-check.bat' - arguments: '--project "periodic-output-service - $(Build.SourceBranchName)" --scan "$(Build.SourcesDirectory)\UKHO.PeriodicOutputService" --out "$(Build.ArtifactStagingDirectory)\DCReport" --suppression $(Build.SourcesDirectory)\NVDSuppressions.xml --noupdate' - - - task: PublishBuildArtifacts@1 - displayName: "Publish Artifact: OWASP Dependency Checker Report" - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)\DCReport' - ArtifactName: "OWASP Dependency Checker Report" - - - task: PowerShell@1 - displayName: "Fail Build if Dependency Check Finds Any Vulnerabilities" - inputs: - scriptType: inlineScript - arguments: '-ReportLocation $(Build.ArtifactStagingDirectory)\DCReport\*' - inlineScript: | - param($ReportLocation) - Invoke-VulnerabilityCheck -ReportLocation $ReportLocation - - - job: UnitTestsAndCodeCoverage - workspace: - clean: all - displayName: "Dotnet Test and Publish Code Coverage" - steps: - - task: UseDotNet@2 - displayName: 'Use .NET SDK' - inputs: - packageType: sdk - useGlobalJson: true - workingDirectory: '$(Build.SourcesDirectory)' - - - task: DotNetCoreCLI@2 - displayName: ".Net Core - NuGet restore test projects only" - inputs: - command: "restore" - projects: "**/*Tests.csproj" - feedsToUse: config - noCache: true - nugetConfigPath: '$(Build.SourcesDirectory)\BuildNuget.config' - workingDirectory: '$(Build.SourcesDirectory)\UKHO.PeriodicOutputService' - packagesDirectory: '$(Build.SourcesDirectory)\UKHO.PeriodicOutputService\packagesForTests' - - - task: DotNetCoreCLI@2 - displayName: "dotnet test - Perform Unit Tests" - inputs: - command: "test" - projects: "**/*UnitTests.csproj" - arguments: '--configuration $(BuildConfiguration) --settings "$(Build.SourcesDirectory)\test.runsettings" /p:CollectCoverage=true /p:CoverletOutputFormat=cobertura' - publishTestResults: true - testRunTitle: "UnitTests" - - - task: PowerShell@2 - displayName: "Generate code coverage report" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)\CodeCoverageReport.ps1' - arguments: '-source "$(Build.SourcesDirectory)" -reportFolder "$(Build.ArtifactStagingDirectory)"' - - - task: PublishBuildArtifacts@1 - displayName: "Publish Code coverage" - inputs: - PathtoPublish: "$(Build.ArtifactStagingDirectory)/codecoveragereport" - ArtifactName: codecoveragereport - - - job: BuildAndPublishWebJob - workspace: - clean: all - displayName: "Dotnet Build publish WebJob" - steps: - - task: PowerShell@2 - displayName: "Set assembly version numbers based on build ID" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)\Apply-AssemblyVersionAndDefaults.ps1' - arguments: '-buildNumber "$(Build.BuildNumber)" -solutionDirectory "$(Build.SourcesDirectory)\UKHO.PeriodicOutputService\" -UKHOAssemblyCompany "$env:UKHOAssemblyCompany" -UKHOAssemblyCopyright "$(UKHOAssemblyCopyright)" -UKHOAssemblyVersionPrefix "$env:UKHOAssemblyVersionPrefix" -UKHOAssemblyProduct "$env:UKHOAssemblyProduct"' - - - task: UseDotNet@2 - displayName: 'Use .NET SDK' - inputs: - packageType: sdk - useGlobalJson: true - workingDirectory: '$(Build.SourcesDirectory)' - - - task: DotNetCoreCLI@2 - displayName: ".Net Core - NuGet restore" - inputs: - command: restore - projects: | - **/*.csproj - feedsToUse: config - noCache: true - nugetConfigPath: '$(Build.SourcesDirectory)\BuildNuget.config' - workingDirectory: '$(Build.SourcesDirectory)\UKHO.PeriodicOutputService' - - - task: DotNetCoreCLI@2 - displayName: "dotnet build task" - inputs: - command: "build" - projects: "**/*.csproj" - arguments: '--configuration $(BuildConfiguration) --output $(Build.BinariesDirectory)' - - - task: DotNetCoreCLI@2 - displayName: "Publish POS Fulfilment Service Code" - inputs: - command: "publish" - publishWebProjects: false - projects: "**/*UKHO.PeriodicOutputService.Fulfilment.csproj" - arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\App_Data\jobs\triggered\POSFulfilmentWebJob' - zipAfterPublish: false - modifyOutputPath: false - - - task: DotNetCoreCLI@2 - displayName: "Publish AIO Fulfilment Service Code" - inputs: - command: "publish" - publishWebProjects: false - projects: "**/*UKHO.AdmiraltyInformationOverlay.Fulfilment.csproj" - arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\App_Data\jobs\triggered\AIOFulfilmentWebJob' - zipAfterPublish: false - modifyOutputPath: false - - - task: DotNetCoreCLI@2 - displayName: "Publish BESS Configuration Service Code" - inputs: - command: "publish" - publishWebProjects: false - projects: "**/*UKHO.BESS.ConfigurationService.csproj" - arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\App_Data\jobs\continuous\BESSConfigurationServiceWebJob' - zipAfterPublish: false - modifyOutputPath: false - - - task: DotNetCoreCLI@2 - displayName: "Publish BESS Builder Service Code" - inputs: - command: "publish" - publishWebProjects: false - projects: "**/*UKHO.BESS.BuilderService.csproj" - arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\App_Data\jobs\continuous\BESSBuilderServiceWebJob' - zipAfterPublish: false - modifyOutputPath: false - - - task: DotNetCoreCLI@2 - displayName: "Publish BESS CleanUp Service Code" - inputs: - command: "publish" - publishWebProjects: false - projects: "**/*UKHO.BESS.CleanUpJob.csproj" - arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\App_Data\jobs\triggered\BESSCleanUpWebJob' - zipAfterPublish: false - modifyOutputPath: false - - - task: ArchiveFiles@2 - displayName: "Zip POS fulfilment service" - inputs: - rootFolderOrFile: '$(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\' - includeRootFolder: false - archiveType: "zip" - archiveFile: '$(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\PeriodicOutputFulfilmentService.zip' - replaceExistingArchive: true - - - task: PublishBuildArtifacts@1 - displayName: "Publish PeriodicOutputFulfilmentService Artifact" - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService' - ArtifactName: PeriodicOutputService - - - task: PowerShell@2 - displayName: "Generate event id runbook" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)\Utility\XmlToRtfTransformation.ps1' - arguments: '-xmlFilePath $(Build.ArtifactStagingDirectory)\PeriodicOutputFulfilmentService\App_Data\jobs\triggered\POSFulfilmentWebJob\UKHO.PeriodicOutputService.Common.xml -xsltFilePath $(Build.SourcesDirectory)\Utility\EventIdXmlTransformation.xslt -outputFileName Runbook-EventId' - - - task: PublishBuildArtifacts@1 - displayName: "Publish event id runbook" - inputs: - PathtoPublish: '$(Build.SourcesDirectory)\Utility\Runbook-EventId.rtf' - ArtifactName: Runbook - - - job: PublishTerraformArtifacts - workspace: - clean: all - displayName: "Publish Terraform Artifacts" - steps: - - - task: PublishBuildArtifacts@1 - displayName: "Publish Dev terraform Artifacts" - inputs: - PathtoPublish: '$(Build.SourcesDirectory)\DevDeployment' - ArtifactName: devterraformartifact - - - task: PublishBuildArtifacts@1 - displayName: "Publish QA and Live terraform Artifacts" - inputs: - PathtoPublish: '$(Build.SourcesDirectory)\QALiveDeployment' - ArtifactName: qaliveterraformartifact - - - task: PublishBuildArtifacts@1 - displayName: "Publish vNext terraform Artifacts" - inputs: - PathtoPublish: '$(Build.SourcesDirectory)\vNextE2EDeployment' - ArtifactName: vnexte2eterraformartifact - - - task: PublishBuildArtifacts@1 - displayName: "Publish vNext terraform Artifacts" - inputs: - PathtoPublish: '$(Build.SourcesDirectory)\vNextIATDeployment' - ArtifactName: vnextiatterraformartifact + - template: Deployment/templates/build-test-publish.yml + parameters: + DisableDependencyCheck: ${{ parameters.DisableDependencyCheck }} + DotNetVersion: '8.0.x' - - job: PublishFunctionalTests - workspace: - clean: all - displayName: "Publish Functional Tests" - steps: - - task: UseDotNet@2 - displayName: 'Use .NET SDK' - inputs: - packageType: sdk - useGlobalJson: true - workingDirectory: '$(Build.SourcesDirectory)' - - - task: DotNetCoreCLI@2 - displayName: ".Net Core - NuGet restore" - inputs: - command: restore - projects: | - **/*.csproj - feedsToUse: config - noCache: true - nugetConfigPath: '$(Build.SourcesDirectory)\BuildNuget.config' - workingDirectory: '$(Build.SourcesDirectory)\UKHO.PeriodicOutputService' - - - task: DotNetCoreCLI@2 - displayName: "Publish POS functional test" - inputs: - command: "publish" - publishWebProjects: false - projects: "**/*UKHO.PeriodicOutputService.API.FunctionalTests.csproj" - arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\UKHO.PeriodicOutputService.API.FunctionalTests' - zipAfterPublish: false - - - task: PublishBuildArtifacts@1 - displayName: "Publish POS Functional test Artifact" - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)\UKHO.PeriodicOutputService.API.FunctionalTests' - ArtifactName: posfunctionaltests - - - task: DotNetCoreCLI@2 - displayName: "Publish BESS functional test" - inputs: - command: "publish" - publishWebProjects: false - projects: "**/*UKHO.BESS.API.FunctionalTests.csproj" - arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\UKHO.BESS.API.FunctionalTests' - zipAfterPublish: false - - - task: PublishBuildArtifacts@1 - displayName: "Publish BESS Functional test Artifact" - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)\UKHO.BESS.API.FunctionalTests' - ArtifactName: bessfunctionaltests - - - job: BuildAndPublishMockAPI - workspace: - clean: all - displayName: "Build and Publish Mock API" - steps: - - task: PowerShell@2 - displayName: "Set assembly version numbers based on build ID" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)\Apply-AssemblyVersionAndDefaults.ps1' - arguments: '-buildNumber "$(Build.BuildNumber)" -solutionDirectory "$(Build.SourcesDirectory)\UKHO.FmEssFssMock.API\" -UKHOAssemblyCompany "$env:UKHOAssemblyCompany" -UKHOAssemblyCopyright "$(UKHOAssemblyCopyright)" -UKHOAssemblyVersionPrefix "$env:UKHOAssemblyVersionPrefix" -UKHOAssemblyProduct "$(UKHOAssemblyProduct) Mock"' - - - task: UseDotNet@2 - displayName: 'Use .NET SDK' - inputs: - packageType: sdk - useGlobalJson: true - workingDirectory: '$(Build.SourcesDirectory)' - - - task: DotNetCoreCLI@2 - displayName: ".Net Core - NuGet restore" - inputs: - command: restore - projects: | - **/*.csproj - feedsToUse: config - noCache: true - nugetConfigPath: '$(Build.SourcesDirectory)\BuildNuget.config' - workingDirectory: '$(Build.SourcesDirectory)\UKHO.FmEssFssMock.API' - - - task: DotNetCoreCLI@2 - displayName: "dotnet build task" - inputs: - command: "build" - projects: "**/*UKHO.FmEssFssMock.API.csproj" - arguments: '--configuration $(BuildConfiguration) --output $(Build.BinariesDirectory)' - workingDirectory: '$(Build.SourcesDirectory)\UKHO.FmEssFssMock.API' - - - task: DotNetCoreCLI@2 - displayName: "Publish MockWebAPI" - inputs: - command: "publish" - publishWebProjects: false - projects: '**/*UKHO.FmEssFssMock.API.csproj' - arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\MockWebAPI' - zipAfterPublish: true - modifyOutputPath: true - - - task: PublishBuildArtifacts@1 - displayName: "Publish WebAPI Artifact" - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)\MockWebAPI' - ArtifactName: MockWebAPI - - - job: BuildAndPublishPKSWireMockAPI - workspace: - clean: all - displayName: "Build and Publish PKSWireMock API" - steps: - - task: PowerShell@2 - displayName: "Set assembly version numbers based on build ID" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)\Apply-AssemblyVersionAndDefaults.ps1' - arguments: '-buildNumber "$(Build.BuildNumber)" -solutionDirectory "$(Build.SourcesDirectory)\UKHO.PKSWireMockService.API\" -UKHOAssemblyCompany "$env:UKHOAssemblyCompany" -UKHOAssemblyCopyright "$(UKHOAssemblyCopyright)" -UKHOAssemblyVersionPrefix "$env:UKHOAssemblyVersionPrefix" -UKHOAssemblyProduct "$(UKHOAssemblyProduct) Mock"' - - - task: UseDotNet@2 - displayName: 'Use .NET SDK' - inputs: - packageType: sdk - useGlobalJson: true - workingDirectory: '$(Build.SourcesDirectory)' - - - task: DotNetCoreCLI@2 - displayName: ".Net Core - NuGet restore" - inputs: - command: restore - projects: | - **/*.csproj - feedsToUse: config - noCache: true - nugetConfigPath: '$(Build.SourcesDirectory)\BuildNuget.config' - workingDirectory: '$(Build.SourcesDirectory)\UKHO.PKSWireMockService.API' - - - task: DotNetCoreCLI@2 - displayName: "dotnet build task" - inputs: - command: "build" - projects: "**/*UKHO.PKSWireMock.API.csproj" - arguments: '--configuration $(BuildConfiguration) --output $(Build.BinariesDirectory)' - workingDirectory: '$(Build.SourcesDirectory)\UKHO.PKSWireMockService.API' - - - task: DotNetCoreCLI@2 - displayName: "Publish PKSWireMock WebAPI" - inputs: - command: "publish" - publishWebProjects: false - projects: '**/*UKHO.PKSWireMock.API.csproj' - arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)\PKSWireMockWebAPI' - zipAfterPublish: true - modifyOutputPath: true - - - task: PublishBuildArtifacts@1 - displayName: "Publish PKSWireMock WebAPI Artifact" - inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)\PKSWireMockWebAPI' - ArtifactName: PKSWireMockWebAPI - - stage: Devdeploy displayName: "Devdeploy (inc terraform, webapp deploy)" variables: - - group: "ESS-Dev-Variables" - - group: "ESS-Deployment-Variables-DEV" - - group: "POS-Dev-Variables" - - name: "ESSApiConfiguration.TenantId" - value: $(TenantId) - - name: "ESSApiConfiguration.AutoTestClientId" - value: $(AutoTestClientId_Authed) - - name: "ESSApiConfiguration.AutoTestClientSecret" - value: $(AutoTestClientSecret_Authed) - - name: "ESSApiConfiguration.EssClientId" - value: $(ESSClientId) - - name: "ElasticAPM_ServerURL" - value: $(ElasticAPM.ServerURL) - - name: "ElasticAPM_ApiKey" - value: $(ElasticAPM.ApiKey) - + - name: Environment + value: "dev" + - template: Deployment/templates/variables.yml + parameters: + Environment: ${{variables.Environment}} jobs: - - deployment: DevDeployApp - displayName: "Dev - Deploy Terraform and Dotnet App" - environment: "Ess-Dev" - pool: $(DeploymentPool) - container: ${{variables.Container}} - workspace: - clean: all - strategy: - runOnce: - deploy: - steps: - - template: DevDeployment/templates/continuous-deployment.yml - parameters: - ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} - AzureSubscription: "Exchange-Set-Service-Dev-A-008-02" - - - job: CheckInfra - displayName: "Check Infrastructure Health" - dependsOn: DevDeployApp - variables: - - name: WEB_APP_NAME - value: $[ dependencies.DevDeployApp.outputs['DevDeployApp.TerraformDeploy.WEBAPP'] ] - - name: RGName - value: $[ dependencies.DevDeployApp.outputs['DevDeployApp.TerraformDeploy.ResourceGroup'] ] - steps: - - task: AzureCLI@2 - displayName: "Check Infrastructure is healthy" - inputs: - azureSubscription: "Exchange-Set-Service-Dev-A-008-02" - scriptType: 'pscore' - scriptLocation: 'scriptPath' - scriptPath: '$(Build.SourcesDirectory)/DevDeployment/check_service_status_webjob.ps1' - arguments: '-RGName $(RGName) -webAppName $(WEB_APP_NAME) -waitTimeInMinute $(waitTimeInMinute)' - - - job: CheckFSS - displayName: "Check FSS Health" - dependsOn: DevDeployApp - steps: - - task: PowerShell@2 - displayName: "Check FSS Health endpoint is healthy" - inputs: - targetType: filePath - filePath: "$(Build.SourcesDirectory)/DevDeployment/check_health_endpoint.ps1" - arguments: "-healthEndPointUrl $(FSSHealthEndpoint)/heartbeat -waitTimeInMinute $(waitTimeInMinute)" - - - job: CheckESS - displayName: "Check ESS Health" - dependsOn: DevDeployApp - steps: - - task: PowerShell@2 - displayName: "Check ESS Health endpoint is healthy" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)/DevDeployment/check_health_endpoint.ps1' - arguments: "-healthEndPointUrl $(ESSHealthEndpoint)/health -waitTimeInMinute $(waitTimeInMinute)" - - - job: CheckFM - displayName: "Check Fleet Manager Health" - dependsOn: DevDeployApp - steps: - - task: PowerShell@2 - displayName: "Check FM Health endpoint is healthy" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)/DevDeployment/check_health_endpoint.ps1' - arguments: "-healthEndPointUrl $(FMHealthEndpoint)/health-check -waitTimeInMinute $(waitTimeInMinute)" - - - job: SetPOSQASubnet - displayName: "Set QA Subnet Configuration" - dependsOn: DevDeployApp - pool: $(DeploymentPool) - container: ${{variables.Container}} - variables: - - name: mockWebAppName - value: $[ dependencies.DevDeployApp.outputs['DevDeployApp.TerraformDeploy.mockWebApp'] ] - - name: mockWebAppResourceGroup - value: $[ dependencies.DevDeployApp.outputs['DevDeployApp.TerraformDeploy.mockWebAppResourceGroupName'] ] - steps: - - task: AzureCLI@2 - displayName: "Set QA Subnet Configuration" - inputs: - azureSubscription: "Exchange-Set-Service-Dev-A-008-02" - scriptType: 'pscore' - scriptLocation: 'scriptPath' - scriptPath: '$(Build.SourcesDirectory)/DevDeployment/set_qa_subnet_configuration.ps1' - arguments: '-mockresourcegroup $(mockWebAppResourceGroup) -mockwebappname $(mockWebAppName) -qasubscriptionid $(POSESSQASubscriptionId) -qavnetresourcegroup $(spokeRG) -qavnetname $(POSESSQAspokeVnetName) -qasubnetname $(POSESSspokeSubnetName)' - - - job: POSFunctionalTests - dependsOn: - - DevDeployApp - - CheckInfra - - CheckFSS - - CheckESS - - CheckFM - pool: NautilusBuild - displayName: "Dev POS Functional Automated Tests" - workspace: - clean: all - variables: - - name: POSWebjobApiConfiguration.UserName - value: $[ dependencies.DevDeployApp.outputs['DevDeployApp.TerraformDeploy.webJobUsername'] ] - - name: POSWebjobApiConfiguration.Password - value: $[ dependencies.DevDeployApp.outputs['DevDeployApp.TerraformDeploy.webJobPassword'] ] - steps: - - task: DownloadBuildArtifacts@0 - displayName: "Download POS Functional test Artifact" - inputs: - buildType: 'current' - downloadType: 'single' - artifactName: 'posfunctionaltests' - downloadPath: '$(Build.SourcesDirectory)' - - - task: FileTransform@2 - displayName: "File Transform: functionaltests" - inputs: - folderPath: '$(Build.SourcesDirectory)/posfunctionaltests/' - xmlTransformationRules: - jsonTargetFiles: '**/appsettings.json' - - - task: UseDotNet@2 - displayName: 'Use .NET SDK' - inputs: - packageType: sdk - version: 6.0.x - - - task: DotNetCoreCLI@2 - displayName: "Run POS Functional tests" - inputs: - command: "test" - projects: | - **/*FunctionalTest*.dll - !**/*TestAdapter.dll - !**/obj/** - arguments: '--filter Category~CallEssEndPoint|Category~GetAVCSCatalogue|Category~POSEndToEndScenarioFullAvcsPollingTimeOut|Category~POSEndToEndScenarioUpdatePollingTimeOut|Category~POSEndToEndScenarioWithInvalidProductIdentifier|Category~POSEndToEndValidFunctionalScenarios|Category~POSAIOValidFunctionalScenarios|Category~POSAIOScenarioWithInvalidProductIdentifier|Category~POSAIOScenarioPollingTimeOut' - testRunTitle: "Dev-POSAutomationTests" - workingDirectory: '$(Build.SourcesDirectory)/posfunctionaltests' - - - job: BESSFunctionalTests - dependsOn: - - DevDeployApp - - CheckInfra - - CheckFSS - - CheckESS - - CheckFM - - POSFunctionalTests - pool: NautilusBuild - displayName: "Dev BESS Functional Automated Tests" - workspace: - clean: all - variables: - - name: AzureWebJobsStorage - value: $[ dependencies.DevDeployApp.outputs['DevDeployApp.TerraformDeploy.AzureWebJobsStorageName'] ] - - name: WEB_APP_NAME - value: $[ dependencies.DevDeployApp.outputs['DevDeployApp.TerraformDeploy.WEBAPP'] ] - - name: mockWebAppName - value: $[ dependencies.DevDeployApp.outputs['DevDeployApp.TerraformDeploy.mockWebApp'] ] - - name: mockWebAppResourceGroup - value: $[ dependencies.DevDeployApp.outputs['DevDeployApp.TerraformDeploy.mockWebAppResourceGroupName'] ] - - name: RGName - value: $[ dependencies.DevDeployApp.outputs['DevDeployApp.TerraformDeploy.ResourceGroup'] ] - - name: BessStorageConfiguration.ConnectionString - value: $[ dependencies.DevDeployApp.outputs['DevDeployApp.TerraformDeploy.AzureWebJobsStorageName'] ] - steps: - - task: DownloadBuildArtifacts@0 - displayName: "Download Terraform Artifact" - condition: always() - inputs: - buildType: 'current' - downloadType: 'single' - artifactName: 'devterraformartifact' - downloadPath: '$(Build.SourcesDirectory)' - - - task: AzureCLI@2 - displayName: "Swap Storage Container Configuration" - condition: always() - inputs: - azureSubscription: "Exchange-Set-Service-Dev-A-008-02" - scriptType: 'pscore' - scriptLocation: 'scriptPath' - scriptPath: "$(Build.SourcesDirectory)/devterraformartifact/swap_container_config.ps1" - arguments: '-containername $(BessContainerForFT) -resourcegroup $(RGName) -webappname $(WEB_APP_NAME)' - - - task: DownloadBuildArtifacts@0 - displayName: "Download BESS Functional test Artifact" - inputs: - buildType: 'current' - downloadType: 'single' - artifactName: 'bessfunctionaltests' - downloadPath: '$(Build.SourcesDirectory)' - - - task: FileTransform@2 - displayName: "File Transform: functionaltests" - inputs: - folderPath: '$(Build.SourcesDirectory)/bessfunctionaltests/' - xmlTransformationRules: - jsonTargetFiles: '**/appsettings.json' - - - task: UseDotNet@2 - displayName: 'Use .NET SDK' - inputs: - packageType: sdk - version: 6.0.x - - - task: DotNetCoreCLI@2 - displayName: "Run BESS Functional tests" - inputs: - command: "test" - projects: | - **/*FunctionalTest*.dll - !**/*TestAdapter.dll - !**/obj/** - testRunTitle: "Dev-BESSAutomationTests" - workingDirectory: '$(Build.SourcesDirectory)/bessfunctionaltests' - - - task: AzureCLI@2 - displayName: "Swap Storage Container Configuration" - condition: always() - inputs: - azureSubscription: "Exchange-Set-Service-Dev-A-008-02" - scriptType: 'pscore' - scriptLocation: 'scriptPath' - scriptPath: "$(Build.SourcesDirectory)/devterraformartifact/swap_container_config.ps1" - arguments: '-containername $(BessContainerForWebjob) -resourcegroup $(RGName) -webappname $(WEB_APP_NAME)' - + - template: Deployment/templates/app-deploy.yml + parameters: + Environment: ${{variables.Environment}} + ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} + AzureSubscription: "Exchange-Set-Service-Dev-A-008-02" + Container: ${{variables.Container}} + RunTests: true + - stage: QAdeploy dependsOn: Devdeploy displayName: "QAdeploy (inc terraform, webapp deploy)" variables: - - group: "ESS-QA-Variables" - - group: "ESS-Deployment-Variables-QA" - - group: "POS-QA-Variables" - - name: "ESSApiConfiguration.TenantId" - value: $(TenantId) - - name: "ESSApiConfiguration.AutoTestClientId" - value: $(AutoTestClientId_Authed) - - name: "ESSApiConfiguration.AutoTestClientSecret" - value: $(AutoTestClientSecret_Authed) - - name: "ESSApiConfiguration.EssClientId" - value: $(ESSClientId) - - name: "ElasticAPM_ServerURL" - value: $(ElasticAPM.ServerURL) - - name: "ElasticAPM_ApiKey" - value: $(ElasticAPM.ApiKey) - condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'),startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))) - + - name: Environment + value: "qa" + - template: Deployment/templates/variables.yml + parameters: + Environment: ${{variables.Environment}} jobs: - - deployment: QADeployApp - displayName: "QA - Deploy Terraform and Dotnet App" - environment: "Ess-Qa" - pool: $(DeploymentPool) - container: ${{variables.Container}} - workspace: - clean: all - strategy: - runOnce: - deploy: - steps: - - template: QALiveDeployment/templates/continuous-deployment.yml - parameters: - ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} - AzureSubscription: "Exchange-Set-Service-QA-A-008-02" - - - job: CheckInfra - displayName: "Check Infrastructure Health" - dependsOn: QADeployApp - variables: - - name: WEB_APP_NAME - value: $[ dependencies.QADeployApp.outputs['QADeployApp.TerraformDeploy.WEBAPP'] ] - - name: RGName - value: $[ dependencies.QADeployApp.outputs['QADeployApp.TerraformDeploy.ResourceGroup'] ] - steps: - - task: AzureCLI@2 - displayName: "Check Infrastructure is healthy" - inputs: - azureSubscription: "Exchange-Set-Service-QA-A-008-02" - scriptType: 'pscore' - scriptLocation: 'scriptPath' - scriptPath: '$(Build.SourcesDirectory)/QALiveDeployment/check_service_status_webjob.ps1' - arguments: '-RGName $(RGName) -webAppName $(WEB_APP_NAME) -waitTimeInMinute $(waitTimeInMinute)' - - - job: CheckFSS - displayName: "Check FSS Health" - dependsOn: QADeployApp - steps: - - task: PowerShell@2 - displayName: "Check FSS Health endpoint is healthy" - inputs: - targetType: filePath - filePath: "$(Build.SourcesDirectory)/QALiveDeployment/check_health_endpoint.ps1" - arguments: "-healthEndPointUrl $(FSSHealthEndpoint)/heartbeat -waitTimeInMinute $(waitTimeInMinute)" - - - job: CheckESS - displayName: "Check ESS Health" - dependsOn: QADeployApp - steps: - - task: PowerShell@2 - displayName: "Check ESS Health endpoint is healthy" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)/QALiveDeployment/check_health_endpoint.ps1' - arguments: "-healthEndPointUrl $(ESSHealthEndpoint)/health -waitTimeInMinute $(waitTimeInMinute)" - - - job: CheckFM - displayName: "Check Fleet Manager Health" - dependsOn: QADeployApp - steps: - - task: PowerShell@2 - displayName: "Check FM Health endpoint is healthy" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)/QALiveDeployment/check_health_endpoint.ps1' - arguments: "-healthEndPointUrl $(FMHealthEndpoint)/health-check -waitTimeInMinute $(waitTimeInMinute)" + - template: Deployment/templates/app-deploy.yml + parameters: + Environment: ${{variables.Environment}} + ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} + AzureSubscription: "Exchange-Set-Service-QA-A-008-02" + Container: ${{variables.Container}} - stage: Livedeploy displayName: "Livedeploy (inc terraform, webapp deploy)" variables: - - group: "ESS-Live-Variables" - - group: "ESS-Deployment-Variables-LIVE" - - group: "POS-Live-Variables" - - name: "ElasticAPM_ServerURL" - value: $(ElasticAPM.ServerURL) - - name: "ElasticAPM_ApiKey" - value: $(ElasticAPM.ApiKey) - condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/main'),startsWith(variables['Build.SourceBranch'], 'refs/heads/release/'))) + - name: Environment + value: "Live" + - template: Deployment/templates/variables.yml + parameters: + Environment: ${{variables.Environment}} jobs: - - deployment: LiveDeployApp - displayName: "Live - Deploy Terraform and Dotnet App" - environment: "Ess-Live" - pool: $(DeploymentPool) - container: ${{variables.Container}} - workspace: - clean: all - strategy: - runOnce: - deploy: - steps: - - template: QALiveDeployment/templates/continuous-deployment.yml - parameters: - ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} - AzureSubscription: "Exchange-Set-Service-Live-A-008-02" - - - job: LiveSetup - displayName: "Set Webjob Configuration For Live" - dependsOn: LiveDeployApp - variables: - - name: WEB_APP_NAME - value: $[ dependencies.LiveDeployApp.outputs['LiveDeployApp.TerraformDeploy.WEBAPP'] ] - - name: RGName - value: $[ dependencies.LiveDeployApp.outputs['LiveDeployApp.TerraformDeploy.ResourceGroup'] ] - steps: - - task: AzureCLI@2 - displayName: "Swap Webjob Configuration" - condition: always() - inputs: - azureSubscription: "Exchange-Set-Service-Live-A-008-02" - scriptType: 'pscore' - scriptLocation: 'scriptPath' - scriptPath: "$(Build.SourcesDirectory)/QALiveDeployment/set_webjob_configuration.ps1" - arguments: '-essapibaseurl $(ESSApiConfiguration.BaseUrl) -fssapibaseurl $(FSSApiConfiguration.BaseUrl) -fleetmanagerbaseurl $(FleetManagerB2BApiConfiguration.BaseUrl) -ftrunning "false" -fssapipollingcutoffime $(FSSApiConfiguration.BatchStatusPollingCutoffTime) -fssapipollingdelaytime $(FSSApiConfiguration.BatchStatusPollingDelayTime) -resourcegroup $(RGName) -webappname $(WEB_APP_NAME)' - - - job: CheckInfra - displayName: "Check Infrastructure Health" - dependsOn: - - LiveDeployApp - - LiveSetup - variables: - - name: WEB_APP_NAME - value: $[ dependencies.LiveDeployApp.outputs['LiveDeployApp.TerraformDeploy.WEBAPP'] ] - - name: RGName - value: $[ dependencies.LiveDeployApp.outputs['LiveDeployApp.TerraformDeploy.ResourceGroup'] ] - steps: - - task: AzureCLI@2 - displayName: "Check Infrastructure is healthy" - inputs: - azureSubscription: "Exchange-Set-Service-Live-A-008-02" - scriptType: 'pscore' - scriptLocation: 'scriptPath' - scriptPath: '$(Build.SourcesDirectory)/QALiveDeployment/check_service_status_webjob.ps1' - arguments: '-RGName $(RGName) -webAppName $(WEB_APP_NAME) -waitTimeInMinute $(waitTimeInMinute)' - - - job: CheckFSS - displayName: "Check FSS Health" - dependsOn: - - LiveDeployApp - - LiveSetup - steps: - - task: PowerShell@2 - displayName: "Check FSS Health endpoint is healthy" - inputs: - targetType: filePath - filePath: "$(Build.SourcesDirectory)/QALiveDeployment/check_health_endpoint.ps1" - arguments: "-healthEndPointUrl $(FSSHealthEndpoint)/heartbeat -waitTimeInMinute $(waitTimeInMinute)" - - - job: CheckESS - displayName: "Check ESS Health" - dependsOn: - - LiveDeployApp - - LiveSetup - steps: - - task: PowerShell@2 - displayName: "Check ESS Health endpoint is healthy" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)/QALiveDeployment/check_health_endpoint.ps1' - arguments: "-healthEndPointUrl $(ESSHealthEndpoint)/health -waitTimeInMinute $(waitTimeInMinute)" - - - job: CheckFM - displayName: "Check Fleet Manager Health" - dependsOn: - - LiveDeployApp - - LiveSetup - steps: - - task: PowerShell@2 - displayName: "Check FM Health endpoint is healthy" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)/QALiveDeployment/check_health_endpoint_fm_live.ps1' - arguments: "-healthEndPointUrl $(FMHealthEndpoint)/live/echo/health-check -waitTimeInMinute $(waitTimeInMinute) -ocpapimsubscriptionkey $(FM_Ocp_Apim_Subscription_Key)" - + - template: Deployment/templates/app-deploy.yml + parameters: + Environment: ${{variables.Environment}} + ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} + AzureSubscription: "Exchange-Set-Service-Live-A-008-02" + Container: ${{variables.Container}} + - job: PostDeploymentActions dependsOn: - - LiveDeployApp - - LiveSetup + - DeployApp + - Setup - CheckInfra - CheckFSS - CheckESS @@ -947,7 +180,7 @@ stages: pool: $(WindowPool) displayName: Post Deployment Actions steps: - - template: QALiveDeployment/templates/retain-pipeline.yml + - template: Deployment/templates/retain-pipeline.yml - stage: vNextIATDeploy dependsOn: @@ -955,107 +188,18 @@ stages: displayName: vNext IAT Deploy (inc terraform, webapp deploy) condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/develop'), startsWith(variables['Build.SourceBranch'], 'refs/heads/dev/'))) variables: - - group: "ESS-vNextIAT-Variables" - - group: "ESS-Deployment-Variables-vNextIAT" - - group: "POS-vNextIAT-Variables" - - name: "ESSApiConfiguration.TenantId" - value: $(TenantId) - - name: "ESSApiConfiguration.AutoTestClientId" - value: $(AutoTestClientId_Authed) - - name: "ESSApiConfiguration.AutoTestClientSecret" - value: $(AutoTestClientSecret_Authed) - - name: "ESSApiConfiguration.EssClientId" - value: $(ESSClientId) - - name: "ElasticAPM_ServerURL" - value: $(ElasticAPM.ServerURL) - - name: "ElasticAPM_ApiKey" - value: $(ElasticAPM.ApiKey) + - name: Environment + value: "vnextiat" + - template: Deployment/templates/variables.yml + parameters: + Environment: ${{variables.Environment}} jobs: - - deployment: vNextIATDeployApp - displayName: "vNextIAT - Deploy Terraform and Dotnet App" - environment: "Ess-vnextiat" - pool: $(DeploymentPool) - container: ${{variables.Container}} - workspace: - clean: all - strategy: - runOnce: - deploy: - steps: - - template: vNextIATDeployment/templates/continuous-deployment.yml - parameters: - ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} - AzureSubscription: "Exchange-Set-Service-vNext-IAT-A.011.08" - - - job: vNextIATSetup - displayName: "Set Webjob Configuration For vNextIAT" - dependsOn: vNextIATDeployApp - variables: - - name: WEB_APP_NAME - value: $[ dependencies.vNextIATDeployApp.outputs['vNextIATDeployApp.TerraformDeploy.WEBAPP'] ] - - name: RGName - value: $[ dependencies.vNextIATDeployApp.outputs['vNextIATDeployApp.TerraformDeploy.ResourceGroup'] ] - steps: - - task: AzureCLI@2 - displayName: "Swap Webjob Configuration" - condition: always() - inputs: - azureSubscription: "Exchange-Set-Service-vNext-IAT-A.011.08" - scriptType: 'pscore' - scriptLocation: 'scriptPath' - scriptPath: "$(Build.SourcesDirectory)/vNextIATDeployment/set_webjob_configuration.ps1" - arguments: '-essapibaseurl $(ESSApiConfiguration.BaseUrl) -fssapibaseurl $(FSSApiConfiguration.BaseUrl) -fleetmanagerbaseurl $(FleetManagerB2BApiConfiguration.BaseUrl) -ftrunning "false" -fssapipollingcutoffime $(FSSApiConfiguration.BatchStatusPollingCutoffTime) -fssapipollingdelaytime $(FSSApiConfiguration.BatchStatusPollingDelayTime) -resourcegroup $(RGName) -webappname $(WEB_APP_NAME)' - - - job: CheckInfra - displayName: "Check Infrastructure Health" - dependsOn: vNextIATDeployApp - variables: - - name: WEB_APP_NAME - value: $[ dependencies.vNextIATDeployApp.outputs['vNextIATDeployApp.TerraformDeploy.WEBAPP'] ] - - name: RGName - value: $[ dependencies.vNextIATDeployApp.outputs['vNextIATDeployApp.TerraformDeploy.ResourceGroup'] ] - steps: - - task: AzureCLI@2 - displayName: "Check Infrastructure is healthy" - inputs: - azureSubscription: "Exchange-Set-Service-vNext-IAT-A.011.08" - scriptType: 'pscore' - scriptLocation: 'scriptPath' - scriptPath: '$(Build.SourcesDirectory)/vNextIATDeployment/check_service_status_webjob.ps1' - arguments: '-RGName $(RGName) -webAppName $(WEB_APP_NAME) -waitTimeInMinute $(waitTimeInMinute)' - - - job: CheckFSS - displayName: "Check FSS Health" - dependsOn: vNextIATDeployApp - steps: - - task: PowerShell@2 - displayName: "Check FSS Health endpoint is healthy" - inputs: - targetType: filePath - filePath: "$(Build.SourcesDirectory)/vNextIATDeployment/check_health_endpoint.ps1" - arguments: "-healthEndPointUrl $(FSSHealthEndpoint)/heartbeat -waitTimeInMinute $(waitTimeInMinute)" - - - job: CheckESS - displayName: "Check ESS Health" - dependsOn: vNextIATDeployApp - steps: - - task: PowerShell@2 - displayName: "Check ESS Health endpoint is healthy" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)/vNextIATDeployment/check_health_endpoint.ps1' - arguments: "-healthEndPointUrl $(ESSHealthEndpoint)/health -waitTimeInMinute $(waitTimeInMinute)" - - - job: CheckFM - displayName: "Check Fleet Manager Health" - dependsOn: vNextIATDeployApp - steps: - - task: PowerShell@2 - displayName: "Check FM Health endpoint is healthy" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)/vNextIATDeployment/check_health_endpoint.ps1' - arguments: "-healthEndPointUrl $(FMHealthEndpoint)/health-check -waitTimeInMinute $(waitTimeInMinute)" + - template: Deployment/templates/app-deploy.yml + parameters: + Environment: ${{variables.Environment}} + ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} + AzureSubscription: "Exchange-Set-Service-vNext-IAT-A.011.08" + Container: ${{variables.Container}} - stage: vnexte2eDeploy dependsOn: @@ -1063,104 +207,53 @@ stages: displayName: vNext E2E Deploy (inc terraform, webapp deploy) condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/develop')) variables: - - group: "ESS-vNextE2E-Variables" - - group: "ESS-Deployment-Variables-vNextE2E" - - group: "POS-vNextE2E-Variables" - - name: "ESSApiConfiguration.TenantId" - value: $(TenantId) - - name: "ESSApiConfiguration.AutoTestClientId" - value: $(AutoTestClientId_Authed) - - name: "ESSApiConfiguration.AutoTestClientSecret" - value: $(AutoTestClientSecret_Authed) - - name: "ESSApiConfiguration.EssClientId" - value: $(ESSClientId) - - name: "ElasticAPM_ServerURL" - value: $(ElasticAPM.ServerURL) - - name: "ElasticAPM_ApiKey" - value: $(ElasticAPM.ApiKey) + - name: Environment + value: "vnexte2e" + - template: Deployment/templates/variables.yml + parameters: + Environment: ${{variables.Environment}} jobs: - - deployment: vNextE2EDeployApp - displayName: "vNextE2E - Deploy Terraform and Dotnet App" - environment: "Ess-vnexte2e" - pool: $(DeploymentPool) - container: ${{variables.Container}} - workspace: - clean: all - strategy: - runOnce: - deploy: - steps: - - template: vNextE2EDeployment/templates/continuous-deployment.yml - parameters: - ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} - AzureSubscription: "Exchange-Set-Service-vNext-E2E-A.011.08" - - - job: vNextE2ESetup - displayName: "Set Webjob Configuration For vNextE2E" - dependsOn: vNextE2EDeployApp - variables: - - name: WEB_APP_NAME - value: $[ dependencies.vNextE2EDeployApp.outputs['vNextE2EDeployApp.TerraformDeploy.WEBAPP'] ] - - name: RGName - value: $[ dependencies.vNextE2EDeployApp.outputs['vNextE2EDeployApp.TerraformDeploy.ResourceGroup'] ] - steps: - - task: AzureCLI@2 - displayName: "Swap Webjob Configuration" - condition: always() - inputs: - azureSubscription: "Exchange-Set-Service-vNext-E2E-A.011.08" - scriptType: 'pscore' - scriptLocation: 'scriptPath' - scriptPath: "$(Build.SourcesDirectory)/vNextE2EDeployment/set_webjob_configuration.ps1" - arguments: '-essapibaseurl $(ESSApiConfiguration.BaseUrl) -fssapibaseurl $(FSSApiConfiguration.BaseUrl) -fleetmanagerbaseurl $(FleetManagerB2BApiConfiguration.BaseUrl) -ftrunning "false" -fssapipollingcutoffime $(FSSApiConfiguration.BatchStatusPollingCutoffTime) -fssapipollingdelaytime $(FSSApiConfiguration.BatchStatusPollingDelayTime) -resourcegroup $(RGName) -webappname $(WEB_APP_NAME)' - - - job: CheckInfra - displayName: "Check Infrastructure Health" - dependsOn: vNextE2EDeployApp - variables: - - name: WEB_APP_NAME - value: $[ dependencies.vNextE2EDeployApp.outputs['vNextE2EDeployApp.TerraformDeploy.WEBAPP'] ] - - name: RGName - value: $[ dependencies.vNextE2EDeployApp.outputs['vNextE2EDeployApp.TerraformDeploy.ResourceGroup'] ] - steps: - - task: AzureCLI@2 - displayName: "Check Infrastructure is healthy" - inputs: - azureSubscription: "Exchange-Set-Service-vNext-E2E-A.011.08" - scriptType: 'pscore' - scriptLocation: 'scriptPath' - scriptPath: '$(Build.SourcesDirectory)/vNextE2EDeployment/check_service_status_webjob.ps1' - arguments: '-RGName $(RGName) -webAppName $(WEB_APP_NAME) -waitTimeInMinute $(waitTimeInMinute)' - - - job: CheckFSS - displayName: "Check FSS Health" - dependsOn: vNextE2EDeployApp - steps: - - task: PowerShell@2 - displayName: "Check FSS Health endpoint is healthy" - inputs: - targetType: filePath - filePath: "$(Build.SourcesDirectory)/vNextE2EDeployment/check_health_endpoint.ps1" - arguments: "-healthEndPointUrl $(FSSHealthEndpoint)/heartbeat -waitTimeInMinute $(waitTimeInMinute)" - - - job: CheckESS - displayName: "Check ESS Health" - dependsOn: vNextE2EDeployApp - steps: - - task: PowerShell@2 - displayName: "Check ESS Health endpoint is healthy" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)/vNextE2EDeployment/check_health_endpoint.ps1' - arguments: "-healthEndPointUrl $(ESSHealthEndpoint)/health -waitTimeInMinute $(waitTimeInMinute)" - - - job: CheckFM - displayName: "Check Fleet Manager Health" - dependsOn: vNextE2EDeployApp - steps: - - task: PowerShell@2 - displayName: "Check FM Health endpoint is healthy" - inputs: - targetType: filePath - filePath: '$(Build.SourcesDirectory)/vNextE2EDeployment/check_health_endpoint.ps1' - arguments: "-healthEndPointUrl $(FMHealthEndpoint)/health-check -waitTimeInMinute $(waitTimeInMinute)" + - template: Deployment/templates/app-deploy.yml + parameters: + Environment: ${{variables.Environment}} + ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} + AzureSubscription: "Exchange-Set-Service-vNext-E2E-A.011.08" + Container: ${{variables.Container}} + + - stage: IatDeploy + dependsOn: + - Devdeploy + displayName: IAT Deploy (inc terraform, webapp deploy) + condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/develop'), startsWith(variables['Build.SourceBranch'], 'refs/heads/dev/'))) + variables: + - name: Environment + value: "iat" + - template: Deployment/templates/variables.yml + parameters: + Environment: ${{variables.Environment}} + jobs: + - template: Deployment/templates/app-deploy.yml + parameters: + Environment: ${{variables.Environment}} + ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} + AzureSubscription: "Exchange-Set-Service-IAT-A.011.08" + Container: ${{variables.Container}} + + - stage: PreprodDeploy + dependsOn: + - IatDeploy + displayName: PreProd Deploy (inc terraform, webapp deploy) + condition: and(succeeded(), or(eq(variables['Build.SourceBranch'], 'refs/heads/develop'), startsWith(variables['Build.SourceBranch'], 'refs/heads/dev/'))) + variables: + - name: Environment + value: "preprod" + - template: Deployment/templates/variables.yml + parameters: + Environment: ${{variables.Environment}} + jobs: + - template: Deployment/templates/app-deploy.yml + parameters: + Environment: ${{variables.Environment}} + ContinueEvenIfResourcesAreGettingDestroyed: ${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} + AzureSubscription: "Exchange-Set-Service-Pre-A.011.08" + Container: ${{variables.Container}} \ No newline at end of file diff --git a/vNextE2EDeployment/add-lease.ps1 b/vNextE2EDeployment/add-lease.ps1 deleted file mode 100644 index 1799b455..00000000 --- a/vNextE2EDeployment/add-lease.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -Param( - [Parameter(mandatory=$true)][int]$daysValid, - [Parameter(mandatory=$true)][string]$accessToken, - [Parameter(mandatory=$true)][int]$definitionId, - [Parameter(mandatory=$true)][string]$ownerId, - [Parameter(mandatory=$true)][int]$buildId, - [Parameter(mandatory=$true)][string]$collectionUri, - [Parameter(mandatory=$true)][string]$teamProject -) - -try{ - $contentType = "application/json"; - $headers = @{ Authorization = 'Bearer $accessToken' }; - $rawRequest = @{ daysValid = $daysValid; definitionId = $definitionId; ownerId = $ownerId; protectPipeline = $false; runId = $buildId }; - $request = ConvertTo-Json @($rawRequest); - $uri = "$collectionUri$teamProject/_apis/build/retention/leases?api-version=7.0"; - - Write-Host $request - Write-Host $uri - - Invoke-RestMethod -uri $uri -method POST -Headers $headers -ContentType $contentType -Body $request; - - Write-Host "Pipeline will be retained for $daysValid days" -} -catch{ - Write-Host $_ - Write-Host "##vso[task.complete result=SucceededWithIssues;]" -} diff --git a/vNextE2EDeployment/check_health_endpoint.ps1 b/vNextE2EDeployment/check_health_endpoint.ps1 deleted file mode 100644 index d2476eac..00000000 --- a/vNextE2EDeployment/check_health_endpoint.ps1 +++ /dev/null @@ -1,52 +0,0 @@ -Param( - [Parameter(mandatory=$true)][string]$healthEndPointUrl, - [Parameter(mandatory=$true)][string]$waitTimeInMinute -) - -$sleepTimeInSecond = 15 -$isServiceActive = 'false' - -$stopWatch = New-Object -TypeName System.Diagnostics.Stopwatch -$timeSpan = New-TimeSpan -Minutes $waitTimeInMinute -$stopWatch.Start() - -do -{ - Write-Host "Polling url: $healthEndPointUrl ..." - try{ - $HttpRequest = [System.Net.WebRequest]::Create("$healthEndPointUrl") - $HttpResponse = $HttpRequest.GetResponse() - $HttpStatus = $HttpResponse.StatusCode - Write-Host "Status code of web is $HttpStatus ..." - - If ($HttpStatus -eq 200 ) { - Write-Host "Service is up. Stopping Polling ..." - $isServiceActive = 'true' - break - } - Else { - Write-Host "Service not yet Up. Status code: $HttpStatus re-checking after $sleepTimeInSecond sec ..." - } - } - catch [System.Net.WebException] - { - $HttpStatus = $_.Exception.Response.StatusCode - Write-Host "Service not yet Up.Status: $HttpStatus re-checking after $sleepTimeInSecond sec ..." - } - - Start-Sleep -Seconds $sleepTimeInSecond -} -until ($stopWatch.Elapsed -ge $timeSpan) - - -If ($HttpResponse -ne $null) { - $HttpResponse.Close() -} - -if ($isServiceActive -eq 'true' ) { - Write-Host "Service is up returning from script ..." -} -Else { - Write-Error "Service was not up in $waitTimeInMinute, error while deployment ..." - throw "Error" -} diff --git a/vNextE2EDeployment/check_health_endpoint_fm_live.ps1 b/vNextE2EDeployment/check_health_endpoint_fm_live.ps1 deleted file mode 100644 index 55912c2c..00000000 --- a/vNextE2EDeployment/check_health_endpoint_fm_live.ps1 +++ /dev/null @@ -1,54 +0,0 @@ -Param( - [Parameter(mandatory=$true)][string]$healthEndPointUrl, - [Parameter(mandatory=$true)][string]$waitTimeInMinute, - [Parameter(mandatory=$true)][string]$ocpapimsubscriptionkey -) - -$sleepTimeInSecond = 15 -$isServiceActive = 'false' - -$stopWatch = New-Object -TypeName System.Diagnostics.Stopwatch -$timeSpan = New-TimeSpan -Minutes $waitTimeInMinute -$stopWatch.Start() - -do -{ - Write-Host "Polling url: $healthEndPointUrl ..." - try{ - $HttpRequest = [System.Net.WebRequest]::Create("$healthEndPointUrl") - $HttpRequest.Headers.Add('Ocp-Apim-Subscription-Key', "$ocpapimsubscriptionkey") - $HttpResponse = $HttpRequest.GetResponse() - $HttpStatus = $HttpResponse.StatusCode - Write-Host "Status code of web is $HttpStatus ..." - - If ($HttpStatus -eq 200 ) { - Write-Host "Service is up. Stopping Polling ..." - $isServiceActive = 'true' - break - } - Else { - Write-Host "Service not yet Up. Status code: $HttpStatus re-checking after $sleepTimeInSecond sec ..." - } - } - catch [System.Net.WebException] - { - $HttpStatus = $_.Exception.Response.StatusCode - Write-Host "Service not yet Up.Status: $HttpStatus re-checking after $sleepTimeInSecond sec ..." - } - - Start-Sleep -Seconds $sleepTimeInSecond -} -until ($stopWatch.Elapsed -ge $timeSpan) - - -If ($HttpResponse -ne $null) { - $HttpResponse.Close() -} - -if ($isServiceActive -eq 'true' ) { - Write-Host "Service is up returning from script ..." -} -Else { - Write-Error "Service was not up in $waitTimeInMinute, error while deployment ..." - throw "Error" -} diff --git a/vNextE2EDeployment/check_service_status_webjob.ps1 b/vNextE2EDeployment/check_service_status_webjob.ps1 deleted file mode 100644 index 530fa994..00000000 --- a/vNextE2EDeployment/check_service_status_webjob.ps1 +++ /dev/null @@ -1,49 +0,0 @@ -Param( - [Parameter(mandatory=$true)][string]$RGName, - [Parameter(mandatory=$true)][string]$webAppName, - [Parameter(mandatory=$true)][string]$waitTimeInMinute -) - -$sleepTimeInSecond = 10 -$recheckTimeInSecond = 35 -$isServiceActive = 'false' - -$stopWatch = New-Object -TypeName System.Diagnostics.Stopwatch -$fullTimeSpan = New-TimeSpan -Minutes $waitTimeInMinute -$recheckTimeSpan = New-TimeSpan -Seconds $recheckTimeInSecond -$stopWatch.Start() - -do -{ - Write-Host "Polling AZ ..." - $StateRequest = az webapp show --name $webAppName --resource-group $RGName --query "state" - Write-Host "State of webjob is $StateRequest ..." - - If ($StateRequest -eq '"Running"') { - Write-Host "Webjob service is running..." - $isServiceActive = 'true' - If($stopWatch.Elapsed -ge $recheckTimeSpan) { - Write-Host "Stopping polling ..." - break - } - - } - ElseIf ($StateRequest -eq '"PendingRestart"'){ - Write-Host "Webjob has encountered an error. Webjob state: $StateRequest..." - throw "Error" - } - Else { - Write-Host "Webjob is not yet running. Webjob state: $StateRequest re-checking after $sleepTimeInSecond sec ..." - } - - Start-Sleep -Seconds $sleepTimeInSecond -} -until ($stopWatch.Elapsed -ge $fullTimeSpan) - -if ($isServiceActive -eq 'true' ) { - Write-Host "Webjob is running, returning from script ..." -} -Else { - Write-Error "Error: Webjob was not running within $waitTimeInMinute minutes..." - throw "Error" -} diff --git a/vNextE2EDeployment/set_stub_configuration.ps1 b/vNextE2EDeployment/set_stub_configuration.ps1 deleted file mode 100644 index bb5fe92e..00000000 --- a/vNextE2EDeployment/set_stub_configuration.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -param ( - [Parameter(Mandatory = $true)] [string] $mockresourcegroup, - [Parameter(Mandatory = $true)] [string] $mockwebappname, - [Parameter(Mandatory = $true)] [string] $fleetmanagerfilepath, - [Parameter(Mandatory = $true)] [string] $ftrunning -) - -Write-Output "Set Stub Configuration in appsetting..." -az webapp config appsettings set -g $mockresourcegroup -n $mockwebappname --settings FleetManagerB2BApiConfiguration:GetCatalogueResponseFilePath=$fleetmanagerfilepath IsFTRunning=$ftrunning -az webapp restart --name $mockwebappname --resource-group $mockresourcegroup - - diff --git a/vNextE2EDeployment/set_webjob_configuration.ps1 b/vNextE2EDeployment/set_webjob_configuration.ps1 deleted file mode 100644 index d4a4fa73..00000000 --- a/vNextE2EDeployment/set_webjob_configuration.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -param ( - [Parameter(Mandatory = $true)] [string] $essapibaseurl, - [Parameter(Mandatory = $true)] [string] $resourcegroup, - [Parameter(Mandatory = $true)] [string] $webappname, - [Parameter(Mandatory = $true)] [string] $fssapibaseurl, - [Parameter(Mandatory = $true)] [string] $fleetmanagerbaseurl, - [Parameter(Mandatory = $true)] [string] $ftrunning, - [Parameter(Mandatory = $true)] [string] $fssapipollingcutoffime, - [Parameter(Mandatory = $true)] [string] $fssapipollingdelaytime -) - -Write-Output "Set Webjob Configuration in appsetting..." -az webapp config appsettings set -g $resourcegroup -n $webappname --settings ESSApiConfiguration:BaseUrl=$essapibaseurl FSSApiConfiguration:BaseUrl=$fssapibaseurl FleetManagerB2BApiConfiguration:BaseUrl=$fleetmanagerbaseurl IsFTRunning=$ftrunning FSSApiConfiguration:BatchStatusPollingCutoffTime=$fssapipollingcutoffime FSSApiConfiguration:BatchStatusPollingDelayTime=$fssapipollingdelaytime -az webapp restart --name $webappname --resource-group $resourcegroup diff --git a/vNextE2EDeployment/src/Modules/AppInsights/main.tf b/vNextE2EDeployment/src/Modules/AppInsights/main.tf deleted file mode 100644 index 9f73e3b9..00000000 --- a/vNextE2EDeployment/src/Modules/AppInsights/main.tf +++ /dev/null @@ -1,17 +0,0 @@ -resource "azurerm_log_analytics_workspace" "logs_analytics_workspace" { - name = "${var.name}-workspace" - location = var.location - resource_group_name = var.resource_group_name - sku = "PerGB2018" - retention_in_days = 30 - tags = var.tags -} - -resource "azurerm_application_insights" "app_insights" { - name = var.name - location = var.location - resource_group_name = var.resource_group_name - application_type = "web" - workspace_id = azurerm_log_analytics_workspace.logs_analytics_workspace.id - tags = var.tags -} diff --git a/vNextE2EDeployment/src/Modules/AppInsights/outputs.tf b/vNextE2EDeployment/src/Modules/AppInsights/outputs.tf deleted file mode 100644 index ebebdb1b..00000000 --- a/vNextE2EDeployment/src/Modules/AppInsights/outputs.tf +++ /dev/null @@ -1,8 +0,0 @@ -output "instrumentation_key" { - value = azurerm_application_insights.app_insights.instrumentation_key -} - -output "connection_string" { - value = azurerm_application_insights.app_insights.connection_string - sensitive = true -} diff --git a/vNextE2EDeployment/src/Modules/AppInsights/variables.tf b/vNextE2EDeployment/src/Modules/AppInsights/variables.tf deleted file mode 100644 index 9c44bd70..00000000 --- a/vNextE2EDeployment/src/Modules/AppInsights/variables.tf +++ /dev/null @@ -1,15 +0,0 @@ -variable "name" { - type = string -} - -variable "resource_group_name" { - type = string -} - -variable "location" { - type = string -} - -variable "tags" { - -} diff --git a/vNextE2EDeployment/src/Modules/EventHub/main.tf b/vNextE2EDeployment/src/Modules/EventHub/main.tf deleted file mode 100644 index 48f6c93b..00000000 --- a/vNextE2EDeployment/src/Modules/EventHub/main.tf +++ /dev/null @@ -1,50 +0,0 @@ -resource "azurerm_eventhub_namespace" "eventhub_namespace" { - name = "${var.name}-namespace" - location = var.location - resource_group_name = var.resource_group_name - sku = "Standard" - capacity = 1 - tags = var.tags -} - -resource "azurerm_eventhub" "eventhub" { - name = var.name - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - resource_group_name = var.resource_group_name - partition_count = 2 - message_retention = 7 -} - -resource "azurerm_eventhub_consumer_group" "logging_application_consumer_group" { - name = "loggingApplication" - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - eventhub_name = azurerm_eventhub.eventhub.name - resource_group_name = var.resource_group_name -} - -resource "azurerm_eventhub_consumer_group" "logstash_consumer_group" { - name = "logstash" - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - eventhub_name = azurerm_eventhub.eventhub.name - resource_group_name = var.resource_group_name -} - -resource "azurerm_eventhub_authorization_rule" "log" { - name = "logAccessKey" - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - eventhub_name = azurerm_eventhub.eventhub.name - resource_group_name = var.resource_group_name - listen = false - send = true - manage = false -} - -resource "azurerm_eventhub_authorization_rule" "logstash" { - name = "logstashAccessKey" - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - eventhub_name = azurerm_eventhub.eventhub.name - resource_group_name = var.resource_group_name - listen = true - send = false - manage = false -} diff --git a/vNextE2EDeployment/src/Modules/EventHub/outputs.tf b/vNextE2EDeployment/src/Modules/EventHub/outputs.tf deleted file mode 100644 index 0a570f8a..00000000 --- a/vNextE2EDeployment/src/Modules/EventHub/outputs.tf +++ /dev/null @@ -1,9 +0,0 @@ -output "log_primary_connection_string" { - value = azurerm_eventhub_authorization_rule.log.primary_connection_string - sensitive = true -} - -output "entity_path" { - value = azurerm_eventhub.eventhub.name - sensitive = true -} diff --git a/vNextE2EDeployment/src/Modules/EventHub/variables.tf b/vNextE2EDeployment/src/Modules/EventHub/variables.tf deleted file mode 100644 index b222f79b..00000000 --- a/vNextE2EDeployment/src/Modules/EventHub/variables.tf +++ /dev/null @@ -1,19 +0,0 @@ -variable "name" { - type = string -} - -variable "resource_group_name" { - type = string -} - -variable "location" { - type = string -} - -variable "tags" { - -} - -variable "env_name" { - type = string -} diff --git a/vNextE2EDeployment/src/Modules/KeyVault/main.tf b/vNextE2EDeployment/src/Modules/KeyVault/main.tf deleted file mode 100644 index 7dba76e1..00000000 --- a/vNextE2EDeployment/src/Modules/KeyVault/main.tf +++ /dev/null @@ -1,68 +0,0 @@ -data "azurerm_client_config" "current" {} - -resource "azurerm_key_vault" "kv" { - name = var.name - location = var.location - resource_group_name = var.resource_group_name - enabled_for_disk_encryption = true - tenant_id = var.tenant_id - - sku_name = "standard" - - network_acls { - default_action = "Deny" - bypass = "AzureServices" - ip_rules = var.allowed_ips - virtual_network_subnet_ids = var.allowed_subnet_ids - } - - tags = var.tags -} - -#access policy for terraform script service account -resource "azurerm_key_vault_access_policy" "kv_access_terraform" { - key_vault_id = azurerm_key_vault.kv.id - tenant_id = data.azurerm_client_config.current.tenant_id - object_id = data.azurerm_client_config.current.object_id - - key_permissions = [ - "Create", - "Get", - ] - - secret_permissions = [ - "Set", - "Get", - "Delete", - "Recover", - "Purge" - ] -} - -#access policy for read access (app service) -resource "azurerm_key_vault_access_policy" "kv_read_access" { - for_each = var.read_access_objects - key_vault_id = azurerm_key_vault.kv.id - tenant_id = var.tenant_id - object_id = each.value - - key_permissions = [ - "List", - "Get", - ] - - secret_permissions = [ - "List", - "Get" - ] -} - -resource "azurerm_key_vault_secret" "passed_in_secrets" { - count = length(var.secrets) - name = keys(var.secrets)[count.index] - value = values(var.secrets)[count.index] - key_vault_id = azurerm_key_vault.kv.id - tags = var.tags - - depends_on = [azurerm_key_vault_access_policy.kv_access_terraform] -} diff --git a/vNextE2EDeployment/src/Modules/KeyVault/outputs.tf b/vNextE2EDeployment/src/Modules/KeyVault/outputs.tf deleted file mode 100644 index 0772ec06..00000000 --- a/vNextE2EDeployment/src/Modules/KeyVault/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output keyvault_uri { - value = azurerm_key_vault.kv.vault_uri -} diff --git a/vNextE2EDeployment/src/Modules/KeyVault/variables.tf b/vNextE2EDeployment/src/Modules/KeyVault/variables.tf deleted file mode 100644 index 93bbffb3..00000000 --- a/vNextE2EDeployment/src/Modules/KeyVault/variables.tf +++ /dev/null @@ -1,46 +0,0 @@ -variable "name" { - type = string -} - -variable "resource_group_name" { - type = string -} - -variable "location" { - type = string -} - -variable "tenant_id" { - type = string -} - -variable "env_name" { - type = string -} - -variable "read_access_objects" { - type = map(string) -} - -variable "secrets" { - type = map(string) -} - -variable "tags" { -} - -variable "allowed_subnet_ids" { - type = list -} - -variable "allowed_ips" { -} - - -variable "agent_2204_subnet" { - type = string -} - -variable "agent_prd_subnet" { - type = string -} diff --git a/vNextE2EDeployment/src/Modules/MockWebApp/main.tf b/vNextE2EDeployment/src/Modules/MockWebApp/main.tf deleted file mode 100644 index b712caeb..00000000 --- a/vNextE2EDeployment/src/Modules/MockWebApp/main.tf +++ /dev/null @@ -1,48 +0,0 @@ -resource "azurerm_windows_web_app" "mock_webapp_service" { - name = var.name - location = var.location - resource_group_name = var.resource_group_name - service_plan_id = var.service_plan_id - tags = var.tags - - site_config { - application_stack { - current_stack = "dotnet" - dotnet_version = "v6.0" - } - always_on = true - ftps_state = "Disabled" - - ip_restriction { - virtual_network_subnet_id = var.subnet_id - } - - ip_restriction { - virtual_network_subnet_id = var.main_subnet_id - } - - dynamic "ip_restriction" { - for_each = var.allowed_ips - content { - ip_address = length(split("/",ip_restriction.value)) > 1 ? ip_restriction.value : "${ip_restriction.value}/32" - } - } - } - - app_settings = var.app_settings - - identity { - type = "SystemAssigned" - } - - lifecycle { - ignore_changes = [ virtual_network_subnet_id ] - } - - https_only = true -} - -resource "azurerm_app_service_virtual_network_swift_connection" "mock_webapp_vnet_integration" { - app_service_id = azurerm_windows_web_app.mock_webapp_service.id - subnet_id = var.subnet_id -} diff --git a/vNextE2EDeployment/src/Modules/MockWebApp/outputs.tf b/vNextE2EDeployment/src/Modules/MockWebApp/outputs.tf deleted file mode 100644 index cbe5fc0f..00000000 --- a/vNextE2EDeployment/src/Modules/MockWebApp/outputs.tf +++ /dev/null @@ -1,11 +0,0 @@ -output "web_app_object_id" { - value = azurerm_windows_web_app.mock_webapp_service.identity.0.principal_id -} - -output "web_app_tenant_id" { - value = azurerm_windows_web_app.mock_webapp_service.identity.0.tenant_id -} - -output "default_site_hostname" { - value = azurerm_windows_web_app.mock_webapp_service.default_hostname -} diff --git a/vNextE2EDeployment/src/Modules/Storage/main.tf b/vNextE2EDeployment/src/Modules/Storage/main.tf deleted file mode 100644 index ee9779a2..00000000 --- a/vNextE2EDeployment/src/Modules/Storage/main.tf +++ /dev/null @@ -1,60 +0,0 @@ -resource "azurerm_storage_account" "pos_storage" { - name = lower("${var.service_name}${var.env_name}storageukho") - resource_group_name = var.resource_group_name - location = var.location - account_tier = "Standard" - account_replication_type = "LRS" - account_kind = "StorageV2" - - tags = var.tags - network_rules { - default_action = "Deny" - ip_rules = var.allowed_ips - bypass = ["Logging", "Metrics", "AzureServices"] - virtual_network_subnet_ids = [var.m_spoke_subnet, var.agent_2204_subnet, var.agent_prd_subnet] -} -} - -resource "azurerm_storage_account" "bess_storage" { - name = lower("${var.service_name_bess}${var.env_name}storageukho") - resource_group_name = var.resource_group_name - location = var.location - account_tier = "Standard" - account_replication_type = "LRS" - account_kind = "StorageV2" - - tags = var.tags - network_rules { - default_action = "Deny" - ip_rules = var.allowed_ips - bypass = ["Logging", "Metrics", "AzureServices"] - virtual_network_subnet_ids = [var.m_spoke_subnet,var.mock_spoke_subnet,var.agent_2204_subnet, var.agent_prd_subnet] -} -} - -resource "azurerm_storage_container" "bess_config_container" { - name = var.container_name - storage_account_name = azurerm_storage_account.bess_storage.name -} - -resource "azurerm_storage_account" "bess_storage" { - name = lower("${var.service_name_bess}${var.env_name}storageukho") - resource_group_name = var.resource_group_name - location = var.location - account_tier = "Standard" - account_replication_type = "LRS" - account_kind = "StorageV2" - - tags = var.tags - network_rules { - default_action = "Deny" - ip_rules = var.allowed_ips - bypass = ["Logging", "Metrics", "AzureServices"] - virtual_network_subnet_ids = [var.m_spoke_subnet,var.agent_subnet] -} -} - -resource "azurerm_storage_container" "bess_config_container" { - name = var.container_name - storage_account_name = azurerm_storage_account.bess_storage.name -} diff --git a/vNextE2EDeployment/src/Modules/Storage/outputs.tf b/vNextE2EDeployment/src/Modules/Storage/outputs.tf deleted file mode 100644 index e2895b8c..00000000 --- a/vNextE2EDeployment/src/Modules/Storage/outputs.tf +++ /dev/null @@ -1,13 +0,0 @@ -output pos_storage_name { - value = azurerm_storage_account.pos_storage.name -} - -output pos_storage_connection_string { - value = azurerm_storage_account.pos_storage.primary_connection_string - sensitive = true -} - -output bess_storage_connection_string { - value = azurerm_storage_account.bess_storage.primary_connection_string - sensitive = true -} diff --git a/vNextE2EDeployment/src/Modules/Storage/variables.tf b/vNextE2EDeployment/src/Modules/Storage/variables.tf deleted file mode 100644 index 93d12193..00000000 --- a/vNextE2EDeployment/src/Modules/Storage/variables.tf +++ /dev/null @@ -1,46 +0,0 @@ - -variable "resource_group_name" { - type = string -} - -variable "location" { - type = string -} - -variable "env_name" { - type = string -} - -variable "tags" { -} - -variable "service_name" { - type = string -} - -variable "service_name_bess" { - type = string -} - -variable "container_name" { - type = string -} - -variable "m_spoke_subnet" { - type = string -} - -variable "mock_spoke_subnet" { - type = string -} - -variable "allowed_ips" { -} - -variable "agent_2204_subnet" { - type = string -} - -variable "agent_prd_subnet" { - type = string -} diff --git a/vNextE2EDeployment/src/Modules/Webapp/main.tf b/vNextE2EDeployment/src/Modules/Webapp/main.tf deleted file mode 100644 index 8fa44a3f..00000000 --- a/vNextE2EDeployment/src/Modules/Webapp/main.tf +++ /dev/null @@ -1,44 +0,0 @@ -resource "azurerm_windows_web_app" "webapp_service" { - name = var.name - location = var.location - resource_group_name = var.resource_group_name - service_plan_id = var.service_plan_id - tags = var.tags - - site_config { - application_stack { - current_stack = "dotnet" - dotnet_version = "v6.0" - } - always_on = true - ftps_state = "Disabled" - - ip_restriction { - virtual_network_subnet_id = var.subnet_id - } - - dynamic "ip_restriction" { - for_each = var.allowed_ips - content { - ip_address = length(split("/",ip_restriction.value)) > 1 ? ip_restriction.value : "${ip_restriction.value}/32" - } - } - } - - app_settings = var.app_settings - - identity { - type = "SystemAssigned" - } - - lifecycle { - ignore_changes = [ virtual_network_subnet_id ] - } - - https_only = true -} - -resource "azurerm_app_service_virtual_network_swift_connection" "webapp_vnet_integration" { - app_service_id = azurerm_windows_web_app.webapp_service.id - subnet_id = var.subnet_id -} diff --git a/vNextE2EDeployment/src/Modules/Webapp/variables.tf b/vNextE2EDeployment/src/Modules/Webapp/variables.tf deleted file mode 100644 index 0fc55fae..00000000 --- a/vNextE2EDeployment/src/Modules/Webapp/variables.tf +++ /dev/null @@ -1,35 +0,0 @@ -variable "name" { - type = string -} - -variable "resource_group_name" { - type = string -} - -variable "service_plan_id" { - type = string -} - -variable "location" { - type = string -} - -variable "app_settings" { - type = map(string) -} - -variable "tags" { - -} - -variable "env_name" { - type = string -} - -variable "subnet_id" { - type = string -} - -variable "allowed_ips" { - -} diff --git a/vNextE2EDeployment/src/azure.tf b/vNextE2EDeployment/src/azure.tf deleted file mode 100644 index d4c8c2fc..00000000 --- a/vNextE2EDeployment/src/azure.tf +++ /dev/null @@ -1,24 +0,0 @@ -terraform { - required_providers { - azurerm = { - source = "hashicorp/azurerm" - version = "=3.116.0" - } - } - - required_version = "=1.9.6" - backend "azurerm" { - container_name = "tfstate" - key = "posterraform.deployment.tfplan" - } -} - -provider "azurerm" { - features {} -} - -provider "azurerm" { - features {} - alias = "build_agent" - subscription_id = var.agent_subscription_id -} diff --git a/vNextE2EDeployment/src/main.tf b/vNextE2EDeployment/src/main.tf deleted file mode 100644 index e254f3b0..00000000 --- a/vNextE2EDeployment/src/main.tf +++ /dev/null @@ -1,131 +0,0 @@ -data "azurerm_subnet" "main_subnet" { - name = var.spoke_subnet_name - virtual_network_name = var.spoke_vnet_name - resource_group_name = var.spoke_rg -} - -data "azurerm_subnet" "mock_main_subnet" { - name = var.mock_spoke_subnet_name - virtual_network_name = var.spoke_vnet_name - resource_group_name = var.spoke_rg -} - -data "azurerm_app_service_plan" "essft_asp" { - name = "ess-vne-sxs-2-asp" - resource_group_name = "ess-vne-rg" -} - -data "azurerm_app_service_plan" "ess_asp" { - name = "ess-${local.env_name}-lxs-1-asp" - resource_group_name = "ess-${local.env_name}-rg" -} - -module "app_insights" { - source = "./Modules/AppInsights" - name = "${local.service_name}-${local.env_name}-insights" - resource_group_name = azurerm_resource_group.webapp_rg.name - location = azurerm_resource_group.webapp_rg.location - tags = local.tags -} - -module "eventhub" { - source = "./Modules/EventHub" - name = "${local.service_name}-${local.env_name}-events" - resource_group_name = azurerm_resource_group.webapp_rg.name - location = azurerm_resource_group.webapp_rg.location - tags = local.tags - env_name = local.env_name -} - -module "mock_webapp_service" { - source = "./Modules/MockWebApp" - name = local.mock_web_app_name - env_name = local.env_name - resource_group_name = azurerm_resource_group.mock_webapp_rg.name - service_plan_id = data.azurerm_app_service_plan.essft_asp.id - location = azurerm_resource_group.mock_webapp_rg.location - subnet_id = data.azurerm_subnet.mock_main_subnet.id - main_subnet_id = data.azurerm_subnet.main_subnet.id - app_settings = { - "ASPNETCORE_ENVIRONMENT" = local.env_name - "WEBSITE_RUN_FROM_PACKAGE" = "1" - "WEBSITE_ENABLE_SYNC_UPDATE_SITE" = "true" - "APPINSIGHTS_INSTRUMENTATIONKEY" = "NOT_CONFIGURED" - } - tags = local.tags - allowed_ips = var.allowed_ips -} - -module "webapp_service" { - source = "./Modules/Webapp" - name = local.web_app_name - resource_group_name = azurerm_resource_group.webapp_rg.name - service_plan_id = data.azurerm_app_service_plan.ess_asp.id - env_name = local.env_name - location = azurerm_resource_group.webapp_rg.location - subnet_id = data.azurerm_subnet.main_subnet.id - app_settings = { - "EventHubLoggingConfiguration:Environment" = local.env_name - "EventHubLoggingConfiguration:MinimumLoggingLevel" = "Warning" - "EventHubLoggingConfiguration:UkhoMinimumLoggingLevel" = "Information" - "APPINSIGHTS_INSTRUMENTATIONKEY" = module.app_insights.instrumentation_key - "ASPNETCORE_ENVIRONMENT" = local.env_name - "WEBSITE_RUN_FROM_PACKAGE" = "1" - "WEBSITE_ENABLE_SYNC_UPDATE_SITE" = "true" - "FSSApiConfiguration:BusinessUnit" = "AVCSData" - "FSSApiConfiguration:PosReadGroups" = "public" - "FSSApiConfiguration:PosReadUsers" = "" - "FSSApiConfiguration:AIOBusinessUnit" = "AVCSData" - "FSSApiConfiguration:AIOReadGroups" = "public" - "FSSApiConfiguration:AIOReadUsers" = "" - "ELASTIC_APM_SERVER_URL" = var.elastic_apm_server_url - "ELASTIC_APM_TRANSACTION_SAMPLE_RATE" = "1" - "ELASTIC_APM_ENVIRONMENT" = local.env_name - "ELASTIC_APM_SERVICE_NAME" = "POS Web Job" - "ELASTIC_APM_API_KEY" = var.elastic_apm_api_key - "BessStorageConfiguration:ContainerName" = var.BessContainerName - } - tags = local.tags - allowed_ips = var.allowed_ips -} - -module "storage" { - source = "./Modules/Storage" - resource_group_name = azurerm_resource_group.webapp_rg.name - location = azurerm_resource_group.webapp_rg.location - allowed_ips = var.allowed_ips - m_spoke_subnet = data.azurerm_subnet.main_subnet.id - mock_spoke_subnet = data.azurerm_subnet.mock_main_subnet.id - agent_2204_subnet = var.agent_2204_subnet - agent_prd_subnet = var.agent_prd_subnet - env_name = local.env_name - service_name = local.service_name - service_name_bess = local.service_name_bess - container_name = local.container_name - tags = local.tags -} - -module "key_vault" { - source = "./Modules/KeyVault" - name = local.key_vault_name - resource_group_name = azurerm_resource_group.webapp_rg.name - env_name = local.env_name - tenant_id = module.webapp_service.web_app_tenant_id - allowed_ips = var.allowed_ips - allowed_subnet_ids = [data.azurerm_subnet.main_subnet.id, var.agent_2204_subnet,var.agent_prd_subnet] - location = azurerm_resource_group.webapp_rg.location - agent_2204_subnet = var.agent_2204_subnet - agent_prd_subnet = var.agent_prd_subnet - read_access_objects = { - "webapp_service" = module.webapp_service.web_app_object_id - } - secrets = { - "EventHubLoggingConfiguration--ConnectionString" = module.eventhub.log_primary_connection_string - "EventHubLoggingConfiguration--EntityPath" = module.eventhub.entity_path - "ApplicationInsights--ConnectionString" = module.app_insights.connection_string - "BessStorageConfiguration--ConnectionString" = module.storage.bess_storage_connection_string - "AzureWebJobsStorage" = module.storage.bess_storage_connection_string - "PKSApiConfiguration--PermitDecryptionHardwareId" = var.permitdecryptionhardwareid - } - tags = local.tags -} diff --git a/vNextE2EDeployment/src/outputs.tf b/vNextE2EDeployment/src/outputs.tf deleted file mode 100644 index f168c366..00000000 --- a/vNextE2EDeployment/src/outputs.tf +++ /dev/null @@ -1,70 +0,0 @@ -output "web_app_name" { - value = local.web_app_name -} - -output "env_name" { - value = local.env_name -} - -output "webapp_rg" { - value = azurerm_resource_group.webapp_rg.name -} - -output "Website_Url" { - value = "https://${module.webapp_service.default_site_hostname}/" -} - -output "kv_name" { - value = local.key_vault_name -} - -output "pos_storage_name" { -value = module.storage.pos_storage_name -} - -output "pos_storage_connection_string"{ - value = module.storage.pos_storage_connection_string - sensitive = true -} - -output "bess_storage_connection_string"{ - value = module.storage.bess_storage_connection_string - sensitive = true -} - -output "log_primary_connection_string" { - value = module.eventhub.log_primary_connection_string - sensitive = true -} - -output "entity_path" { - value = module.eventhub.entity_path - sensitive = true -} - -output "webjob_username" { - value = module.webapp_service.username - sensitive = true -} - -output "webjob_password" { - value = module.webapp_service.password - sensitive = true -} - -output "connection_string" { - value = module.app_insights.connection_string - sensitive = true -} - -output "mock_webappname" { - value = local.mock_web_app_name -} - -output "mock_webapp_rg" { -value = azurerm_resource_group.mock_webapp_rg.name -} - -output "keyvault_uri"{ - value = module.key_vault.keyvault_uri -} diff --git a/vNextE2EDeployment/src/variables.tf b/vNextE2EDeployment/src/variables.tf deleted file mode 100644 index 79627282..00000000 --- a/vNextE2EDeployment/src/variables.tf +++ /dev/null @@ -1,75 +0,0 @@ -variable "location" { - type = string - default = "uksouth" -} - -variable "resource_group_name" { - type = string - default = "pos" -} - -locals { - env_name = lower(terraform.workspace) - service_name = "pos" - web_app_name = "${local.service_name}-${local.env_name}-lxs-webapp" - mock_web_app_name = "${local.service_name}-${local.env_name}-mock-webapp" - pks_mock_web_app_name = "${local.service_name}-${local.env_name}-pks-mock-webapp" - key_vault_name = "${local.service_name}-ukho-${local.env_name}-kv" - service_name_bess = "bess" - container_name = "bess-configs" - - tags = { - SERVICE = "Periodic Output Service" - ENVIRONMENT = local.env_name - SERVICE_OWNER = "UKHO" - RESPONSIBLE_TEAM = "Abzu" - CALLOUT_TEAM = "On-Call_N/A" - COST_CENTRE = "A.008.02" - } -} - -variable "spoke_rg" { - type = string -} - -variable "spoke_vnet_name" { - type = string -} - -variable "spoke_subnet_name" { - type = string -} - -variable "mock_spoke_subnet_name" { - type = string -} - -variable "agent_subscription_id" { - type = string -} - -variable "allowed_ips" { - type = list -} - -variable "elastic_apm_server_url" { -} - -variable "elastic_apm_api_key" { -} - -variable "agent_2204_subnet" { - type = string -} - -variable "agent_prd_subnet" { - type = string -} - -variable "permitdecryptionhardwareid" { - type = string -} - -variable "BessContainerName" { - type = string -} diff --git a/vNextE2EDeployment/templates/continuous-deployment.yml b/vNextE2EDeployment/templates/continuous-deployment.yml deleted file mode 100644 index 27ed5b94..00000000 --- a/vNextE2EDeployment/templates/continuous-deployment.yml +++ /dev/null @@ -1,62 +0,0 @@ -parameters: - - name: ContinueEvenIfResourcesAreGettingDestroyed - type: boolean - default: false - - name: AzureSubscription - type: string - -steps: - - - task: PowerShell@2 - displayName: "Terraform $(Environment)deploy" - name: TerraformDeploy - inputs: - targetType: filePath - filePath: '$(Pipeline.Workspace)/vnexte2eterraformartifact/terraform_conditional_run.ps1' - arguments: '-deploymentResourceGroupName $(DeploymentResourceGroupName) -deploymentStorageAccountName $(DeploymentStorageAccountName) -workSpace $(Environment) -continueEvenIfResourcesAreGettingDestroyed $${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} -terraformJsonOutputFile $(Pipeline.Workspace)/qaliveterraformartifact/terraform_output.json -elasticApmServerUrl $(ElasticAPM_ServerURL) -elasticApmApiKey $(ElasticAPM_ApiKey)' - env: - ARM_CLIENT_ID: $(TERRAFORM-CLIENT-ID) - ARM_CLIENT_SECRET: $(TERRAFORM-CLIENT-SECRET) - ARM_TENANT_ID: $(TERRAFORM-TENANT-ID) - ARM_SUBSCRIPTION_ID: $(TERRAFORM-SUBSCRIPTION-ID) - TF_VAR_spoke_rg: $(spokeRG) - TF_VAR_spoke_vnet_name: $(spokeVnetName) - TF_VAR_spoke_subnet_name: $(POSESSspokeSubnetName) - TF_VAR_mock_spoke_subnet_name: $(POSESSmockspokeSubnetName) - TF_VAR_allowed_ips: $(whiteListedIps) - TF_VAR_permitdecryptionhardwareid: $(PermitDecryptionHardwareId) - TF_VAR_agent_2204_subnet: $(agent2204SubnetId) - TF_VAR_agent_prd_subnet: $(agentprdSubnetId) - TF_VAR_agent_subscription_id: $(agentSubscriptionId) - TF_VAR_BessContainerName: $(BessContainerForWebjob) - - - task: FileTransform@2 - displayName: "File Transform: Mock API WebApp" - inputs: - folderPath: '$(Pipeline.Workspace)/MockWebAPI/*.zip' - xmlTransformationRules: - jsonTargetFiles: '**/appsettings.json' - - - task: AzureCLI@2 - displayName: "Mock API WebApp deployment" - inputs: - azureSubscription: "${{ parameters.AzureSubscription }}" - scriptType: 'pscore' - scriptLocation: 'scriptPath' - scriptPath: '$(Pipeline.Workspace)/vnexte2eterraformartifact/mock_api_deployment.ps1' - arguments: '-mockWebAppName $(mockWebAppName) -mockApipackagePath "$(Pipeline.Workspace)/MockWebAPI/UKHO.FmEssFssMock.API.zip" -mockWebAppResourceGroup $(mockWebAppResourceGroup)' - - - task: FileTransform@2 - displayName: "File Transform: POS Config" - inputs: - folderPath: '$(Pipeline.Workspace)/PeriodicOutputService/*.zip' - xmlTransformationRules: - jsonTargetFiles: '**/appsettings.json' - - - task: AzureWebApp@1 - displayName: "Azure LXS App Deploy: pos-$(Environment)-lxs-webapp" - inputs: - azureSubscription: "${{ parameters.AzureSubscription }}" - appType: webApp - appName: "$(WEB_APP_NAME)" - package: "$(Pipeline.Workspace)/PeriodicOutputService/PeriodicOutputFulfilmentService.zip" diff --git a/vNextE2EDeployment/templates/retain-pipeline.yml b/vNextE2EDeployment/templates/retain-pipeline.yml deleted file mode 100644 index 2479bb05..00000000 --- a/vNextE2EDeployment/templates/retain-pipeline.yml +++ /dev/null @@ -1,14 +0,0 @@ -steps: - - task: PowerShell@2 - condition: and(succeeded(), not(canceled())) - displayName: Retain Live Release - inputs: - targetType: filePath - filePath: "$(Build.SourcesDirectory)/QALiveDeployment/add-lease.ps1" - arguments: "-daysValid 365 - -accessToken '$(System.AccessToken)' - -definitionId $(System.DefinitionId) - -ownerId 'User:$(Build.RequestedForId)' - -buildId $(Build.BuildId) - -collectionUri '$(System.CollectionUri)' - -teamProject '$(System.TeamProject)'" diff --git a/vNextE2EDeployment/terraform_conditional_run.ps1 b/vNextE2EDeployment/terraform_conditional_run.ps1 deleted file mode 100644 index 511b9432..00000000 --- a/vNextE2EDeployment/terraform_conditional_run.ps1 +++ /dev/null @@ -1,77 +0,0 @@ -param ( - [Parameter(Mandatory = $true)] [string] $deploymentResourceGroupName, - [Parameter(Mandatory = $true)] [string] $deploymentStorageAccountName, - [Parameter(Mandatory = $true)] [string] $workSpace, - [Parameter(Mandatory = $true)] [boolean] $continueEvenIfResourcesAreGettingDestroyed, - [Parameter(Mandatory = $true)] [string] $terraformJsonOutputFile, - [Parameter(Mandatory = $true)] [string] $elasticApmServerUrl, - [Parameter(Mandatory = $true)] [string] $elasticApmApiKey -) - -cd $env:AGENT_BUILDDIRECTORY/vnexte2eterraformartifact/src - -terraform --version - -Write-output "Executing terraform scripts for deployment in $workSpace enviroment" -terraform init -backend-config="resource_group_name=$deploymentResourceGroupName" -backend-config="storage_account_name=$deploymentStorageAccountName" -backend-config="key=posterraform.deployment.tfplan" -if ( !$? ) { echo "Something went wrong during terraform initialization"; throw "Error" } - -Write-output "Selecting workspace" - -$ErrorActionPreference = 'SilentlyContinue' -terraform workspace new $WorkSpace 2>&1 > $null -$ErrorActionPreference = 'Continue' - -terraform workspace select $workSpace -if ( !$? ) { echo "Error while selecting workspace"; throw "Error" } - -Write-output "Validating terraform" -terraform validate -if ( !$? ) { echo "Something went wrong during terraform validation" ; throw "Error" } - -Write-output "Execute Terraform plan" -terraform plan -out "posterraform.deployment.tfplan" -var elastic_apm_server_url=$elasticApmServerUrl -var elastic_apm_api_key=$elasticApmApiKey | tee terraform_output.txt -if ( !$? ) { echo "Something went wrong during terraform plan" ; throw "Error" } - -$totalDestroyLines=(Get-Content -Path terraform_output.txt | Select-String -Pattern "destroy" -CaseSensitive | where {$_ -ne ""}).length -if($totalDestroyLines -ge 2) -{ - write-Host("Terraform is destroying some resources, please verify...................") - if ( !$ContinueEvenIfResourcesAreGettingDestroyed) - { - write-Host("exiting...................") - Write-Output $_ - exit 1 - } - write-host("Continue executing terraform apply - as continueEvenIfResourcesAreGettingDestroyed param is set to true in pipeline") -} - -Write-output "Executing terraform apply" -terraform apply "posterraform.deployment.tfplan" -if ( !$? ) { echo "Something went wrong during terraform apply" ; throw "Error" } - -Write-output "Terraform output as json" -$terraformOutput = terraform output -json | ConvertFrom-Json - -write-output "Set JSON output into pipeline variables" -Write-Host "##vso[task.setvariable variable=Website_Url]$($terraformOutput.Website_Url.value)" -Write-Host "##vso[task.setvariable variable=WEB_APP_NAME]$($terraformOutput.web_app_name.value)" -Write-Host "##vso[task.setvariable variable=mockWebAppName]$($terraformOutput.mock_webappname.value)" -Write-Host "##vso[task.setvariable variable=mock_web_app_url]$($terraformOutput.fm_mock_web_app_url.value)" -Write-Host "##vso[task.setvariable variable=mockWebAppResourceGroup]$($terraformOutput.mock_webapp_rg.value)" -Write-Host "##vso[task.setvariable variable=RGName]$($terraformOutput.webapp_rg.value)" -Write-Host "##vso[task.setvariable variable=WEBAPP;isOutput=true]$($terraformOutput.web_app_name.value)" -Write-Host "##vso[task.setvariable variable=mockWebApp;isOutput=true]$($terraformOutput.mock_webappname.value)" -Write-Host "##vso[task.setvariable variable=mockWebAppResourceGroupName;isOutput=true]$($terraformOutput.mock_webapp_rg.value)" -Write-Host "##vso[task.setvariable variable=ResourceGroup;isOutput=true]$($terraformOutput.webapp_rg.value)" -Write-Host "##vso[task.setvariable variable=webJobUsername;isOutput=true]$($terraformOutput.webjob_username.value)" -Write-Host "##vso[task.setvariable variable=webJobPassword;issecret=true;isOutput=true]$($terraformOutput.webjob_password.value)" -Write-Host "##vso[task.setvariable variable=AzureStorageConfiguration.ConnectionString;issecret=true]$($terraformOutput.pos_storage_connection_string.value)" -Write-Host "##vso[task.setvariable variable=BessStorageConfiguration.ConnectionString;issecret=true]$($terraformOutput.bess_storage_connection_string.value)" -Write-Host "##vso[task.setvariable variable=EventHubLoggingConfiguration.ConnectionString;issecret=true]$($terraformOutput.log_primary_connection_string.value)" -Write-Host "##vso[task.setvariable variable=EventHubLoggingConfiguration.EntityPath;issecret=true]$($terraformOutput.entity_path.value)" -Write-Host "##vso[task.setvariable variable=ApplicationInsights.ConnectionString;issecret=true]$($terraformOutput.connection_string.value)" -Write-Host "##vso[task.setvariable variable=AzureWebJobsStorage;issecret=true]$($terraformOutput.bess_storage_connection_string.value)" -Write-Host "##vso[task.setvariable variable=KeyVaultSettings.ServiceUri]$($terraformOutput.keyvault_uri.value)" - -$terraformOutput | ConvertTo-Json -Depth 5 > $terraformJsonOutputFile diff --git a/vNextIATDeployment/add-lease.ps1 b/vNextIATDeployment/add-lease.ps1 deleted file mode 100644 index 1799b455..00000000 --- a/vNextIATDeployment/add-lease.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -Param( - [Parameter(mandatory=$true)][int]$daysValid, - [Parameter(mandatory=$true)][string]$accessToken, - [Parameter(mandatory=$true)][int]$definitionId, - [Parameter(mandatory=$true)][string]$ownerId, - [Parameter(mandatory=$true)][int]$buildId, - [Parameter(mandatory=$true)][string]$collectionUri, - [Parameter(mandatory=$true)][string]$teamProject -) - -try{ - $contentType = "application/json"; - $headers = @{ Authorization = 'Bearer $accessToken' }; - $rawRequest = @{ daysValid = $daysValid; definitionId = $definitionId; ownerId = $ownerId; protectPipeline = $false; runId = $buildId }; - $request = ConvertTo-Json @($rawRequest); - $uri = "$collectionUri$teamProject/_apis/build/retention/leases?api-version=7.0"; - - Write-Host $request - Write-Host $uri - - Invoke-RestMethod -uri $uri -method POST -Headers $headers -ContentType $contentType -Body $request; - - Write-Host "Pipeline will be retained for $daysValid days" -} -catch{ - Write-Host $_ - Write-Host "##vso[task.complete result=SucceededWithIssues;]" -} diff --git a/vNextIATDeployment/check_health_endpoint.ps1 b/vNextIATDeployment/check_health_endpoint.ps1 deleted file mode 100644 index d2476eac..00000000 --- a/vNextIATDeployment/check_health_endpoint.ps1 +++ /dev/null @@ -1,52 +0,0 @@ -Param( - [Parameter(mandatory=$true)][string]$healthEndPointUrl, - [Parameter(mandatory=$true)][string]$waitTimeInMinute -) - -$sleepTimeInSecond = 15 -$isServiceActive = 'false' - -$stopWatch = New-Object -TypeName System.Diagnostics.Stopwatch -$timeSpan = New-TimeSpan -Minutes $waitTimeInMinute -$stopWatch.Start() - -do -{ - Write-Host "Polling url: $healthEndPointUrl ..." - try{ - $HttpRequest = [System.Net.WebRequest]::Create("$healthEndPointUrl") - $HttpResponse = $HttpRequest.GetResponse() - $HttpStatus = $HttpResponse.StatusCode - Write-Host "Status code of web is $HttpStatus ..." - - If ($HttpStatus -eq 200 ) { - Write-Host "Service is up. Stopping Polling ..." - $isServiceActive = 'true' - break - } - Else { - Write-Host "Service not yet Up. Status code: $HttpStatus re-checking after $sleepTimeInSecond sec ..." - } - } - catch [System.Net.WebException] - { - $HttpStatus = $_.Exception.Response.StatusCode - Write-Host "Service not yet Up.Status: $HttpStatus re-checking after $sleepTimeInSecond sec ..." - } - - Start-Sleep -Seconds $sleepTimeInSecond -} -until ($stopWatch.Elapsed -ge $timeSpan) - - -If ($HttpResponse -ne $null) { - $HttpResponse.Close() -} - -if ($isServiceActive -eq 'true' ) { - Write-Host "Service is up returning from script ..." -} -Else { - Write-Error "Service was not up in $waitTimeInMinute, error while deployment ..." - throw "Error" -} diff --git a/vNextIATDeployment/check_health_endpoint_fm_live.ps1 b/vNextIATDeployment/check_health_endpoint_fm_live.ps1 deleted file mode 100644 index 55912c2c..00000000 --- a/vNextIATDeployment/check_health_endpoint_fm_live.ps1 +++ /dev/null @@ -1,54 +0,0 @@ -Param( - [Parameter(mandatory=$true)][string]$healthEndPointUrl, - [Parameter(mandatory=$true)][string]$waitTimeInMinute, - [Parameter(mandatory=$true)][string]$ocpapimsubscriptionkey -) - -$sleepTimeInSecond = 15 -$isServiceActive = 'false' - -$stopWatch = New-Object -TypeName System.Diagnostics.Stopwatch -$timeSpan = New-TimeSpan -Minutes $waitTimeInMinute -$stopWatch.Start() - -do -{ - Write-Host "Polling url: $healthEndPointUrl ..." - try{ - $HttpRequest = [System.Net.WebRequest]::Create("$healthEndPointUrl") - $HttpRequest.Headers.Add('Ocp-Apim-Subscription-Key', "$ocpapimsubscriptionkey") - $HttpResponse = $HttpRequest.GetResponse() - $HttpStatus = $HttpResponse.StatusCode - Write-Host "Status code of web is $HttpStatus ..." - - If ($HttpStatus -eq 200 ) { - Write-Host "Service is up. Stopping Polling ..." - $isServiceActive = 'true' - break - } - Else { - Write-Host "Service not yet Up. Status code: $HttpStatus re-checking after $sleepTimeInSecond sec ..." - } - } - catch [System.Net.WebException] - { - $HttpStatus = $_.Exception.Response.StatusCode - Write-Host "Service not yet Up.Status: $HttpStatus re-checking after $sleepTimeInSecond sec ..." - } - - Start-Sleep -Seconds $sleepTimeInSecond -} -until ($stopWatch.Elapsed -ge $timeSpan) - - -If ($HttpResponse -ne $null) { - $HttpResponse.Close() -} - -if ($isServiceActive -eq 'true' ) { - Write-Host "Service is up returning from script ..." -} -Else { - Write-Error "Service was not up in $waitTimeInMinute, error while deployment ..." - throw "Error" -} diff --git a/vNextIATDeployment/check_service_status_webjob.ps1 b/vNextIATDeployment/check_service_status_webjob.ps1 deleted file mode 100644 index 530fa994..00000000 --- a/vNextIATDeployment/check_service_status_webjob.ps1 +++ /dev/null @@ -1,49 +0,0 @@ -Param( - [Parameter(mandatory=$true)][string]$RGName, - [Parameter(mandatory=$true)][string]$webAppName, - [Parameter(mandatory=$true)][string]$waitTimeInMinute -) - -$sleepTimeInSecond = 10 -$recheckTimeInSecond = 35 -$isServiceActive = 'false' - -$stopWatch = New-Object -TypeName System.Diagnostics.Stopwatch -$fullTimeSpan = New-TimeSpan -Minutes $waitTimeInMinute -$recheckTimeSpan = New-TimeSpan -Seconds $recheckTimeInSecond -$stopWatch.Start() - -do -{ - Write-Host "Polling AZ ..." - $StateRequest = az webapp show --name $webAppName --resource-group $RGName --query "state" - Write-Host "State of webjob is $StateRequest ..." - - If ($StateRequest -eq '"Running"') { - Write-Host "Webjob service is running..." - $isServiceActive = 'true' - If($stopWatch.Elapsed -ge $recheckTimeSpan) { - Write-Host "Stopping polling ..." - break - } - - } - ElseIf ($StateRequest -eq '"PendingRestart"'){ - Write-Host "Webjob has encountered an error. Webjob state: $StateRequest..." - throw "Error" - } - Else { - Write-Host "Webjob is not yet running. Webjob state: $StateRequest re-checking after $sleepTimeInSecond sec ..." - } - - Start-Sleep -Seconds $sleepTimeInSecond -} -until ($stopWatch.Elapsed -ge $fullTimeSpan) - -if ($isServiceActive -eq 'true' ) { - Write-Host "Webjob is running, returning from script ..." -} -Else { - Write-Error "Error: Webjob was not running within $waitTimeInMinute minutes..." - throw "Error" -} diff --git a/vNextIATDeployment/mock_api_deployment.ps1 b/vNextIATDeployment/mock_api_deployment.ps1 deleted file mode 100644 index b5c3f402..00000000 --- a/vNextIATDeployment/mock_api_deployment.ps1 +++ /dev/null @@ -1,26 +0,0 @@ -param ( - [Parameter(Mandatory = $true)] [string] $mockWebAppName, - [Parameter(Mandatory = $true)] [string] $mockApipackagePath, - [Parameter(Mandatory = $true)] [string] $mockWebAppResourceGroup -) - -echo "mockApipackagePath : $mockApipackagePath" -echo "mockWebAppName : $mockWebAppName" -echo "ResourceGroup : $mockWebAppResourceGroup" - -function DeployWebApp($webAppName, $package, $webAppRGroup){ - - echo "Function DeployWebApp called with params $webAppName, $package, $webAppRGroup ..." - - az webapp deployment source config-zip -g $webAppRGroup -n $webAppName --src $package - - if ( !$? ) { echo "Error while deploying webapp" $webAppName ; throw $_ } -} - -echo "Deploying mock api ..." -DeployWebApp $mockWebAppName $mockApipackagePath $mockWebAppResourceGroup - -if ( !$? ) { echo "Error while deploying mock api webapp" ; throw $_ } - -echo "Deploying mock api done ..." - diff --git a/vNextIATDeployment/set_stub_configuration.ps1 b/vNextIATDeployment/set_stub_configuration.ps1 deleted file mode 100644 index bb5fe92e..00000000 --- a/vNextIATDeployment/set_stub_configuration.ps1 +++ /dev/null @@ -1,12 +0,0 @@ -param ( - [Parameter(Mandatory = $true)] [string] $mockresourcegroup, - [Parameter(Mandatory = $true)] [string] $mockwebappname, - [Parameter(Mandatory = $true)] [string] $fleetmanagerfilepath, - [Parameter(Mandatory = $true)] [string] $ftrunning -) - -Write-Output "Set Stub Configuration in appsetting..." -az webapp config appsettings set -g $mockresourcegroup -n $mockwebappname --settings FleetManagerB2BApiConfiguration:GetCatalogueResponseFilePath=$fleetmanagerfilepath IsFTRunning=$ftrunning -az webapp restart --name $mockwebappname --resource-group $mockresourcegroup - - diff --git a/vNextIATDeployment/set_webjob_configuration.ps1 b/vNextIATDeployment/set_webjob_configuration.ps1 deleted file mode 100644 index d4a4fa73..00000000 --- a/vNextIATDeployment/set_webjob_configuration.ps1 +++ /dev/null @@ -1,14 +0,0 @@ -param ( - [Parameter(Mandatory = $true)] [string] $essapibaseurl, - [Parameter(Mandatory = $true)] [string] $resourcegroup, - [Parameter(Mandatory = $true)] [string] $webappname, - [Parameter(Mandatory = $true)] [string] $fssapibaseurl, - [Parameter(Mandatory = $true)] [string] $fleetmanagerbaseurl, - [Parameter(Mandatory = $true)] [string] $ftrunning, - [Parameter(Mandatory = $true)] [string] $fssapipollingcutoffime, - [Parameter(Mandatory = $true)] [string] $fssapipollingdelaytime -) - -Write-Output "Set Webjob Configuration in appsetting..." -az webapp config appsettings set -g $resourcegroup -n $webappname --settings ESSApiConfiguration:BaseUrl=$essapibaseurl FSSApiConfiguration:BaseUrl=$fssapibaseurl FleetManagerB2BApiConfiguration:BaseUrl=$fleetmanagerbaseurl IsFTRunning=$ftrunning FSSApiConfiguration:BatchStatusPollingCutoffTime=$fssapipollingcutoffime FSSApiConfiguration:BatchStatusPollingDelayTime=$fssapipollingdelaytime -az webapp restart --name $webappname --resource-group $resourcegroup diff --git a/vNextIATDeployment/src/Modules/AppInsights/main.tf b/vNextIATDeployment/src/Modules/AppInsights/main.tf deleted file mode 100644 index 9f73e3b9..00000000 --- a/vNextIATDeployment/src/Modules/AppInsights/main.tf +++ /dev/null @@ -1,17 +0,0 @@ -resource "azurerm_log_analytics_workspace" "logs_analytics_workspace" { - name = "${var.name}-workspace" - location = var.location - resource_group_name = var.resource_group_name - sku = "PerGB2018" - retention_in_days = 30 - tags = var.tags -} - -resource "azurerm_application_insights" "app_insights" { - name = var.name - location = var.location - resource_group_name = var.resource_group_name - application_type = "web" - workspace_id = azurerm_log_analytics_workspace.logs_analytics_workspace.id - tags = var.tags -} diff --git a/vNextIATDeployment/src/Modules/AppInsights/outputs.tf b/vNextIATDeployment/src/Modules/AppInsights/outputs.tf deleted file mode 100644 index ebebdb1b..00000000 --- a/vNextIATDeployment/src/Modules/AppInsights/outputs.tf +++ /dev/null @@ -1,8 +0,0 @@ -output "instrumentation_key" { - value = azurerm_application_insights.app_insights.instrumentation_key -} - -output "connection_string" { - value = azurerm_application_insights.app_insights.connection_string - sensitive = true -} diff --git a/vNextIATDeployment/src/Modules/AppInsights/variables.tf b/vNextIATDeployment/src/Modules/AppInsights/variables.tf deleted file mode 100644 index 9c44bd70..00000000 --- a/vNextIATDeployment/src/Modules/AppInsights/variables.tf +++ /dev/null @@ -1,15 +0,0 @@ -variable "name" { - type = string -} - -variable "resource_group_name" { - type = string -} - -variable "location" { - type = string -} - -variable "tags" { - -} diff --git a/vNextIATDeployment/src/Modules/EventHub/main.tf b/vNextIATDeployment/src/Modules/EventHub/main.tf deleted file mode 100644 index 48f6c93b..00000000 --- a/vNextIATDeployment/src/Modules/EventHub/main.tf +++ /dev/null @@ -1,50 +0,0 @@ -resource "azurerm_eventhub_namespace" "eventhub_namespace" { - name = "${var.name}-namespace" - location = var.location - resource_group_name = var.resource_group_name - sku = "Standard" - capacity = 1 - tags = var.tags -} - -resource "azurerm_eventhub" "eventhub" { - name = var.name - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - resource_group_name = var.resource_group_name - partition_count = 2 - message_retention = 7 -} - -resource "azurerm_eventhub_consumer_group" "logging_application_consumer_group" { - name = "loggingApplication" - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - eventhub_name = azurerm_eventhub.eventhub.name - resource_group_name = var.resource_group_name -} - -resource "azurerm_eventhub_consumer_group" "logstash_consumer_group" { - name = "logstash" - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - eventhub_name = azurerm_eventhub.eventhub.name - resource_group_name = var.resource_group_name -} - -resource "azurerm_eventhub_authorization_rule" "log" { - name = "logAccessKey" - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - eventhub_name = azurerm_eventhub.eventhub.name - resource_group_name = var.resource_group_name - listen = false - send = true - manage = false -} - -resource "azurerm_eventhub_authorization_rule" "logstash" { - name = "logstashAccessKey" - namespace_name = azurerm_eventhub_namespace.eventhub_namespace.name - eventhub_name = azurerm_eventhub.eventhub.name - resource_group_name = var.resource_group_name - listen = true - send = false - manage = false -} diff --git a/vNextIATDeployment/src/Modules/EventHub/outputs.tf b/vNextIATDeployment/src/Modules/EventHub/outputs.tf deleted file mode 100644 index 0a570f8a..00000000 --- a/vNextIATDeployment/src/Modules/EventHub/outputs.tf +++ /dev/null @@ -1,9 +0,0 @@ -output "log_primary_connection_string" { - value = azurerm_eventhub_authorization_rule.log.primary_connection_string - sensitive = true -} - -output "entity_path" { - value = azurerm_eventhub.eventhub.name - sensitive = true -} diff --git a/vNextIATDeployment/src/Modules/EventHub/variables.tf b/vNextIATDeployment/src/Modules/EventHub/variables.tf deleted file mode 100644 index b222f79b..00000000 --- a/vNextIATDeployment/src/Modules/EventHub/variables.tf +++ /dev/null @@ -1,19 +0,0 @@ -variable "name" { - type = string -} - -variable "resource_group_name" { - type = string -} - -variable "location" { - type = string -} - -variable "tags" { - -} - -variable "env_name" { - type = string -} diff --git a/vNextIATDeployment/src/Modules/KeyVault/main.tf b/vNextIATDeployment/src/Modules/KeyVault/main.tf deleted file mode 100644 index 6dc84ec2..00000000 --- a/vNextIATDeployment/src/Modules/KeyVault/main.tf +++ /dev/null @@ -1,69 +0,0 @@ -data "azurerm_client_config" "current" {} - -resource "azurerm_key_vault" "kv" { - name = var.name - location = var.location - resource_group_name = var.resource_group_name - enabled_for_disk_encryption = true - tenant_id = var.tenant_id - - sku_name = "standard" - - network_acls { - default_action = "Deny" - bypass = "AzureServices" - ip_rules = var.allowed_ips - virtual_network_subnet_ids = var.allowed_subnet_ids - } - - tags = var.tags - -} - -#access policy for terraform script service account -resource "azurerm_key_vault_access_policy" "kv_access_terraform" { - key_vault_id = azurerm_key_vault.kv.id - tenant_id = data.azurerm_client_config.current.tenant_id - object_id = data.azurerm_client_config.current.object_id - - key_permissions = [ - "Create", - "Get", - ] - - secret_permissions = [ - "Set", - "Get", - "Delete", - "Recover", - "Purge" - ] -} - -#access policy for read access (app service) -resource "azurerm_key_vault_access_policy" "kv_read_access" { - for_each = var.read_access_objects - key_vault_id = azurerm_key_vault.kv.id - tenant_id = var.tenant_id - object_id = each.value - - key_permissions = [ - "List", - "Get", - ] - - secret_permissions = [ - "List", - "Get" - ] -} - -resource "azurerm_key_vault_secret" "passed_in_secrets" { - count = length(var.secrets) - name = keys(var.secrets)[count.index] - value = values(var.secrets)[count.index] - key_vault_id = azurerm_key_vault.kv.id - tags = var.tags - - depends_on = [azurerm_key_vault_access_policy.kv_access_terraform] -} diff --git a/vNextIATDeployment/src/Modules/KeyVault/outputs.tf b/vNextIATDeployment/src/Modules/KeyVault/outputs.tf deleted file mode 100644 index 0772ec06..00000000 --- a/vNextIATDeployment/src/Modules/KeyVault/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output keyvault_uri { - value = azurerm_key_vault.kv.vault_uri -} diff --git a/vNextIATDeployment/src/Modules/KeyVault/variables.tf b/vNextIATDeployment/src/Modules/KeyVault/variables.tf deleted file mode 100644 index 93bbffb3..00000000 --- a/vNextIATDeployment/src/Modules/KeyVault/variables.tf +++ /dev/null @@ -1,46 +0,0 @@ -variable "name" { - type = string -} - -variable "resource_group_name" { - type = string -} - -variable "location" { - type = string -} - -variable "tenant_id" { - type = string -} - -variable "env_name" { - type = string -} - -variable "read_access_objects" { - type = map(string) -} - -variable "secrets" { - type = map(string) -} - -variable "tags" { -} - -variable "allowed_subnet_ids" { - type = list -} - -variable "allowed_ips" { -} - - -variable "agent_2204_subnet" { - type = string -} - -variable "agent_prd_subnet" { - type = string -} diff --git a/vNextIATDeployment/src/Modules/MockWebApp/main.tf b/vNextIATDeployment/src/Modules/MockWebApp/main.tf deleted file mode 100644 index b712caeb..00000000 --- a/vNextIATDeployment/src/Modules/MockWebApp/main.tf +++ /dev/null @@ -1,48 +0,0 @@ -resource "azurerm_windows_web_app" "mock_webapp_service" { - name = var.name - location = var.location - resource_group_name = var.resource_group_name - service_plan_id = var.service_plan_id - tags = var.tags - - site_config { - application_stack { - current_stack = "dotnet" - dotnet_version = "v6.0" - } - always_on = true - ftps_state = "Disabled" - - ip_restriction { - virtual_network_subnet_id = var.subnet_id - } - - ip_restriction { - virtual_network_subnet_id = var.main_subnet_id - } - - dynamic "ip_restriction" { - for_each = var.allowed_ips - content { - ip_address = length(split("/",ip_restriction.value)) > 1 ? ip_restriction.value : "${ip_restriction.value}/32" - } - } - } - - app_settings = var.app_settings - - identity { - type = "SystemAssigned" - } - - lifecycle { - ignore_changes = [ virtual_network_subnet_id ] - } - - https_only = true -} - -resource "azurerm_app_service_virtual_network_swift_connection" "mock_webapp_vnet_integration" { - app_service_id = azurerm_windows_web_app.mock_webapp_service.id - subnet_id = var.subnet_id -} diff --git a/vNextIATDeployment/src/Modules/MockWebApp/outputs.tf b/vNextIATDeployment/src/Modules/MockWebApp/outputs.tf deleted file mode 100644 index cbe5fc0f..00000000 --- a/vNextIATDeployment/src/Modules/MockWebApp/outputs.tf +++ /dev/null @@ -1,11 +0,0 @@ -output "web_app_object_id" { - value = azurerm_windows_web_app.mock_webapp_service.identity.0.principal_id -} - -output "web_app_tenant_id" { - value = azurerm_windows_web_app.mock_webapp_service.identity.0.tenant_id -} - -output "default_site_hostname" { - value = azurerm_windows_web_app.mock_webapp_service.default_hostname -} diff --git a/vNextIATDeployment/src/Modules/MockWebApp/variables.tf b/vNextIATDeployment/src/Modules/MockWebApp/variables.tf deleted file mode 100644 index 1322466d..00000000 --- a/vNextIATDeployment/src/Modules/MockWebApp/variables.tf +++ /dev/null @@ -1,39 +0,0 @@ -variable "name" { - type = string -} - -variable "resource_group_name" { - type = string -} - -variable "service_plan_id" { - type = string -} - -variable "location" { - type = string -} - -variable "app_settings" { - type = map(string) -} - -variable "tags" { - -} - -variable "env_name" { - type = string -} - -variable "subnet_id" { - type = string -} - -variable "main_subnet_id" { - type = string -} - -variable "allowed_ips" { - -} diff --git a/vNextIATDeployment/src/Modules/Storage/main.tf b/vNextIATDeployment/src/Modules/Storage/main.tf deleted file mode 100644 index ee9779a2..00000000 --- a/vNextIATDeployment/src/Modules/Storage/main.tf +++ /dev/null @@ -1,60 +0,0 @@ -resource "azurerm_storage_account" "pos_storage" { - name = lower("${var.service_name}${var.env_name}storageukho") - resource_group_name = var.resource_group_name - location = var.location - account_tier = "Standard" - account_replication_type = "LRS" - account_kind = "StorageV2" - - tags = var.tags - network_rules { - default_action = "Deny" - ip_rules = var.allowed_ips - bypass = ["Logging", "Metrics", "AzureServices"] - virtual_network_subnet_ids = [var.m_spoke_subnet, var.agent_2204_subnet, var.agent_prd_subnet] -} -} - -resource "azurerm_storage_account" "bess_storage" { - name = lower("${var.service_name_bess}${var.env_name}storageukho") - resource_group_name = var.resource_group_name - location = var.location - account_tier = "Standard" - account_replication_type = "LRS" - account_kind = "StorageV2" - - tags = var.tags - network_rules { - default_action = "Deny" - ip_rules = var.allowed_ips - bypass = ["Logging", "Metrics", "AzureServices"] - virtual_network_subnet_ids = [var.m_spoke_subnet,var.mock_spoke_subnet,var.agent_2204_subnet, var.agent_prd_subnet] -} -} - -resource "azurerm_storage_container" "bess_config_container" { - name = var.container_name - storage_account_name = azurerm_storage_account.bess_storage.name -} - -resource "azurerm_storage_account" "bess_storage" { - name = lower("${var.service_name_bess}${var.env_name}storageukho") - resource_group_name = var.resource_group_name - location = var.location - account_tier = "Standard" - account_replication_type = "LRS" - account_kind = "StorageV2" - - tags = var.tags - network_rules { - default_action = "Deny" - ip_rules = var.allowed_ips - bypass = ["Logging", "Metrics", "AzureServices"] - virtual_network_subnet_ids = [var.m_spoke_subnet,var.agent_subnet] -} -} - -resource "azurerm_storage_container" "bess_config_container" { - name = var.container_name - storage_account_name = azurerm_storage_account.bess_storage.name -} diff --git a/vNextIATDeployment/src/Modules/Storage/outputs.tf b/vNextIATDeployment/src/Modules/Storage/outputs.tf deleted file mode 100644 index e2895b8c..00000000 --- a/vNextIATDeployment/src/Modules/Storage/outputs.tf +++ /dev/null @@ -1,13 +0,0 @@ -output pos_storage_name { - value = azurerm_storage_account.pos_storage.name -} - -output pos_storage_connection_string { - value = azurerm_storage_account.pos_storage.primary_connection_string - sensitive = true -} - -output bess_storage_connection_string { - value = azurerm_storage_account.bess_storage.primary_connection_string - sensitive = true -} diff --git a/vNextIATDeployment/src/Modules/Storage/variables.tf b/vNextIATDeployment/src/Modules/Storage/variables.tf deleted file mode 100644 index 93d12193..00000000 --- a/vNextIATDeployment/src/Modules/Storage/variables.tf +++ /dev/null @@ -1,46 +0,0 @@ - -variable "resource_group_name" { - type = string -} - -variable "location" { - type = string -} - -variable "env_name" { - type = string -} - -variable "tags" { -} - -variable "service_name" { - type = string -} - -variable "service_name_bess" { - type = string -} - -variable "container_name" { - type = string -} - -variable "m_spoke_subnet" { - type = string -} - -variable "mock_spoke_subnet" { - type = string -} - -variable "allowed_ips" { -} - -variable "agent_2204_subnet" { - type = string -} - -variable "agent_prd_subnet" { - type = string -} diff --git a/vNextIATDeployment/src/Modules/WebApp/main.tf b/vNextIATDeployment/src/Modules/WebApp/main.tf deleted file mode 100644 index 8fa44a3f..00000000 --- a/vNextIATDeployment/src/Modules/WebApp/main.tf +++ /dev/null @@ -1,44 +0,0 @@ -resource "azurerm_windows_web_app" "webapp_service" { - name = var.name - location = var.location - resource_group_name = var.resource_group_name - service_plan_id = var.service_plan_id - tags = var.tags - - site_config { - application_stack { - current_stack = "dotnet" - dotnet_version = "v6.0" - } - always_on = true - ftps_state = "Disabled" - - ip_restriction { - virtual_network_subnet_id = var.subnet_id - } - - dynamic "ip_restriction" { - for_each = var.allowed_ips - content { - ip_address = length(split("/",ip_restriction.value)) > 1 ? ip_restriction.value : "${ip_restriction.value}/32" - } - } - } - - app_settings = var.app_settings - - identity { - type = "SystemAssigned" - } - - lifecycle { - ignore_changes = [ virtual_network_subnet_id ] - } - - https_only = true -} - -resource "azurerm_app_service_virtual_network_swift_connection" "webapp_vnet_integration" { - app_service_id = azurerm_windows_web_app.webapp_service.id - subnet_id = var.subnet_id -} diff --git a/vNextIATDeployment/src/Modules/WebApp/outputs.tf b/vNextIATDeployment/src/Modules/WebApp/outputs.tf deleted file mode 100644 index a6b555d0..00000000 --- a/vNextIATDeployment/src/Modules/WebApp/outputs.tf +++ /dev/null @@ -1,20 +0,0 @@ -output "web_app_object_id" { - value = azurerm_windows_web_app.webapp_service.identity.0.principal_id -} - -output "web_app_tenant_id" { - value = azurerm_windows_web_app.webapp_service.identity.0.tenant_id -} - -output "default_site_hostname" { - value = azurerm_windows_web_app.webapp_service.default_hostname -} - -output "username" { - value = azurerm_windows_web_app.webapp_service.site_credential[0].name -} - -output "password" { - value = azurerm_windows_web_app.webapp_service.site_credential[0].password - sensitive = true -} diff --git a/vNextIATDeployment/src/Modules/WebApp/variables.tf b/vNextIATDeployment/src/Modules/WebApp/variables.tf deleted file mode 100644 index 0fc55fae..00000000 --- a/vNextIATDeployment/src/Modules/WebApp/variables.tf +++ /dev/null @@ -1,35 +0,0 @@ -variable "name" { - type = string -} - -variable "resource_group_name" { - type = string -} - -variable "service_plan_id" { - type = string -} - -variable "location" { - type = string -} - -variable "app_settings" { - type = map(string) -} - -variable "tags" { - -} - -variable "env_name" { - type = string -} - -variable "subnet_id" { - type = string -} - -variable "allowed_ips" { - -} diff --git a/vNextIATDeployment/src/azure.tf b/vNextIATDeployment/src/azure.tf deleted file mode 100644 index d4c8c2fc..00000000 --- a/vNextIATDeployment/src/azure.tf +++ /dev/null @@ -1,24 +0,0 @@ -terraform { - required_providers { - azurerm = { - source = "hashicorp/azurerm" - version = "=3.116.0" - } - } - - required_version = "=1.9.6" - backend "azurerm" { - container_name = "tfstate" - key = "posterraform.deployment.tfplan" - } -} - -provider "azurerm" { - features {} -} - -provider "azurerm" { - features {} - alias = "build_agent" - subscription_id = var.agent_subscription_id -} diff --git a/vNextIATDeployment/src/main.tf b/vNextIATDeployment/src/main.tf deleted file mode 100644 index c8d4a873..00000000 --- a/vNextIATDeployment/src/main.tf +++ /dev/null @@ -1,131 +0,0 @@ -data "azurerm_subnet" "main_subnet" { - name = var.spoke_subnet_name - virtual_network_name = var.spoke_vnet_name - resource_group_name = var.spoke_rg -} - -data "azurerm_subnet" "mock_main_subnet" { - name = var.mock_spoke_subnet_name - virtual_network_name = var.spoke_vnet_name - resource_group_name = var.spoke_rg -} - -module "app_insights" { - source = "./Modules/AppInsights" - name = "${local.service_name}-${local.env_name}-insights" - resource_group_name = azurerm_resource_group.webapp_rg.name - location = azurerm_resource_group.webapp_rg.location - tags = local.tags -} - -module "eventhub" { - source = "./Modules/EventHub" - name = "${local.service_name}-${local.env_name}-events" - resource_group_name = azurerm_resource_group.webapp_rg.name - location = azurerm_resource_group.webapp_rg.location - tags = local.tags - env_name = local.env_name -} - -data "azurerm_app_service_plan" "essft_asp" { - name = "ess-vni-sxs-2-asp" - resource_group_name = "ess-vni-rg" -} - -data "azurerm_app_service_plan" "ess_asp" { - name = "ess-${local.env_name}-lxs-1-asp" - resource_group_name = "ess-${local.env_name}-rg" -} - -module "mock_webapp_service" { - source = "./Modules/MockWebApp" - name = local.mock_web_app_name - env_name = local.env_name - resource_group_name = azurerm_resource_group.mock_webapp_rg.name - service_plan_id = data.azurerm_app_service_plan.essft_asp.id - location = azurerm_resource_group.mock_webapp_rg.location - subnet_id = data.azurerm_subnet.mock_main_subnet.id - main_subnet_id = data.azurerm_subnet.main_subnet.id - app_settings = { - "ASPNETCORE_ENVIRONMENT" = local.env_name - "WEBSITE_RUN_FROM_PACKAGE" = "1" - "WEBSITE_ENABLE_SYNC_UPDATE_SITE" = "true" - "APPINSIGHTS_INSTRUMENTATIONKEY" = "NOT_CONFIGURED" - } - tags = local.tags - allowed_ips = var.allowed_ips -} - -module "webapp_service" { - source = "./Modules/WebApp" - name = local.web_app_name - resource_group_name = azurerm_resource_group.webapp_rg.name - service_plan_id = data.azurerm_app_service_plan.ess_asp.id - env_name = local.env_name - location = azurerm_resource_group.webapp_rg.location - subnet_id = data.azurerm_subnet.main_subnet.id - app_settings = { - "EventHubLoggingConfiguration:Environment" = local.env_name - "EventHubLoggingConfiguration:MinimumLoggingLevel" = "Warning" - "EventHubLoggingConfiguration:UkhoMinimumLoggingLevel" = "Information" - "APPINSIGHTS_INSTRUMENTATIONKEY" = module.app_insights.instrumentation_key - "ASPNETCORE_ENVIRONMENT" = local.env_name - "WEBSITE_RUN_FROM_PACKAGE" = "1" - "WEBSITE_ENABLE_SYNC_UPDATE_SITE" = "true" - "FSSApiConfiguration:BusinessUnit" = "AVCSData" - "FSSApiConfiguration:PosReadGroups" = "public" - "FSSApiConfiguration:PosReadUsers" = "" - "FSSApiConfiguration:AIOBusinessUnit" = "AVCSData" - "FSSApiConfiguration:AIOReadGroups" = "public" - "FSSApiConfiguration:AIOReadUsers" = "" - "ELASTIC_APM_SERVER_URL" = var.elastic_apm_server_url - "ELASTIC_APM_TRANSACTION_SAMPLE_RATE" = "1" - "ELASTIC_APM_ENVIRONMENT" = local.env_name - "ELASTIC_APM_SERVICE_NAME" = "POS Web Job" - "ELASTIC_APM_API_KEY" = var.elastic_apm_api_key - "BessStorageConfiguration:ContainerName" = var.BessContainerName - } - tags = local.tags - allowed_ips = var.allowed_ips -} - -module "storage" { - source = "./Modules/Storage" - resource_group_name = azurerm_resource_group.webapp_rg.name - location = azurerm_resource_group.webapp_rg.location - allowed_ips = var.allowed_ips - m_spoke_subnet = data.azurerm_subnet.main_subnet.id - mock_spoke_subnet = data.azurerm_subnet.mock_main_subnet.id - agent_2204_subnet = var.agent_2204_subnet - agent_prd_subnet = var.agent_prd_subnet - env_name = local.env_name - service_name = local.service_name - service_name_bess = local.service_name_bess - container_name = local.container_name - tags = local.tags -} - -module "key_vault" { - source = "./Modules/KeyVault" - name = local.key_vault_name - resource_group_name = azurerm_resource_group.webapp_rg.name - env_name = local.env_name - tenant_id = module.webapp_service.web_app_tenant_id - allowed_ips = var.allowed_ips - allowed_subnet_ids = [data.azurerm_subnet.main_subnet.id, var.agent_2204_subnet,var.agent_prd_subnet] - location = azurerm_resource_group.webapp_rg.location - agent_2204_subnet = var.agent_2204_subnet - agent_prd_subnet = var.agent_prd_subnet - read_access_objects = { - "webapp_service" = module.webapp_service.web_app_object_id - } - secrets = { - "EventHubLoggingConfiguration--ConnectionString" = module.eventhub.log_primary_connection_string - "EventHubLoggingConfiguration--EntityPath" = module.eventhub.entity_path - "ApplicationInsights--ConnectionString" = module.app_insights.connection_string - "BessStorageConfiguration--ConnectionString" = module.storage.bess_storage_connection_string - "AzureWebJobsStorage" = module.storage.bess_storage_connection_string - "PKSApiConfiguration--PermitDecryptionHardwareId" = var.permitdecryptionhardwareid - } - tags = local.tags -} diff --git a/vNextIATDeployment/src/outputs.tf b/vNextIATDeployment/src/outputs.tf deleted file mode 100644 index f168c366..00000000 --- a/vNextIATDeployment/src/outputs.tf +++ /dev/null @@ -1,70 +0,0 @@ -output "web_app_name" { - value = local.web_app_name -} - -output "env_name" { - value = local.env_name -} - -output "webapp_rg" { - value = azurerm_resource_group.webapp_rg.name -} - -output "Website_Url" { - value = "https://${module.webapp_service.default_site_hostname}/" -} - -output "kv_name" { - value = local.key_vault_name -} - -output "pos_storage_name" { -value = module.storage.pos_storage_name -} - -output "pos_storage_connection_string"{ - value = module.storage.pos_storage_connection_string - sensitive = true -} - -output "bess_storage_connection_string"{ - value = module.storage.bess_storage_connection_string - sensitive = true -} - -output "log_primary_connection_string" { - value = module.eventhub.log_primary_connection_string - sensitive = true -} - -output "entity_path" { - value = module.eventhub.entity_path - sensitive = true -} - -output "webjob_username" { - value = module.webapp_service.username - sensitive = true -} - -output "webjob_password" { - value = module.webapp_service.password - sensitive = true -} - -output "connection_string" { - value = module.app_insights.connection_string - sensitive = true -} - -output "mock_webappname" { - value = local.mock_web_app_name -} - -output "mock_webapp_rg" { -value = azurerm_resource_group.mock_webapp_rg.name -} - -output "keyvault_uri"{ - value = module.key_vault.keyvault_uri -} diff --git a/vNextIATDeployment/src/resource-group.tf b/vNextIATDeployment/src/resource-group.tf deleted file mode 100644 index d74ddd4e..00000000 --- a/vNextIATDeployment/src/resource-group.tf +++ /dev/null @@ -1,11 +0,0 @@ -resource "azurerm_resource_group" "webapp_rg" { - name = "${local.service_name}-${local.env_name}-rg" - location = var.location - tags = local.tags -} - -resource "azurerm_resource_group" "mock_webapp_rg" { - name = "${local.service_name}-${local.env_name}-mock-rg" - location = var.location - tags = local.tags -} diff --git a/vNextIATDeployment/templates/continuous-deployment.yml b/vNextIATDeployment/templates/continuous-deployment.yml deleted file mode 100644 index c7bc8e7d..00000000 --- a/vNextIATDeployment/templates/continuous-deployment.yml +++ /dev/null @@ -1,61 +0,0 @@ -parameters: - - name: ContinueEvenIfResourcesAreGettingDestroyed - type: boolean - default: false - - name: AzureSubscription - type: string - -steps: - - task: PowerShell@2 - displayName: "Terraform $(Environment)deploy" - name: TerraformDeploy - inputs: - targetType: filePath - filePath: '$(Pipeline.Workspace)/vnextiatterraformartifact/terraform_conditional_run.ps1' - arguments: '-deploymentResourceGroupName $(DeploymentResourceGroupName) -deploymentStorageAccountName $(DeploymentStorageAccountName) -workSpace $(Environment) -continueEvenIfResourcesAreGettingDestroyed $${{ parameters.ContinueEvenIfResourcesAreGettingDestroyed }} -terraformJsonOutputFile $(Pipeline.Workspace)/qaliveterraformartifact/terraform_output.json -elasticApmServerUrl $(ElasticAPM_ServerURL) -elasticApmApiKey $(ElasticAPM_ApiKey)' - env: - ARM_CLIENT_ID: $(TERRAFORM-CLIENT-ID) - ARM_CLIENT_SECRET: $(TERRAFORM-CLIENT-SECRET) - ARM_TENANT_ID: $(TERRAFORM-TENANT-ID) - ARM_SUBSCRIPTION_ID: $(TERRAFORM-SUBSCRIPTION-ID) - TF_VAR_spoke_rg: $(spokeRG) - TF_VAR_spoke_vnet_name: $(spokeVnetName) - TF_VAR_spoke_subnet_name: $(POSESSspokeSubnetName) - TF_VAR_mock_spoke_subnet_name: $(POSESSmockspokeSubnetName) - TF_VAR_allowed_ips: $(whiteListedIps) - TF_VAR_permitdecryptionhardwareid: $(PermitDecryptionHardwareId) - TF_VAR_agent_2204_subnet: $(agent2204SubnetId) - TF_VAR_agent_prd_subnet: $(agentprdSubnetId) - TF_VAR_agent_subscription_id: $(agentSubscriptionId) - TF_VAR_BessContainerName: $(BessContainerForWebjob) - - - task: FileTransform@2 - displayName: "File Transform: Mock API WebApp" - inputs: - folderPath: '$(Pipeline.Workspace)/MockWebAPI/*.zip' - xmlTransformationRules: - jsonTargetFiles: '**/appsettings.json' - - - task: AzureCLI@2 - displayName: "Mock API WebApp deployment" - inputs: - azureSubscription: "${{ parameters.AzureSubscription }}" - scriptType: 'pscore' - scriptLocation: 'scriptPath' - scriptPath: '$(Pipeline.Workspace)/vnextiatterraformartifact/mock_api_deployment.ps1' - arguments: '-mockWebAppName $(mockWebAppName) -mockApipackagePath "$(Pipeline.Workspace)/MockWebAPI/UKHO.FmEssFssMock.API.zip" -mockWebAppResourceGroup $(mockWebAppResourceGroup)' - - - task: FileTransform@2 - displayName: "File Transform: POS Config" - inputs: - folderPath: '$(Pipeline.Workspace)/PeriodicOutputService/*.zip' - xmlTransformationRules: - jsonTargetFiles: '**/appsettings.json' - - - task: AzureWebApp@1 - displayName: "Azure LXS App Deploy: pos-$(Environment)-lxs-webapp" - inputs: - azureSubscription: "${{ parameters.AzureSubscription }}" - appType: webApp - appName: "$(WEB_APP_NAME)" - package: "$(Pipeline.Workspace)/PeriodicOutputService/PeriodicOutputFulfilmentService.zip" diff --git a/vNextIATDeployment/templates/retain-pipeline.yml b/vNextIATDeployment/templates/retain-pipeline.yml deleted file mode 100644 index 2479bb05..00000000 --- a/vNextIATDeployment/templates/retain-pipeline.yml +++ /dev/null @@ -1,14 +0,0 @@ -steps: - - task: PowerShell@2 - condition: and(succeeded(), not(canceled())) - displayName: Retain Live Release - inputs: - targetType: filePath - filePath: "$(Build.SourcesDirectory)/QALiveDeployment/add-lease.ps1" - arguments: "-daysValid 365 - -accessToken '$(System.AccessToken)' - -definitionId $(System.DefinitionId) - -ownerId 'User:$(Build.RequestedForId)' - -buildId $(Build.BuildId) - -collectionUri '$(System.CollectionUri)' - -teamProject '$(System.TeamProject)'" diff --git a/vNextIATDeployment/terraform_conditional_run.ps1 b/vNextIATDeployment/terraform_conditional_run.ps1 deleted file mode 100644 index 06ccc29d..00000000 --- a/vNextIATDeployment/terraform_conditional_run.ps1 +++ /dev/null @@ -1,77 +0,0 @@ -param ( - [Parameter(Mandatory = $true)] [string] $deploymentResourceGroupName, - [Parameter(Mandatory = $true)] [string] $deploymentStorageAccountName, - [Parameter(Mandatory = $true)] [string] $workSpace, - [Parameter(Mandatory = $true)] [boolean] $continueEvenIfResourcesAreGettingDestroyed, - [Parameter(Mandatory = $true)] [string] $terraformJsonOutputFile, - [Parameter(Mandatory = $true)] [string] $elasticApmServerUrl, - [Parameter(Mandatory = $true)] [string] $elasticApmApiKey -) - -cd $env:AGENT_BUILDDIRECTORY/vnextiatterraformartifact/src - -terraform --version - -Write-output "Executing terraform scripts for deployment in $workSpace enviroment" -terraform init -backend-config="resource_group_name=$deploymentResourceGroupName" -backend-config="storage_account_name=$deploymentStorageAccountName" -backend-config="key=posterraform.deployment.tfplan" -if ( !$? ) { echo "Something went wrong during terraform initialization"; throw "Error" } - -Write-output "Selecting workspace" - -$ErrorActionPreference = 'SilentlyContinue' -terraform workspace new $WorkSpace 2>&1 > $null -$ErrorActionPreference = 'Continue' - -terraform workspace select $workSpace -if ( !$? ) { echo "Error while selecting workspace"; throw "Error" } - -Write-output "Validating terraform" -terraform validate -if ( !$? ) { echo "Something went wrong during terraform validation" ; throw "Error" } - -Write-output "Execute Terraform plan" -terraform plan -out "posterraform.deployment.tfplan" -var elastic_apm_server_url=$elasticApmServerUrl -var elastic_apm_api_key=$elasticApmApiKey | tee terraform_output.txt -if ( !$? ) { echo "Something went wrong during terraform plan" ; throw "Error" } - -$totalDestroyLines=(Get-Content -Path terraform_output.txt | Select-String -Pattern "destroy" -CaseSensitive | where {$_ -ne ""}).length -if($totalDestroyLines -ge 2) -{ - write-Host("Terraform is destroying some resources, please verify...................") - if ( !$ContinueEvenIfResourcesAreGettingDestroyed) - { - write-Host("exiting...................") - Write-Output $_ - exit 1 - } - write-host("Continue executing terraform apply - as continueEvenIfResourcesAreGettingDestroyed param is set to true in pipeline") -} - -Write-output "Executing terraform apply" -terraform apply "posterraform.deployment.tfplan" -if ( !$? ) { echo "Something went wrong during terraform apply" ; throw "Error" } - -Write-output "Terraform output as json" -$terraformOutput = terraform output -json | ConvertFrom-Json - -write-output "Set JSON output into pipeline variables" -Write-Host "##vso[task.setvariable variable=Website_Url]$($terraformOutput.Website_Url.value)" -Write-Host "##vso[task.setvariable variable=WEB_APP_NAME]$($terraformOutput.web_app_name.value)" -Write-Host "##vso[task.setvariable variable=mockWebAppName]$($terraformOutput.mock_webappname.value)" -Write-Host "##vso[task.setvariable variable=mock_web_app_url]$($terraformOutput.fm_mock_web_app_url.value)" -Write-Host "##vso[task.setvariable variable=mockWebAppResourceGroup]$($terraformOutput.mock_webapp_rg.value)" -Write-Host "##vso[task.setvariable variable=RGName]$($terraformOutput.webapp_rg.value)" -Write-Host "##vso[task.setvariable variable=WEBAPP;isOutput=true]$($terraformOutput.web_app_name.value)" -Write-Host "##vso[task.setvariable variable=mockWebApp;isOutput=true]$($terraformOutput.mock_webappname.value)" -Write-Host "##vso[task.setvariable variable=mockWebAppResourceGroupName;isOutput=true]$($terraformOutput.mock_webapp_rg.value)" -Write-Host "##vso[task.setvariable variable=ResourceGroup;isOutput=true]$($terraformOutput.webapp_rg.value)" -Write-Host "##vso[task.setvariable variable=webJobUsername;isOutput=true]$($terraformOutput.webjob_username.value)" -Write-Host "##vso[task.setvariable variable=webJobPassword;issecret=true;isOutput=true]$($terraformOutput.webjob_password.value)" -Write-Host "##vso[task.setvariable variable=AzureStorageConfiguration.ConnectionString;issecret=true]$($terraformOutput.pos_storage_connection_string.value)" -Write-Host "##vso[task.setvariable variable=BessStorageConfiguration.ConnectionString;issecret=true]$($terraformOutput.bess_storage_connection_string.value)" -Write-Host "##vso[task.setvariable variable=EventHubLoggingConfiguration.ConnectionString;issecret=true]$($terraformOutput.log_primary_connection_string.value)" -Write-Host "##vso[task.setvariable variable=EventHubLoggingConfiguration.EntityPath;issecret=true]$($terraformOutput.entity_path.value)" -Write-Host "##vso[task.setvariable variable=ApplicationInsights.ConnectionString;issecret=true]$($terraformOutput.connection_string.value)" -Write-Host "##vso[task.setvariable variable=AzureWebJobsStorage;issecret=true]$($terraformOutput.bess_storage_connection_string.value)" -Write-Host "##vso[task.setvariable variable=KeyVaultSettings.ServiceUri]$($terraformOutput.keyvault_uri.value)" - -$terraformOutput | ConvertTo-Json -Depth 5 > $terraformJsonOutputFile