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: deploy/use new test resources in dev tenant #574

Closed
Closed
Show file tree
Hide file tree
Changes from 58 commits
Commits
Show all changes
80 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
3bebc26
pr-fix: expose app insights resource id io workspace id
stijnmoreels May 30, 2024
f62f123
pr-fix: extract variable names
stijnmoreels Jun 11, 2024
035023f
pr-fix: add depends on and extract variables
stijnmoreels Jun 11, 2024
2b19189
pr-fix: use other way to get variables
stijnmoreels Jun 11, 2024
66529e8
pr-fix: set az keyvault secrets as pipeline variables
stijnmoreels Jun 13, 2024
f07114a
pr-fix: add logging for key vault secrets
stijnmoreels Jun 13, 2024
72b55f7
pr-fix: update docker tests with key vault secrets
stijnmoreels Jun 13, 2024
08180d2
pr-fix: correct path to template
stijnmoreels Jun 13, 2024
50ae26c
pr-fix: correct docker parameters
stijnmoreels Jun 13, 2024
677ced8
pr-fix: correct release parameters
stijnmoreels Jun 13, 2024
5d0a175
pr-fix: correct pass parameter
stijnmoreels Jun 13, 2024
7a7373c
pr-fix: move app insights param to var
stijnmoreels Jun 25, 2024
e19307f
pr-fix: simplify pipeline variable setting
stijnmoreels Jul 25, 2024
abf26ef
pr-fix: typo in backtick parameter
stijnmoreels Jul 25, 2024
8fdc68d
pr-fix: missed passing app id secret name
stijnmoreels Jul 25, 2024
fb8a9fd
pr-fix: job spacing
stijnmoreels Jul 25, 2024
16bf488
pr-fix: correct key vault secret name definitions
stijnmoreels Jul 25, 2024
d607f53
pr-fix: explicit variable extraction
stijnmoreels Jul 25, 2024
d4daa9e
pr-fix: add logging
stijnmoreels Jul 25, 2024
4540054
pr-fix: use env variables
stijnmoreels Jul 25, 2024
2230b50
pr-fix: use diff var retrieval
stijnmoreels Jul 25, 2024
c654428
Update deploy-test-resources.bicep
stijnmoreels Jul 25, 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
26 changes: 11 additions & 15 deletions build/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ parameters:
- name: 'Package.Version.ManualTrigger'
type: string
default: 'preview'
- name: azureServiceConnection
displayName: 'Azure service connection'
type: string
default: 'Azure Codit-Arcus Service Principal'
- name: keyVaultName
displayName: 'Azure Key vault with integration test secrets'
type: string
default: 'arcus-observability-kv'

resources:
repositories:
Expand Down Expand Up @@ -111,17 +119,10 @@ stages:
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
- template: templates/run-self-contained-integration-tests.yml
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
includePreviewVersions: $(DotNet.Sdk.IncludePreviewVersions)
projectName: '$(Project).Tests.Integration'
category: 'Integration'
azureServiceConnection: '${{ parameters.azureServiceConnection }}'
keyVaultName: '${{ parameters.keyVaultName }}'

- stage: DockerTests
displayName: Docker Tests
Expand All @@ -138,11 +139,6 @@ stages:
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'
Expand Down
83 changes: 83 additions & 0 deletions build/deploy-test-resources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
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
- name: appInsightsName
displayName: 'Application Insights name'
default: arcus-observability-dev-we-app-insights
- name: variableGroupName
displayName: 'Variable group name'
default: Arcus Observability - Integration Testing

variables:
- name: keyVaultName
value: 'arcus-observability-kv'
- template: ./variables/build.yml

stages:
- stage: Deploy
stijnmoreels marked this conversation as resolved.
Show resolved Hide resolved
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: |
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name Arcus.Scripting.DevOps -AllowClobber
az extension add --name application-insights

$objectId = (az ad sp show --id $env:servicePrincipalId | ConvertFrom-Json).id
$appInsightsOutput = az deployment sub create `
--location westeurope `
--template-file ./build/templates/deploy-test-resources.bicep `
--parameters location=westeurope `
--parameters resourceGroupName=${{ parameters.resourceGroupName }} `
--parameters appInsightsName=${{ parameters.appInsightsName }} `
--parameters keyVaultName=${{ variables.keyVaultName }} `
--parameters servicePrincipal_objectId=$objectId `
| ConvertFrom-Json

$apiKeyName = 'Arcus Observability Integration Tests API Key'
if (az monitor app-insights api-key show `
--app ${{ parameters.appInsightsName }} `
--resource-group ${{ parameters.resourceGroupName }} `
--api-key $apiKeyName) {
az monitor app-insights api-key delete `
--api-key $apiKeyName `
--app ${{ parameters.appInsightsName }} `
--resource-group ${{ parameters.resourceGroupName }} `
--yes
}

$apiKeyOutput = az monitor app-insights api-key create `
--api-key $apiKeyName `
--app ${{ parameters.appInsightsName }} `
--resource-group ${{ parameters.resourceGroupName }} `
--read-properties ReadTelemetry `
| ConvertFrom-Json

az keyvault secret set `
--vault-name ${{ variables.keyVaultName }} `
--name 'ApplicationInsights-ApiKey' `
--value $apiKeyOutput.apiKey `

$env:ArmOutputs = ConvertTo-Json $appInsightsOutput.properties.outputs
Set-AzDevOpsArmOutputsToVariableGroup -VariableGroupName '${{ parameters.variableGroupName }}'
26 changes: 11 additions & 15 deletions build/nuget-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ pr: none
parameters:
- name: 'Package.Version'
type: 'string'
- name: azureServiceConnection
displayName: 'Azure service connection'
type: string
default: 'Azure Codit-Arcus Service Principal'
- name: keyVaultName
displayName: 'Azure Key vault with integration test secrets'
type: string
default: 'arcus-observability-kv'

resources:
repositories:
Expand Down Expand Up @@ -93,17 +101,10 @@ stages:
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
- template: templates/run-self-contained-integration-tests.yml
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
includePreviewVersions: $(DotNet.Sdk.IncludePreviewVersions)
projectName: '$(Project).Tests.Integration'
category: 'Integration'
azureServiceConnection: '${{ parameters.azureServiceConnection }}'
keyVaultName: '${{ parameters.keyVaultName }}'

- stage: DockerTests
displayName: Docker Tests
Expand All @@ -120,11 +121,6 @@ stages:
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'
Expand Down
71 changes: 71 additions & 0 deletions build/templates/deploy-test-resources.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// 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 Application Insights component.
param appInsightsName 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'
scope: rg
params: {
name: 'arcus-observability-dev-we-workspace'
location: location
}
}

module component 'br/public:avm/res/insights/component:0.3.0' = {
name: 'componentDeployment'
scope: rg
params: {
name: appInsightsName
workspaceResourceId: workspace.outputs.resourceId
location: location
}
}

module vault 'br/public:avm/res/key-vault/vault:0.6.1' = {
name: 'vaultDeployment'
scope: rg
params: {
name: keyVaultName
location: location
roleAssignments: [
{
principalId: servicePrincipal_objectId
roleDefinitionIdOrName: 'Key Vault Secrets officer'
}
]
secrets: [
{
name: 'ApplicationInsights-InstrumentationKey'
value: component.outputs.instrumentationKey
}
]
}
}

output ApplicationInsights_WorkspaceId string = workspace.outputs.resourceId
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be used when we migrate to the new app insights query nuget package.

output ApplicationInsights_ApplicationId string = component.outputs.applicationId
5 changes: 5 additions & 0 deletions build/templates/run-docker-integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ steps:
env:
PROJECT_NAME: ${{ parameters.dockerProjectName }}
HTTP_PORT: ${{ parameters.httpPort }}
- task: UseDotNet@2
displayName: 'Import .NET Core SDK ($(DotNet.Sdk.PreviousVersion))'
inputs:
packageType: 'sdk'
version: '$(DotNet.Sdk.PreviousVersion)'
- task: UseDotNet@2
displayName: 'Import .NET Core SDK ($(DotNet.Sdk.Version))'
inputs:
Expand Down
22 changes: 22 additions & 0 deletions build/templates/run-self-contained-integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
parameters:
azureServiceConnection: ''
keyVaultName: ''

steps:
- task: UseDotNet@2
displayName: 'Import .NET Core SDK ($(DotNet.Sdk.PreviousVersion))'
inputs:
packageType: 'sdk'
version: '$(DotNet.Sdk.PreviousVersion)'
- task: AzureKeyVault@2
displayName: 'Import secrets from Azure Key Vault'
inputs:
azureSubscription: '${{ parameters.azureServiceConnection }}'
KeyVaultName: '${{ parameters.keyVaultName }}'
SecretsFilter: '*'
- template: test/run-integration-tests.yml@templates
parameters:
dotnetSdkVersion: '$(DotNet.Sdk.Version)'
includePreviewVersions: $(DotNet.Sdk.IncludePreviewVersions)
projectName: '$(Project).Tests.Integration'
category: 'Integration'
6 changes: 3 additions & 3 deletions src/Arcus.Observability.Tests.Integration/appsettings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"ApplicationInsights": {
"InstrumentationKey": "#{ApplicationInsights.InstrumentationKey}#",
"ApiKey": "#{ApplicationInsights.ApiKey}#",
"ApplicationId": "#{ApplicationInsights.ApplicationId}#"
"InstrumentationKey": "#{ApplicationInsights_InstrumentationKey}#",
"ApiKey": "#{ApplicationInsights_ApiKey}#",
"ApplicationId": "#{ApplicationInsights_ApplicationId}#"
},
"AzureFunctions": {
"HttpPort": "#{AzureFunctions.HttpPort}#"
Expand Down
Loading