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

chore: use new monitor package w/ newly deployed resources #576

Open
wants to merge 86 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
f5a2037
chore: deploy test resourcs w/ bicep
stijnmoreels May 23, 2024
63bf571
pr-fix: use correct parameter default value
stijnmoreels May 23, 2024
3747e10
pr-fix: remove invalid blank space in job name
stijnmoreels May 23, 2024
304d888
pr-fix: use script type 'pscore'
stijnmoreels May 23, 2024
bbd019b
pr-fix: convert from json syntax error
stijnmoreels May 23, 2024
6b5272a
pr-fix: correctly use env vars
stijnmoreels May 23, 2024
f949e31
pr-fix: correctly use env vars
stijnmoreels May 23, 2024
2790056
pr-fix: remove invalid params descriptions
stijnmoreels May 23, 2024
8fec876
pr-fix: add required location & import app insights module
stijnmoreels May 23, 2024
3cb56bb
pr-fix: install az app insights module
stijnmoreels May 23, 2024
4878de1
pr-fix: correct usage of parameters
stijnmoreels May 23, 2024
23ab8b0
pr-fix: pass subscription id
stijnmoreels May 23, 2024
e5ba23a
pr-fix: login before creating api key
stijnmoreels May 23, 2024
f8fefd4
pr-fix: login before creating api key
stijnmoreels May 23, 2024
47cf55b
pr-fix: correct multiple params
stijnmoreels May 23, 2024
ae159ea
pr-fix: correct multiple params
stijnmoreels May 23, 2024
7197500
pr-fix: remove unn login
stijnmoreels May 23, 2024
c49969e
pr-fix: fix json deserialization + sub id set
stijnmoreels May 23, 2024
fc55b38
pr-fix: correct multiple param pass
stijnmoreels May 23, 2024
64c21c6
pr-fix: remove single quotes from var names
stijnmoreels May 23, 2024
82e680e
pr-fix: correct var names
stijnmoreels May 23, 2024
e31ffc7
pr-fix: correct var names
stijnmoreels May 23, 2024
20acf7c
pr-fix: explicitly set az context
stijnmoreels May 23, 2024
08a9134
pr-fix: use az cli alternative
stijnmoreels May 23, 2024
de1e60a
pr-fix: install app insights extension
stijnmoreels May 23, 2024
7815798
pr-fix: correct variable group name pass in
stijnmoreels May 23, 2024
bfa81be
pr-fix: correct read permissions in command
stijnmoreels May 28, 2024
c8b920a
pr-fix: use correct resource group
stijnmoreels May 28, 2024
75ae273
pr-temp: write output
stijnmoreels May 28, 2024
bcfe2f4
pr-fix: use ps for api key
stijnmoreels May 28, 2024
8688e95
pr-fix: api key description
stijnmoreels May 28, 2024
9656267
pr-fix: api permissions
stijnmoreels May 28, 2024
dafac7a
pr-fix: subscription ID
stijnmoreels May 28, 2024
77ff531
pr-fix: subscription ID
stijnmoreels May 28, 2024
8d85b7f
pr-fix: correct json serialization
stijnmoreels May 28, 2024
2ebd9ca
pr-fix: correct retrieving api key
stijnmoreels May 28, 2024
1cc8d19
pr-fix: delete api key if present
stijnmoreels May 28, 2024
bc2828b
pr-fix: show app insights output
stijnmoreels May 28, 2024
303959e
pr-fix: upsert api key
stijnmoreels May 28, 2024
f1bb28d
pr-fix: only expose properties
stijnmoreels May 28, 2024
93c9776
pr-fix: add system access token
stijnmoreels May 28, 2024
7d9a449
pr-fix: save secrets in vault
stijnmoreels May 28, 2024
72a905f
pr-fix: correct back tick
stijnmoreels May 28, 2024
9a1c359
pr-fix: correct back tick
stijnmoreels May 28, 2024
33944eb
pr-fix: correct secret name
stijnmoreels May 28, 2024
ec486bb
pr-fix: add role assignments to key vault for the service principal
stijnmoreels May 30, 2024
94c6531
pr-fix: add service principal ID to bicep parameters
stijnmoreels May 30, 2024
4a5cff7
pr-fix: add owner role assignment for service principal to rg
stijnmoreels May 30, 2024
6f08dbe
pr-fix: resource group deployment
stijnmoreels May 30, 2024
ae207c4
pr-fix: use correct key vault role name
stijnmoreels May 30, 2024
701c895
pr-fix: use object id instead
stijnmoreels May 30, 2024
2e56d16
pr-fix: use object id instead
stijnmoreels May 30, 2024
24e7db4
pr-fix: use correct object id
stijnmoreels May 30, 2024
67a6bba
pr-fix: correct secret name
stijnmoreels May 30, 2024
29afde8
pr-fix: update ci pipeline to use new resources
stijnmoreels May 30, 2024
32f4a2c
pr-fix: remove unused additions
stijnmoreels May 30, 2024
8864a3a
pr-fix: add updated integration test run to release pipeline
stijnmoreels May 30, 2024
a205f92
pr-fix: correct template path
stijnmoreels May 30, 2024
af6dedf
chore: use new monitor package w/ dev tenant resources
stijnmoreels Jul 30, 2024
c7321af
pr-fix: use guid for role definition
stijnmoreels Jul 30, 2024
6f562b9
pr-fix: pass in the key vault name
stijnmoreels Jul 30, 2024
db1cf24
pr-fix: use guid for role definition
stijnmoreels Jul 30, 2024
54daf36
pr-fix: add servie principal to env
stijnmoreels Jul 30, 2024
67ba308
pr-fix: use correct syntax
stijnmoreels Jul 31, 2024
dacdfba
pr-fix: use single vault name
stijnmoreels Jul 31, 2024
fdfd7ad
pr-fix: use correct value syntax
stijnmoreels Jul 31, 2024
ddadafc
pr-fix: use pscal case name
stijnmoreels Aug 1, 2024
cefafaa
pr-fix: use pascalcase names
stijnmoreels Aug 1, 2024
46d6d82
pr-fix: use observability prefix
stijnmoreels Aug 1, 2024
50af20d
pr-fix: use pacal case
stijnmoreels Aug 1, 2024
0754a0a
pr-fix: correct replacement variable names
stijnmoreels Aug 1, 2024
0cd5d6f
pr-fix: use corect name
stijnmoreels Aug 1, 2024
798eff7
pr-fix: use correct var name
stijnmoreels Aug 1, 2024
2df7ca9
pr-fix: move to correct location
stijnmoreels Aug 1, 2024
f0188bb
pr-fix: move to correct location
stijnmoreels Aug 1, 2024
16a11f2
pr-fix: correct secret value
stijnmoreels Aug 1, 2024
26f3beb
pr-fix: use workspace id
stijnmoreels Aug 1, 2024
bcb758f
pr-fix: var name
stijnmoreels Aug 1, 2024
f3d5073
pr-fix: pass correct instrumentation key
stijnmoreels Aug 1, 2024
3f47744
pr-fix: correct exception message
stijnmoreels Aug 1, 2024
5e2b926
pr-fix: rename to original class to reduce code changes
stijnmoreels Aug 1, 2024
ab45203
pr-fix: minimize trace changes
stijnmoreels Aug 1, 2024
3127067
pr-fix: use original namespace to reduce changes
stijnmoreels Aug 1, 2024
d0e94e4
pr-fix: reduce request, dependency and exception changes
stijnmoreels Aug 1, 2024
b7304e2
pr-fix: cloud result for lesser changes
stijnmoreels Aug 1, 2024
4ac4c1b
pr-fix: place resultcode in request
stijnmoreels Aug 1, 2024
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
74 changes: 13 additions & 61 deletions build/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ parameters:
- name: 'Package.Version.ManualTrigger'
type: string
default: 'preview'
- name: azureServiceConnection
displayName: 'Azure service connection'
type: string
default: 'Azure Codit-Arcus Service Principal'

resources:
repositories:
Expand All @@ -27,7 +31,6 @@ resources:
endpoint: arcus-azure

variables:
- group: 'Arcus Observability - Integration Testing'
- group: 'Arcus - GitHub Package Registry'
- group: 'Build Configuration'
- template: ./variables/build.yml
Expand Down Expand Up @@ -75,78 +78,27 @@ stages:
dependsOn: Build
condition: succeeded()
jobs:
- job: UnitTests
displayName: 'Run unit tests'
pool:
vmImage: '$(Vm.Image)'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
inputs:
artifact: 'Build'
path: '$(Build.SourcesDirectory)'
- task: UseDotNet@2
displayName: 'Import .NET Core SDK ($(DotNet.Sdk.PreviousVersion))'
inputs:
packageType: 'sdk'
version: '$(DotNet.Sdk.PreviousVersion)'
- template: test/run-unit-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
includePreviewVersions: $(DotNet.Sdk.IncludePreviewVersions)
projectName: '$(Project).Tests.Unit'
- template: templates/run-unit-tests.yml

- stage: IntegrationTests
displayName: Integration Tests
dependsOn: Build
condition: succeeded()
jobs:
- job: IntegrationTests
displayName: 'Run integration tests'
pool:
vmImage: '$(Vm.Image)'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
inputs:
artifact: 'Build'
path: '$(Build.SourcesDirectory)'
- task: UseDotNet@2
displayName: 'Import .NET Core SDK ($(DotNet.Sdk.PreviousVersion))'
inputs:
packageType: 'sdk'
version: '$(DotNet.Sdk.PreviousVersion)'
- template: test/run-integration-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
includePreviewVersions: $(DotNet.Sdk.IncludePreviewVersions)
projectName: '$(Project).Tests.Integration'
category: 'Integration'
- template: templates/run-self-contained-integration-tests.yml
parameters:
azureServiceConnection: '${{ parameters.azureServiceConnection }}'

- stage: DockerTests
displayName: Docker Tests
dependsOn: Build
condition: succeeded()
jobs:
- job: DockerTests
displayName: 'Run Docker tests'
pool:
vmImage: '$(Vm.Image)'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
inputs:
artifact: 'Build'
path: '$(Build.SourcesDirectory)'
- task: UseDotNet@2
displayName: 'Import .NET Core SDK ($(DotNet.Sdk.PreviousVersion))'
inputs:
packageType: 'sdk'
version: '$(DotNet.Sdk.PreviousVersion)'
- template: templates/run-docker-integration-tests.yml
parameters:
dockerProjectName: '$(Project).Tests.Runtimes.AzureFunction'
httpPort: '$(AzureFunctions.HttpPort)'
- template: templates/run-docker-integration-tests.yml
parameters:
dockerProjectName: '$(Project).Tests.Runtimes.AzureFunction'
httpPort: '$(AzureFunctions.HttpPort)'
azureServiceConnection: '${{ parameters.azureServiceConnection }}'

- stage: ReleaseToMyget
displayName: 'Release to MyGet'
Expand Down
45 changes: 45 additions & 0 deletions build/deploy-test-resources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Arcus Observability - Deploy test resources

trigger: none
pr: none

parameters:
- name: azureServiceConnection
displayName: 'Azure service connection'
type: string
default: 'Azure Codit-Arcus Service Principal'
- name: resourceGroupName
displayName: 'Resource group name'
default: arcus-observability-dev-we-rg

variables:
- template: ./variables/build.yml
- template: ./variables/test.yml

stages:
- stage: Deploy
jobs:
- job: DeployBicep
displayName: 'Deploy test resources'
pool:
vmImage: '$(Vm.Image)'
steps:
- task: AzureCLI@2
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
azureSubscription: '${{ parameters.azureServiceConnection }}'
addSpnToEnvironment: true
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
$objectId = (az ad sp show --id $env:servicePrincipalId | ConvertFrom-Json).id
az deployment sub create `
--location westeurope `
--template-file ./build/templates/deploy-test-resources.bicep `
--parameters location=westeurope `
--parameters resourceGroupName=${{ parameters.resourceGroupName }} `
--parameters instrumentationKey_secretName=${{ variables['Arcus.Observability.ApplicationInsights.InstrumentationKey.SecretName'] }} `
--parameters workspaceId_secretName=${{ variables['Arcus.Observability.LogAnalytics.WorkspaceId.SecretName'] }} `
--parameters keyVaultName=${{ variables['Arcus.Observability.KeyVault.Name'] }} `
--parameters servicePrincipal_objectId=$objectId
74 changes: 13 additions & 61 deletions build/nuget-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ pr: none
parameters:
- name: 'Package.Version'
type: 'string'
- name: azureServiceConnection
displayName: 'Azure service connection'
type: string
default: 'Azure Codit-Arcus Service Principal'

resources:
repositories:
Expand All @@ -15,7 +19,6 @@ resources:
endpoint: arcus-azure

variables:
- group: 'Arcus Observability - Integration Testing'
- group: 'Build Configuration'
- template: ./variables/build.yml
- template: ./variables/test.yml
Expand Down Expand Up @@ -57,78 +60,27 @@ stages:
dependsOn: Build
condition: succeeded()
jobs:
- job: UnitTests
displayName: 'Run unit tests'
pool:
vmImage: '$(Vm.Image)'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
inputs:
artifact: 'Build'
path: '$(Build.SourcesDirectory)'
- task: UseDotNet@2
displayName: 'Import .NET Core SDK ($(DotNet.Sdk.PreviousVersion))'
inputs:
packageType: 'sdk'
version: '$(DotNet.Sdk.PreviousVersion)'
- template: test/run-unit-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
includePreviewVersions: $(DotNet.Sdk.IncludePreviewVersions)
projectName: '$(Project).Tests.Unit'
- template: templates/run-unit-tests.yml

- stage: IntegrationTests
displayName: Integration Tests
dependsOn: Build
condition: succeeded()
jobs:
- job: IntegrationTests
displayName: 'Run integration tests'
pool:
vmImage: '$(Vm.Image)'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
inputs:
artifact: 'Build'
path: '$(Build.SourcesDirectory)'
- task: UseDotNet@2
displayName: 'Import .NET Core SDK ($(DotNet.Sdk.PreviousVersion))'
inputs:
packageType: 'sdk'
version: '$(DotNet.Sdk.PreviousVersion)'
- template: test/run-integration-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
includePreviewVersions: $(DotNet.Sdk.IncludePreviewVersions)
projectName: '$(Project).Tests.Integration'
category: 'Integration'
- template: templates/run-self-contained-integration-tests.yml
parameters:
azureServiceConnection: '${{ parameters.azureServiceConnection }}'

- stage: DockerTests
displayName: Docker Tests
dependsOn: Build
condition: succeeded()
jobs:
- job: DockerTests
displayName: 'Run Docker tests'
pool:
vmImage: '$(Vm.Image)'
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download build artifacts'
inputs:
artifact: 'Build'
path: '$(Build.SourcesDirectory)'
- task: UseDotNet@2
displayName: 'Import .NET Core SDK ($(DotNet.Sdk.PreviousVersion))'
inputs:
packageType: 'sdk'
version: '$(DotNet.Sdk.PreviousVersion)'
- template: templates/run-docker-integration-tests.yml
parameters:
dockerProjectName: '$(Project).Tests.Runtimes.AzureFunction'
httpPort: '$(AzureFunctions.HttpPort)'
- template: templates/run-docker-integration-tests.yml
parameters:
dockerProjectName: '$(Project).Tests.Runtimes.AzureFunction'
httpPort: '$(AzureFunctions.HttpPort)'
azureServiceConnection: '${{ parameters.azureServiceConnection }}'

- stage: Release
displayName: 'Release to NuGet.org'
Expand Down
90 changes: 90 additions & 0 deletions build/templates/deploy-test-resources.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Define the location for the deployment of the components.
param location string

// Define the name of the resource group where the components will be deployed.
param resourceGroupName string

// Define the name of the secret that will store the Application Insights Instrumentation Key.
param instrumentationKey_secretName string

// Define the name of the secret that will store the Application Insights workspace resource ID.
param workspaceId_secretName string

// Define the name of the Key Vault.
param keyVaultName string

// Define the Service Principal ID that needs access full access to the deployed resource group.
param servicePrincipal_objectId string

targetScope='subscription'

module resourceGroup 'br/public:avm/res/resources/resource-group:0.2.3' = {
name: 'resourceGroupDeployment'
params: {
name: resourceGroupName
location: location
}
}

resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' existing = {
name: resourceGroupName
}

module workspace 'br/public:avm/res/operational-insights/workspace:0.3.4' = {
name: 'workspaceDeployment'
dependsOn: [
resourceGroup
]
scope: rg
params: {
name: 'arcus-observability-dev-we-workspace'
location: location
}
}

module component 'br/public:avm/res/insights/component:0.3.0' = {
name: 'componentDeployment'
dependsOn: [
resourceGroup
]
scope: rg
params: {
name: 'arcus-observability-dev-we-app-insights'
workspaceResourceId: workspace.outputs.resourceId
location: location
roleAssignments: [
{
principalId: servicePrincipal_objectId
roleDefinitionIdOrName: '73c42c96-874c-492b-b04d-ab87d138a893'
}
]
}
}

module vault 'br/public:avm/res/key-vault/vault:0.6.1' = {
name: 'vaultDeployment'
dependsOn: [
resourceGroup
]
scope: rg
params: {
name: keyVaultName
location: location
roleAssignments: [
{
principalId: servicePrincipal_objectId
roleDefinitionIdOrName: 'Key Vault Secrets officer'
}
]
secrets: [
{
name: instrumentationKey_secretName
value: component.outputs.instrumentationKey
}
{
name: workspaceId_secretName
value: workspace.outputs.logAnalyticsWorkspaceId
}
]
}
}
31 changes: 31 additions & 0 deletions build/templates/import-keyvault-secrets.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
parameters:
azureServiceConnection: ''

steps:
- task: AzureCLI@2
displayName: 'Import secrets from Azure Key Vault'
inputs:
azureSubscription: '${{ parameters.azureServiceConnection }}'
addSpnToEnvironment: true
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name Arcus.Scripting.DevOps -AllowClobber

Set-AzDevOpsVariable -Name 'Arcus.Observability.TenantId' -Value $env:tenantId
Set-AzDevOpsVariable -Name 'Arcus.Observability.ServicePrincipal.ClientId' -Value $env:servicePrincipalId
Set-AzDevOpsVariable -Name 'Arcus.Observability.ServicePrincipal.ClientSecret' -Value $env:servicePrincipalKey

$keyVaultName = $env:ARCUS_OBSERVABILITY_KEYVAULT_NAME
Write-Host "Importing secrets from Key Vault: $keyVaultName"

$instrumentationKey_secretName = $env:ARCUS_OBSERVABILITY_APPLICATIONINSIGHTS_INSTRUMENTATIONKEY_SECRETNAME
Write-Host "Importing secret: $instrumentationKey_secretName"
$instrumentationKeySecret = az keyvault secret show --name "$instrumentationKey_secretName" --vault-name "$keyVaultName" | ConvertFrom-Json
Set-AzDevOpsVariable -AsSecret -Name 'Arcus.Observability.ApplicationInsights.InstrumentationKey' -Value $instrumentationKeySecret.value

$resourceId_secretName = $env:ARCUS_OBSERVABILITY_LOGANALYTICS_WORKSPACEID_SECRETNAME
Write-Host "Importing secret: $resourceId_secretName"
$resourceIdSecret = az keyvault secret show --name "$resourceId_secretName" --vault-name "$keyVaultName" | ConvertFrom-Json
Set-AzDevOpsVariable -AsSecret -Name 'Arcus.Observability.ApplicationInsights.LogAnalytics.WorkspaceId' -Value $resourceIdSecret.value
Loading
Loading