-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.ps1
More file actions
33 lines (27 loc) · 1.05 KB
/
deploy.ps1
File metadata and controls
33 lines (27 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[CmdletBinding()]
param (
$TenantId,
$SubscriptionId,
$Location = 'West Europe',
[switch]
$WhatIf
)
if ($PSScriptRoot.Contains(' ') -and $PSScriptRoot -ne $PWD) {
throw "This script needs to be executed from inside its folder because white spaces where detected."
}
$root = $PSScriptRoot.Contains(' ') ? '.' : $PSScriptRoot
Write-Host "Retrieving DEVDEER options from AKV and writing to $root/bicepSettings.json..."
$targetFileUri = "$root/bicepSettings.json"
$tmpFileUri = "$root/tmp.json"
Copy-Item $targetFileUri $tmpFileUri -Force
Get-AzKeyVaultSecret -VaultName akv-devdeer -Name SpockBicepSettings -AsPlainText | ConvertFrom-Json | ConvertTo-Json | Set-Content $targetFileUri
Write-Host "Settings retrieved."
$templateFile = "$root\main.bicep"
$templateParameterFile = "$root\parameters.json"
Set-AzdSubscriptionContext -TenantId $TenantId `
-SubscriptionId $SubscriptionId
New-AzDeployment -Location $Location `
-TemplateFile $templateFile `
-TemplateParameterFile $templateParameterFile `
-WhatIf:$WhatIf
Move-Item $tmpFileUri $targetFileUri -Force