Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(fusion-integration): Update Fusion Core API Urls #718

Merged
merged 20 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions pipelines/templates/deploy-function-pr-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,20 @@ steps:
# Generate the app settings
#
# Sett correct resources URI based on environment
$resourcesFunctionUri = "https://resources-api-pr-$pullRequestNumber.fusion-dev.net/"

$settings = @{
clientId = "${{ parameters.clientId }}"
secretIds = @{
clientSecret = "https://$envVaultName.vault.azure.net:443/secrets/AzureAd--ClientSecret"
serviceBus = "https://$envVaultName.vault.azure.net:443/secrets/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"
notifications = "https://fusion-s-notification-$fusionEnvironment.azurewebsites.net"
context = "https://fusion-s-context-$fusionEnvironment.azurewebsites.net"
portal = "https://fusion-s-portal-$fusionEnvironment.azurewebsites.net"
lineorg = "https://lineorg.$fusionEnvironment.api.fusion-dev.net"
org = "https://org.$fusionEnvironment.api.fusion-dev.net"
people = "https://people.$fusionEnvironment.api.fusion-dev.net"
resources = "https://fra-resources-$pullRequestNumber.pr.api.fusion-dev.net"
notifications = "https://notification.$fusionEnvironment.api.fusion-dev.net"
context = "https://context.$fusionEnvironment.api.fusion-dev.net"
portal = "https://fusion.$fusionEnvironment.fusion-dev.net"
}
resources = @{
fusion = "${{ parameters.fusionResource }}"
Expand Down
41 changes: 27 additions & 14 deletions pipelines/templates/deploy-function-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,28 @@ steps:
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/"
if ($environment -eq "fprd") { $resourcesFunctionUri = "https://fap-resources-api-fprd.azurewebsites.net/"}
# Set correct resources URI based on environment

if ($fusionEnvironment -eq "fprd") {
$lineorg = "https://lineorg.api.fusion.equinor.com"
$org = "https://org.api.fusion.equinor.com"
$people = "https://people.api.fusion.equinor.com"
$resources = "https://fra-resources.api.fusion.equinor.com"
$notifications = "https://notification.api.fusion.equinor.com"
$context = "https://context.api.fusion.equinor.com"
$portal = "https://fusion.equinor.com"
}
else {
$lineorg = "https://lineorg.$fusionEnvironment.api.fusion-dev.net"
$org = "https://org.$fusionEnvironment.api.fusion-dev.net"
$people = "https://people.$fusionEnvironment.api.fusion-dev.net"
$resources = "https://fra-resources.$environment.api.fusion-dev.net"
$notifications = "https://notification.$fusionEnvironment.api.fusion-dev.net"
$context = "https://context.$fusionEnvironment.api.fusion-dev.net"
$portal = "https://fusion.$fusionEnvironment.fusion-dev.net"
}

$settings = @{
clientId = "${{ parameters.clientId }}"
Expand All @@ -47,13 +63,13 @@ steps:
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"
notifications = "https://fusion-s-notification-$fusionEnvironment.azurewebsites.net"
context = "https://fusion-s-context-$fusionEnvironment.azurewebsites.net"
portal = "https://fusion-s-portal-$fusionEnvironment.azurewebsites.net"
lineorg = $lineorg
org = $org
people = $people
resources = $resources
notifications = $notifications
context = $context
portal = $portal
}
resources = @{
fusion = "${{ parameters.fusionResource }}"
Expand All @@ -65,9 +81,6 @@ steps:
}
}

if ($fusionEnvironment -eq "fprd") {
$settings.endpoints.portal = "https://fusion.equinor.com"
}

New-AzResourceGroupDeployment -Mode Incremental -Name "resources-function" -ResourceGroupName $resourceGroup -TemplateFile "${{ parameters.templateFile }}" `
-env-name $environment `
Expand Down
161 changes: 77 additions & 84 deletions pipelines/templates/deploy-summary-function-pr-template.yml
Original file line number Diff line number Diff line change
@@ -1,102 +1,95 @@
#
# Template for deploying pull request function app.
#
# Template for deploying pull request function app.
#
# Done this instead of making one template to include all ifs-and-buts.
#


parameters:
envName: ''
clientId: ''
pullRequestNumber: ''
fusionResource: '5a842df8-3238-415d-b168-9f16a6a6031b'
envName: ""
clientId: ""
pullRequestNumber: ""
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)'

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: |
#
# Hardcoded to PR env
#
$environment = "pr"
$pullRequestNumber = "${{ parameters.pullRequestNumber }}"
$fusionEnvironment = "ci"
$functionAppName = "func-fap-summary-$environment"
$envVaultName = "kv-fap-resources-$environment"
$envResourceGroup = Get-AzResourceGroup -Tag @{ "fusion-app-component" = "resources-rg-$environment" }
- checkout: self
- task: AzurePowerShell@5
displayName: "Deploy Function ARM template"
inputs:
azureSubscription: ${{ parameters.azureSubscription }}
ScriptType: "InlineScript"
FailOnStandardError: true
azurePowerShellVersion: "LatestVersion"
Inline: |
#
# Hardcoded to PR env
#
$environment = "pr"
$pullRequestNumber = "${{ parameters.pullRequestNumber }}"
$fusionEnvironment = "ci"
$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'" }

if ($envResourceGroup -eq $null) { throw "Cannot locate resource group for environment '$environment'" }
$resourceGroup = $envResourceGroup.ResourceGroupName
Write-Host "Using resource group $resourceGroup"

$resourceGroup = $envResourceGroup.ResourceGroupName
Write-Host "Using resource group $resourceGroup"
#
# Generate the app settings
#
$settings = @{
clientId = "${{ parameters.clientId }}"
departmentFilter = "PRD"
projectTypeFilter = "PRD"
secretIds = @{
clientSecret = "https://$envVaultName.vault.azure.net:443/secrets/AzureAd--ClientSecret"
serviceBus = "https://$envVaultName.vault.azure.net:443/secrets/Connectionstrings--ServiceBus"
}
endpoints = @{
lineorg = "https://lineorg.$fusionEnvironment.api.fusion-dev.net"
org = "https://org.$fusionEnvironment.api.fusion-dev.net"
people = "https://people.$fusionEnvironment.api.fusion-dev.net"
notifications = "https://notifications.$fusionEnvironment.api.fusion-dev.net"
context = "https://context.$fusionEnvironment.api.fusion-dev.net"
portal = "https://portal.$fusionEnvironment.fusion-dev.net"
resources = "https://fra-resources-$pullRequestNumber.pr.api.fusion-dev.net"
summary = "https://fra-summary-$pullRequestNumber.pr.api.fusion-dev.net"
roles = "https://roles.$fusionEnvironment.api.fusion-dev.net"
}
resources = @{
fusion = "${{ parameters.fusionResource }}"
}
queues = @{
departmentSummaryWeeklyQueue = "scheduled-weekly-department-report"
projectSummaryWeeklyQueue = "scheduled-weekly-project-report"
}
}

#
# Generate the app settings
#
# Sett correct resources URI based on environment
$resourcesFunctionUri = "https://resources-api-pr-$pullRequestNumber.fusion-dev.net/"
$summaryFunctionUri = "https://fra-summary-$pullRequestNumber.pr.api.fusion-dev.net/"
New-AzResourceGroupDeployment -Mode Incremental -Name "summary-function" -ResourceGroupName $resourceGroup -TemplateFile "${{ parameters.templateFile }}" `
-env-name $environment `
-settings $settings

$settings = @{
clientId = "${{ parameters.clientId }}"
departmentFilter = ""
projectTypeFilter = "PRD"
secretIds = @{
clientSecret = "https://$envVaultName.vault.azure.net:443/secrets/AzureAd--ClientSecret"
serviceBus = "https://$envVaultName.vault.azure.net:443/secrets/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"
roles = "https://fusion-s-roles-$fusionEnvironment.azurewebsites.net"
}
resources = @{
fusion = "${{ parameters.fusionResource }}"
}
queues = @{
departmentSummaryWeeklyQueue = "scheduled-weekly-department-report"
projectSummaryWeeklyQueue = "scheduled-weekly-project-report"
}
}

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

$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
## 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
Write-Host "Disabled functions"
$disabledFunctions

$settings = @{}
ForEach ($kvp in $functionApp.SiteConfig.AppSettings) {
$settings[$kvp.Name] = $kvp.Value
}
$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
## 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
44 changes: 30 additions & 14 deletions pipelines/templates/deploy-summary-function-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,28 @@ steps:
# 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/"
$summary = "https://fra-summary.api.fusion.equinor.com"
$portal = "https://fusion.equinor.com"
$lineorg = "https://lineorg.api.fusion.equinor.com"
$org = "https://org.api.fusion.equinor.com"
$people = "https://people.api.fusion.equinor.com"
$resources = "https://fra-resources.api.fusion.equinor.com"
$notifications = "https://notification.api.fusion.equinor.com"
$context = "https://context.api.fusion.equinor.com"
$roles = "https://roles.api.fusion.equinor.com""
}
else {
$summary = "https://fra-summary.$environment.api.fusion-dev.net"
$lineorg = "https://lineorg.$fusionEnvironment.api.fusion-dev.net"
$org = "https://org.$fusionEnvironment.api.fusion-dev.net"
$people = "https://people.$fusionEnvironment.api.fusion-dev.net"
$resources = "https://fra-resources.$environment.api.fusion-dev.net"
$notifications = "https://notification.$fusionEnvironment.api.fusion-dev.net"
$context = "https://context.$fusionEnvironment.api.fusion-dev.net"
$portal = "https://fusion.$fusionEnvironment.fusion-dev.net"
$roles = "https://roles.$fusionEnvironment.api.fusion-dev.net"
}

$settings = @{
Expand All @@ -54,15 +70,15 @@ steps:
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"
roles = "https://fusion-s-roles-$fusionEnvironment.azurewebsites.net"
lineorg = $lineorg
org = $org
people = $people
resources = $resources
notifications = $notifications
context = $context
portal = $portal
summary = $summary
roles = $roles
}
resources = @{
fusion = "${{ parameters.fusionResource }}"
Expand Down
17 changes: 8 additions & 9 deletions src/Fusion.Summary.Functions/Deployment/function.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
"serviceBus": ""
},
"endpoints": {
"lineorg": "https://fusion-s-lineorg-ci.azurewebsites.net",
"org": "https://fusion-s-org-ci.azurewebsites.net",
"people": "https://fusion-s-people-ci.azurewebsites.net",
"resources": "[concat('https://resources-api-', parameters('env-name'), '.fusion-dev.net')]",
"summary": "https://summary-api.ci.fusion-dev.net/",
"notifications": "https://fusion-s-notification-ci.azurewebsites.net",
"context": "https://fusion-s-context-ci.azurewebsites.net",
"portal": "https://fusion-s-portal-ci.azurewebsites.net"
"lineorg": "https://lineorg.ci.api.fusion-dev.net",
"org": "https://org.ci.api.fusion-dev.net",
"people": "https://people.ci.api.fusion-dev.nett",
"resources": "[concat('https://fra-resources.', parameters('env-name'), '.api.fusion-dev.net')]",
"notifications": "https://notification.ci.api.fusion-dev.net",
"context": "https://context.ci.api.fusion-dev.net",
"portal": "https://fusion.ci.fusion-dev.net"
},
"resources": {
"fusion": "5a842df8-3238-415d-b168-9f16a6a6031b"
Expand Down Expand Up @@ -191,4 +190,4 @@
}
}
]
}
}
16 changes: 8 additions & 8 deletions src/Fusion.Summary.Functions/local.settings.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
"project_summary_weekly_queue": "project-summary-weekly-queue-[REPLACE WITH DEV QUEUE]",
"AzureWebJobsServiceBus": "[REPLACE WITH SB CONNECTION STRING]",
"departmentFilter": "PRD",
"Endpoints_lineorg": "https://fusion-s-lineorg-ci.azurewebsites.net",
"Endpoints_people": "https://fusion-s-people-ci.azurewebsites.net",
"Endpoints_org": "https://fusion-s-org-ci.azurewebsites.net",
"Endpoints_resources": "https://resources-api.ci.fusion-dev.net/",
"Endpoints_summary": "https://summary-api.ci.fusion-dev.net/",
"Endpoints_context": "https://fusion-s-context-ci.azurewebsites.net",
"Endpoints_notifications": "https://fusion-s-notification-ci.azurewebsites.net",
"Endpoints_lineorg": "https://lineorg.ci.api.fusion-dev.net/",
"Endpoints_people": "https://people.ci.api.fusion-dev.net/",
"Endpoints_org": "https://org.ci.api.fusion-dev.net/",
"Endpoints_resources": "https://fra-resources.ci.api.fusion-dev.net/",
"Endpoints_summary": "https://fra-summary.ci.api.fusion-dev.net/",
"Endpoints_context": "https://context.ci.api.fusion-dev.net/",
"Endpoints_notifications": "https://notification.ci.api.fusion-dev.net/",
"Endpoints_roles": "https://roles.ci.api.fusion-dev.net",
"Endpoints_Resources_Fusion": "5a842df8-3238-415d-b168-9f16a6a6031b"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@ public static IServiceCollection AddLineOrgHttpClient(this IServiceCollection se
{
var intgConfig = sp.GetRequiredService<IOptions<FusionIntegrationOptions>>();
var fusionEnv = intgConfig.Value.ServiceDiscovery?.Environment ?? "ci";
return Task.FromResult($"https://fusion-s-lineorg-{fusionEnv}.azurewebsites.net");

if (fusionEnv.Equals("fprd", StringComparison.OrdinalIgnoreCase))
return Task.FromResult("https://lineorg.api.fusion.equinor.com");
return Task.FromResult($"https://lineorg.{fusionEnv}.api.fusion-dev.net");
};

// Bug, must be specified
Expand Down
Loading
Loading