-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update summary function app pipelines (#677)
- [x] New feature - [ ] Bug fix - [ ] High impact **Description of work:** [AB#55574](https://statoil-proview.visualstudio.com/787035c2-8cf2-4d73-a83e-bb0e6d937eec/_workitems/edit/55574) Creates a deployment pipeline for the summary function app. Also updates the existing summary PR function. **Testing:** - [ ] ~~Can be tested~~ - [ ] ~~Automatic tests created / updated~~ - [ ] ~~Local tests are passing~~ Will need to run the infra pipeline to deploy the function app in ci-> **Checklist:** - [x] Considered automated tests - [x] Considered updating specification / documentation - [x] Considered work items - [x] Considered security - [x] ~~Performed developer testing~~ - [x] Checklist finalized / ready for review
- Loading branch information
1 parent
dc420db
commit 601da0d
Showing
6 changed files
with
303 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
name: $(date:yyyyMMdd)$(rev:.r) | ||
|
||
pool: | ||
vmImage: "ubuntu-latest" | ||
|
||
trigger: | ||
branches: | ||
include: | ||
- master | ||
paths: | ||
include: | ||
- src/Fusion.Summary.Functions/* | ||
- src/Fusion.Resources.Functions.Common/* | ||
|
||
pr: none | ||
|
||
variables: | ||
subscriptionServiceNonProd: "FRA Automation Non-Prod" | ||
subscriptionServiceProd: "FRA Automation Prod" | ||
webPackage: "$(Pipeline.Workspace)/drop/Fusion.Summary.Functions.zip" | ||
|
||
stages: | ||
- template: templates/build-summary-function.yml | ||
parameters: | ||
project: "Fusion.Summary.Functions" | ||
|
||
- stage: DeployCI | ||
displayName: CI | ||
dependsOn: BuildFunction | ||
condition: succeeded() | ||
|
||
variables: | ||
environment: "ci" | ||
functionServiceName: func-fap-summary-$(environment) | ||
|
||
jobs: | ||
- deployment: Deploy | ||
|
||
displayName: "Deploy function app" | ||
environment: fusion-ci | ||
|
||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- template: templates/deploy-summary-function-template.yml | ||
parameters: | ||
envName: $(environment) | ||
clientId: "5a842df8-3238-415d-b168-9f16a6a6031b" | ||
azureSubscription: $(subscriptionServiceNonProd) | ||
|
||
- task: AzureFunctionApp@1 | ||
inputs: | ||
azureSubscription: $(subscriptionServiceNonProd) | ||
appType: "functionApp" | ||
appName: $(functionServiceName) | ||
package: $(webPackage) | ||
deploymentMethod: "runFromPackage" | ||
|
||
- stage: DeployFQA | ||
displayName: FQA | ||
dependsOn: DeployCI | ||
condition: succeeded() | ||
|
||
variables: | ||
environment: "fqa" | ||
functionServiceName: func-fap-summary-$(environment) | ||
|
||
jobs: | ||
- deployment: Deploy | ||
|
||
displayName: "Deploy function app" | ||
environment: fusion-resources-fqa | ||
|
||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- template: templates/deploy-summary-function-template.yml | ||
parameters: | ||
envName: $(environment) | ||
clientId: "5a842df8-3238-415d-b168-9f16a6a6031b" | ||
fusionEnvironment: fqa | ||
azureSubscription: $(subscriptionServiceNonProd) | ||
|
||
- task: AzureFunctionApp@1 | ||
inputs: | ||
azureSubscription: $(subscriptionServiceNonProd) | ||
appType: "functionApp" | ||
appName: $(functionServiceName) | ||
package: $(webPackage) | ||
deploymentMethod: "runFromPackage" | ||
|
||
- stage: DeployTR | ||
displayName: TR | ||
dependsOn: DeployCI | ||
condition: succeeded() | ||
|
||
variables: | ||
environment: "tr" | ||
functionServiceName: func-fap-summary-$(environment) | ||
|
||
jobs: | ||
- deployment: Deploy | ||
|
||
displayName: "Deploy function app" | ||
environment: fusion-resources-tr | ||
|
||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- template: templates/deploy-summary-function-template.yml | ||
parameters: | ||
envName: $(environment) | ||
clientId: "5a842df8-3238-415d-b168-9f16a6a6031b" | ||
fusionEnvironment: tr | ||
azureSubscription: $(subscriptionServiceNonProd) | ||
|
||
- task: AzureFunctionApp@1 | ||
inputs: | ||
azureSubscription: $(subscriptionServiceNonProd) | ||
appType: "functionApp" | ||
appName: $(functionServiceName) | ||
package: $(webPackage) | ||
deploymentMethod: "runFromPackage" | ||
|
||
- stage: DeployFPRD | ||
displayName: FPRD | ||
dependsOn: DeployFQA | ||
condition: succeeded() | ||
|
||
variables: | ||
environment: "fprd" | ||
functionServiceName: func-fap-summary-$(environment) | ||
|
||
jobs: | ||
- deployment: Deploy | ||
|
||
displayName: "Deploy function app" | ||
environment: fusion-prod | ||
|
||
strategy: | ||
runOnce: | ||
deploy: | ||
steps: | ||
- template: templates/deploy-summary-function-template.yml | ||
parameters: | ||
envName: $(environment) | ||
clientId: "97978493-9777-4d48-b38a-67b0b9cd88d2" | ||
fusionResource: "97978493-9777-4d48-b38a-67b0b9cd88d2" | ||
fusionEnvironment: fprd | ||
azureSubscription: $(subscriptionServiceProd) | ||
|
||
- task: AzureFunctionApp@1 | ||
inputs: | ||
azureSubscription: $(subscriptionServiceProd) | ||
appType: "functionApp" | ||
appName: $(functionServiceName) | ||
package: $(webPackage) | ||
deploymentMethod: "runFromPackage" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
pipelines/templates/deploy-summary-function-template.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
parameters: | ||
envName: '' | ||
clientId: '' | ||
fusionEnvironment: 'ci' | ||
fusionResource: '5a842df8-3238-415d-b168-9f16a6a6031b' | ||
templateFile: $(Build.SourcesDirectory)/src/Fusion.Summary.Functions/Deployment/function.template.json | ||
disabledFunctionsFile: $(Build.SourcesDirectory)/src/Fusion.Summary.Functions/Deployment/disabled-functions.json | ||
azureSubscription: 'PROJECT_PORTAL (63b791ae-b2bc-41a1-ac66-806c4e69bffe)' | ||
|
||
steps: | ||
- checkout: self | ||
- task: AzurePowerShell@5 | ||
displayName: 'Deploy Function ARM template' | ||
inputs: | ||
azureSubscription: ${{ parameters.azureSubscription }} | ||
ScriptType: 'InlineScript' | ||
FailOnStandardError: true | ||
azurePowerShellVersion: 'LatestVersion' | ||
Inline: | | ||
$environment = "${{ parameters.envName }}" | ||
$fusionEnvironment = "${{ parameters.fusionEnvironment }}" | ||
$functionAppName = "func-fap-summary-$environment" | ||
$envVaultName = "kv-fap-resources-$environment" | ||
$envResourceGroup = Get-AzResourceGroup -Tag @{ "fusion-app-component" = "resources-rg-$environment" } | ||
if ($envResourceGroup -eq $null) { throw "Cannot locate resource group for environment '$environment'" } | ||
$resourceGroup = $envResourceGroup.ResourceGroupName | ||
Write-Host "Using resource group $resourceGroup" | ||
function Get-SecretsId($secret) { | ||
$value = (Get-AzKeyVaultSecret -VaultName $envVaultName -Name $secret) | ||
if ($value.Id -eq $null) { return "" } else { return $value.Id.replace($value.Version,'') } | ||
} | ||
# | ||
# Generate the app settings | ||
# | ||
# Sett correct resources URI based on environment | ||
$resourcesFunctionUri = "https://resources-api.$environment.fusion-dev.net/" | ||
$summaryFunctionUri = "https://summary-api.$environment.fusion-dev.net/" | ||
if ($environment -eq "fprd") { | ||
$resourcesFunctionUri = "https://fap-resources-api-fprd.azurewebsites.net/" | ||
$summaryFunctionUri = "https://fap-summary-api-fprd.azurewebsites.net/" | ||
} | ||
$settings = @{ | ||
clientId = "${{ parameters.clientId }}" | ||
secretIds = @{ | ||
clientSecret = Get-SecretsId -secret AzureAd--ClientSecret | ||
serviceBus = Get-SecretsId -secret Connectionstrings--ServiceBus | ||
} | ||
endpoints = @{ | ||
lineorg = "https://fusion-s-lineorg-$fusionEnvironment.azurewebsites.net" | ||
org = "https://fusion-s-org-$fusionEnvironment.azurewebsites.net" | ||
people = "https://fusion-s-people-$fusionEnvironment.azurewebsites.net" | ||
resources = "$resourcesFunctionUri" | ||
summary = "$summaryFunctionUri" | ||
notifications = "https://fusion-s-notification-$fusionEnvironment.azurewebsites.net" | ||
context = "https://fusion-s-context-$fusionEnvironment.azurewebsites.net" | ||
portal = "https://fusion-s-portal-$fusionEnvironment.azurewebsites.net" | ||
} | ||
resources = @{ | ||
fusion = "${{ parameters.fusionResource }}" | ||
} | ||
queues = @{ | ||
departmentSummaryWeeklyQueue = "scheduled-weekly-department-report" | ||
} | ||
} | ||
if ($fusionEnvironment -eq "fprd") { | ||
$settings.endpoints.portal = "https://fusion.equinor.com" | ||
} | ||
New-AzResourceGroupDeployment -Mode Incremental -Name "summary-function" -ResourceGroupName $resourceGroup -TemplateFile "${{ parameters.templateFile }}" ` | ||
-env-name $environment ` | ||
-settings $settings | ||
$functionApp = Get-AzWebApp -ResourceGroupName $resourceGroup -Name $functionAppName | ||
Set-AzKeyVaultAccessPolicy -VaultName $envVaultName -ResourceGroupName $resourceGroup -ObjectId $functionApp.Identity.PrincipalId -PermissionsToSecrets get | ||
## Load disabled functions | ||
$disabledFunctionConfig = ConvertFrom-Json (Get-Content "${{ parameters.disabledFunctionsFile }}" -Raw) | ||
$disabledFunctions = $disabledFunctionConfig | where -Property environment -eq $environment | Select -expandproperty disabledFunctions | ||
Write-Host "Disabled functions" | ||
$disabledFunctions | ||
$settings = @{} | ||
ForEach ($kvp in $functionApp.SiteConfig.AppSettings) { | ||
$settings[$kvp.Name] = $kvp.Value | ||
} | ||
## Mark functions as disabled | ||
$disabledFunctions | ForEach-Object { $settings["AzureWebJobs.$_.Disabled"] = "true" } | ||
## Update web app settings for function app | ||
Set-AzWebApp -ResourceGroupName $resourceGroup -Name $functionAppName -AppSettings $settings | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters