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 to new Dev tenant #432

Merged
merged 66 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
fee9a7e
chore: deploy test resources
stijnmoreels Aug 6, 2024
f6e31c2
pr-fix: use linux vm
stijnmoreels Aug 6, 2024
9048f88
pr-fix: missing backtick
stijnmoreels Aug 6, 2024
b6449d1
pr-fix: use parameter secret
stijnmoreels Aug 6, 2024
39e89fd
pr-fix: gen password
stijnmoreels Aug 6, 2024
56acad8
pr-fix: gen password
stijnmoreels Aug 6, 2024
5d89fa2
pr-fix: remove location param
stijnmoreels Aug 6, 2024
8344d3d
pr-fix: add missing params
stijnmoreels Aug 6, 2024
1c90303
pr-fix: server name
stijnmoreels Aug 6, 2024
4e0ca3e
pr-fix: app service name
stijnmoreels Aug 6, 2024
113397f
pr-fix: correct plan
stijnmoreels Aug 6, 2024
bc9fed0
pr-fix: sql db sku
stijnmoreels Aug 8, 2024
b3a6ccd
pr-fix: sql db basic max bytes
stijnmoreels Aug 8, 2024
766c774
pr-fix: use ex max size
stijnmoreels Aug 8, 2024
88c7ecb
pr-fix: change sku
stijnmoreels Aug 8, 2024
2916b6f
pr-fix: change sku
stijnmoreels Aug 8, 2024
d85e68d
pr-fix: change server name
stijnmoreels Aug 8, 2024
44fe753
pr-fix: update min capacity
stijnmoreels Aug 8, 2024
0d1784c
pr-fix: update min capacity
stijnmoreels Aug 8, 2024
2be004a
pr-fix: update min capacity
stijnmoreels Aug 8, 2024
585cae6
pr-fix: update min capacity
stijnmoreels Aug 8, 2024
9f23115
pr-fix: correct basic max size
stijnmoreels Aug 8, 2024
8c116d0
pr-fix: pass in az service connection
stijnmoreels Aug 8, 2024
5af5224
pr-fix: expose test variables
stijnmoreels Aug 8, 2024
43b921b
pr-fix: add quotes to condition
stijnmoreels Aug 8, 2024
f36a7c8
pr-fix: correct var name
stijnmoreels Aug 8, 2024
c109f14
pr-fix: correct arg name
stijnmoreels Aug 8, 2024
18e9664
pr-fix: correct appsettings name
stijnmoreels Aug 8, 2024
ad1b536
pr-fix: use correct role assignments
stijnmoreels Aug 8, 2024
dfc150f
pr-fix: use correct password
stijnmoreels Aug 8, 2024
fcadf5d
pr-fix: add certificate permissions to built-in logic apps service pr…
stijnmoreels Aug 13, 2024
db2b3bf
pr-fix: add role permissions access
stijnmoreels Aug 13, 2024
92beb6e
pr-fix: correct authz
stijnmoreels Aug 13, 2024
b4fafed
pr-fix: correct sql param name
stijnmoreels Aug 13, 2024
ce0aa9e
pr-fix: use access policies
stijnmoreels Aug 15, 2024
f1836bb
pr-fix: use correct access token
stijnmoreels Aug 15, 2024
2104520
pr-fix: use correct key perm
stijnmoreels Aug 15, 2024
92945ed
pr-fix: sql filewalls
stijnmoreels Aug 15, 2024
5659945
pr-fix: correct sql
stijnmoreels Aug 15, 2024
df57494
pr-fix: correct sql
stijnmoreels Aug 15, 2024
4fdf794
pr-fix: correct sql
stijnmoreels Aug 15, 2024
8ee7085
pr-fix: correct ad
stijnmoreels Aug 15, 2024
977fe67
pr-fix: secret name
stijnmoreels Aug 15, 2024
de8aee0
pr-fix: secret name
stijnmoreels Aug 15, 2024
6b85809
pr-fix: secret name
stijnmoreels Aug 15, 2024
59e88bd
pr-fix: logging
stijnmoreels Aug 15, 2024
a23de40
pr-fix: tenant id
stijnmoreels Aug 15, 2024
a2d4cd3
pr-fix: sql
stijnmoreels Aug 15, 2024
790e0a3
pr-fix: sql
stijnmoreels Aug 15, 2024
5672f17
pr-fix: sql
stijnmoreels Aug 15, 2024
eb8fdc2
pr-fix: sql
stijnmoreels Aug 15, 2024
9741706
pr-fix: sql
stijnmoreels Aug 15, 2024
400b333
pr-fix: use server instance
stijnmoreels Aug 20, 2024
9881c7b
pr-fix: sql instance + connect graph
stijnmoreels Aug 20, 2024
ed73128
pr-fix: sql instance var
stijnmoreels Aug 20, 2024
fda2094
pr-fix: assign values ourselves
stijnmoreels Aug 20, 2024
75c4e55
pr-fix: secure string
stijnmoreels Aug 20, 2024
d5ed3c1
pr-fix: secure string
stijnmoreels Aug 20, 2024
ae0df86
pr-fix: secure string
stijnmoreels Aug 20, 2024
28bb833
pr-fix: apim rest permissions?
stijnmoreels Aug 20, 2024
c442348
pr-fix: activate all tests
stijnmoreels Aug 20, 2024
1f3fc27
pr-fix: remove commented-out sql tasks
stijnmoreels Aug 20, 2024
3e2ea06
pr-fix: skip both apim tests
stijnmoreels Aug 20, 2024
8e6e911
temp: re-activate apim tets
stijnmoreels Aug 27, 2024
0b9f3d9
Update Arcus.Scripting.DevOps.tests.ps1
stijnmoreels Aug 27, 2024
9660817
pr-fix: remove update ps tasks
stijnmoreels Aug 29, 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
8 changes: 7 additions & 1 deletion 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'
- name: 'UnitTests'
type: object
default:
Expand Down Expand Up @@ -62,9 +66,9 @@ resources:
variables:
- group: 'Build Configuration'
- group: 'Arcus Scripting - Integration Testing'
- group: 'Arcus - GitHub Package Registry'
- group: 'MyGet'
- template: ./variables/build.yml
- template: ./variables/test.yml
- name: 'Package.Version'
value: '0.$(Build.BuildNumber)'
- name: 'Prerelease'
Expand Down Expand Up @@ -111,6 +115,7 @@ stages:
parameters:
projectName: '$(Project).Tests.Unit'
testName: '$(Project).${{UnitTest.name}}'
azureServiceConnection: ${{ parameters.azureServiceConnection }}

- stage: IntegrationTests
displayName: Integration Tests
Expand Down Expand Up @@ -139,6 +144,7 @@ stages:
parameters:
projectName: '$(Project).Tests.Integration'
testName: '$(Project).${{IntegrationTest.name}}'
azureServiceConnection: ${{ parameters.azureServiceConnection }}

- stage: ReleaseToMyget
displayName: 'Release to MyGet'
Expand Down
78 changes: 78 additions & 0 deletions build/deploy-test-resources.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Arcus Scripting - 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-scripting-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.Linux.Image)'
steps:
- task: AzureCLI@2
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
inputs:
azureSubscription: '${{ parameters.azureServiceConnection }}'
addSpnToEnvironment: true
scriptType: 'pscore'
scriptLocation: 'inlineScript'
inlineScript: |
az deployment sub create `
--location westeurope `
--template-file ./build/templates/deploy-resource-group.bicep `
--parameters resourceGroupName=$env:ARCUS_SCRIPTING_RESOURCEGROUP_NAME `
--parameters location=westeurope

$objectId = (az ad sp show --id $env:servicePrincipalId | ConvertFrom-Json).id

$symbols = '!@#$%^&*=(),.?'.ToCharArray()
$characterList = 'a'..'z' + 'A'..'Z' + '0'..'9' + $symbols
function Gen-Password {
param($length)
do {
$password = ""
for ($i = 0; $i -lt $length; $i++) {
$randomIndex = [System.Security.Cryptography.RandomNumberGenerator]::GetInt32(0, $characterList.Length)
$password += $characterList[$randomIndex]
}

$hasLowerChar = $password -cmatch '[a-z]'
$hasUpperChar = $password -cmatch '[A-Z]'
$hasDigit = $password -match '[0-9]'
$hasSymbol = $password.IndexOfAny($symbols) -ne -1
}
until (($hasLowerChar + $hasUpperChar + $hasDigit + $hasSymbol) -ge 3)
$password
}

$sqlAdminPassword = Gen-Password 14
az deployment group create `
--resource-group $env:ARCUS_SCRIPTING_RESOURCEGROUP_NAME `
--template-file ./build/templates/deploy-test-resources.bicep `
--parameters location=westeurope `
--parameters keyVaultName=$env:ARCUS_SCRIPTING_KEYVAULT_NAME `
--parameters storageAccountName=$env:ARCUS_SCRIPTING_STORAGEACCOUNT_NAME `
--parameters appServiceName=$env:ARCUS_SCRIPTING_APPSERVICE_NAME `
--parameters sqlServerName=$env:ARCUS_SCRIPTING_SQL_SERVERNAME `
--parameters sqlDatabaseName=$env:ARCUS_SCRIPTING_SQL_DATABASENAME `
--parameters sqlAdminUserName=$env:ARCUS_SCRIPTING_SQL_USERNAME `
--parameters sqlAdminPassword=$sqlAdminPassword `
--parameters sqlAdminPassword_secretName=$env:ARCUS_SCRIPTING_SQL_PASSWORD_SECRETNAME `
--parameters integrationAccountName=$env:ARCUS_SCRIPTING_INTEGRATIONACCOUNT_NAME `
--parameters servicePrincipal_objectId=$objectId
7 changes: 7 additions & 0 deletions build/psgallery-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ parameters:
displayName: 'Prerelease string (ex. -alpha, -alpha1, -BETA, -update20171020) or none'
type: 'string'
default: 'none'
- name: azureServiceConnection
displayName: 'Azure service connection'
type: string
default: 'Azure Codit-Arcus Service Principal'
- name: 'UnitTests'
type: object
default:
Expand Down Expand Up @@ -56,6 +60,7 @@ variables:
- group: 'Arcus Scripting - Integration Testing'
- group: 'Arcus.Scripting - Releasing PS Gallery'
- template: ./variables/build.yml
- template: ./variables/test.yml
- name: 'Repository'
value: 'arcus-azure/arcus.scripting'
- name: 'Package.Version'
Expand Down Expand Up @@ -104,6 +109,7 @@ stages:
parameters:
projectName: '$(Project).Tests.Unit'
testName: '$(Project).${{UnitTest.name}}'
azureServiceConnection: ${{ parameters.azureServiceConnection }}

- stage: IntegrationTests
displayName: Integration Tests
Expand Down Expand Up @@ -132,6 +138,7 @@ stages:
parameters:
projectName: '$(Project).Tests.Integration'
testName: '$(Project).${{IntegrationTest.name}}'
azureServiceConnection: ${{ parameters.azureServiceConnection }}

- stage: Release
displayName: 'Release to PowerShell Gallery'
Expand Down
15 changes: 15 additions & 0 deletions build/templates/deploy-resource-group.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Define the name of the resource group.
param resourceGroupName string

// Define the location for the deployment of the components.
param location string

targetScope='subscription'

module resourceGroup 'br/public:avm/res/resources/resource-group:0.2.3' = {
name: 'resourceGroupDeployment'
params: {
name: resourceGroupName
location: location
}
}
155 changes: 155 additions & 0 deletions build/templates/deploy-test-resources.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
// Define the location for the deployment of the components.
param location string

// Define the name of the storage account that will be created.
param storageAccountName string

// Define the name of the Azure Functions app service that will be created.
param appServiceName string

// Define the name of the Azure SQL server instance that will be created.
param sqlServerName string

// Define the username of the administrator login for the Azure SQL server instance.
param sqlAdminUserName string

// Define the password of the administrator login for the Azure SQL server instance.
@secure()
param sqlAdminPassword string

// Define the Azure Key vault secret name of the administrator login password for the Azure SQL server instance.
param sqlAdminPassword_secretName string

// Define the name of the Azure SQL database that will be created within the Azure SQL server instance.
param sqlDatabaseName string

// Define the name of the integration account that will be created.
param integrationAccountName 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

module storageAccount 'br/public:avm/res/storage/storage-account:0.9.1' = {
name: 'storageAccountDeployment'
params: {
name: storageAccountName
location: location
allowBlobPublicAccess: true
publicNetworkAccess: 'Enabled'
networkAcls: {
bypass: 'AzureServices'
defaultAction: 'Allow'
ipRules: []
virtualNetworkRules: []
}
roleAssignments: [
{
principalId: servicePrincipal_objectId
roleDefinitionIdOrName: 'Storage Blob Data Contributor'
}
{
principalId: servicePrincipal_objectId
roleDefinitionIdOrName: 'Storage Table Data Contributor'
}
]
}
}

module serverfarm 'br/public:avm/res/web/serverfarm:0.2.2' = {
name: 'serverfarmDeployment'
params: {
name: '${appServiceName}-plan'
skuCapacity: 2
skuName: 'Y1'
location: location
}
}

module functionApp 'br/public:avm/res/web/site:0.3.9' = {
name: 'functionAppDeployment'
params: {
kind: 'functionapp'
name: appServiceName
serverFarmResourceId: serverfarm.outputs.resourceId
location: location
enableTelemetry: false
siteConfig: {
alwaysOn: false
}
}
}

module sqlServer 'br/public:avm/res/sql/server:0.4.1' = {
name: 'sqlServerDeployment'
params: {
name: sqlServerName
location: location
administratorLogin: sqlAdminUserName
administratorLoginPassword: sqlAdminPassword
enableTelemetry: false
publicNetworkAccess: 'Enabled'
restrictOutboundNetworkAccess: 'Disabled'
auditSettings: {
state: 'Disabled'
}
databases: [
{
name: sqlDatabaseName
skuName: 'Basic'
skuTier: 'Basic'
maxSizeBytes: 2147483648
}
]
}
}

resource integrationAccount 'Microsoft.Logic/integrationAccounts@2019-05-01' = {
name: integrationAccountName
location: location
properties: {
state: 'Enabled'
}
sku: {
name: 'Free'
}
}

module vault 'br/public:avm/res/key-vault/vault:0.6.1' = {
name: 'vaultDeployment'
params: {
name: keyVaultName
location: location
enableRbacAuthorization: false
sku: 'standard'
accessPolicies: [
{
objectId: servicePrincipal_objectId
permissions: {
secrets: [
'get', 'list', 'set', 'delete'
]
keys: [
'get', 'list', 'create', 'delete'
]
}
}
{
objectId: '0d926a02-88dc-4279-8265-fbcd8178ecb0' // (built-in) Azure Logic Apps service principal
permissions: {
keys: [
'list', 'get', 'decrypt', 'sign'
]
}
}
]
secrets: [
{
name: sqlAdminPassword_secretName
value: sqlAdminPassword
}
]
}
}
Loading