forked from geekzter/azure-minecraft-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeploy_functions.ps1
executable file
·44 lines (38 loc) · 1.45 KB
/
deploy_functions.ps1
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
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env pwsh
<#
.SYNOPSIS
Grants access to given AAD user/service principal name
#>
#Requires -Version 7
. (Join-Path $PSScriptRoot functions.ps1)
if (!(Get-Command func -ErrorAction SilentlyContinue)) {
Write-Warning "Azure Function Tools not found, exiting..."
exit
}
if (!(Get-Command dotnet -ErrorAction SilentlyContinue)) {
Write-Warning ".NET (Core) SDK not found, exiting..."
exit
}
try {
$tfdirectory=$(Join-Path (Split-Path -Parent -Path $PSScriptRoot) "terraform")
Push-Location $tfdirectory
AzLogin
$functionNames = (Get-TerraformOutput -OutputVariable "function_name" -ComplexType)
if (!($functionNames)) {
Write-Warning "Azure Function not found, has infrastructure been provisioned?"
exit
}
$subscriptionID = (Get-TerraformOutput "subscription_guid")
az account set -s $subscriptionID # Required as func ignores --subscription
$functionDirectory=$(Join-Path (Split-Path -Parent -Path $PSScriptRoot) "functions")
Push-Location $functionDirectory
foreach ($functionName in $functionNames) {
Write-Host "`nFetching settings for function ${functionName}..."
func azure functionapp fetch-app-settings $functionName --subscription $subscriptionID
Write-Host "`nPublishing to function ${functionName}..."
func azure functionapp publish $functionName -b local --subscription $subscriptionID
}
Pop-Location
} finally {
Pop-Location
}