forked from KelvinTegelaar/CIPP-API
-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.ps1
41 lines (35 loc) · 1.38 KB
/
profile.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
# Azure Functions profile.ps1
#
# This profile.ps1 will get executed every "cold start" of your Function App.
# "cold start" occurs when:
#
# * A Function App starts up for the very first time
# * A Function App starts up after being de-allocated due to inactivity
#
# You can define helper functions, run commands, or specify environment variables
# NOTE: any variables defined that are not environment variables will get reset after the first execution
# Authenticate with Azure PowerShell using MSI.
# Remove this if you are not planning on using MSI or Azure PowerShell.
# Import modules
@('CippCore','CippExtensions','Az.KeyVault','Az.Accounts') | ForEach-Object {
try {
Import-Module -Name $_ -ErrorAction Stop
} catch {
Write-LogMessage -message "Failed to import module $($_): $_.Exception.Message" -Sev 'CRITICAL'
$_.Exception.Message
}
}
try {
Disable-AzContextAutosave -Scope Process | Out-Null
} catch {}
try {
if (!$ENV:SetFromProfile) {
Write-Host "We're reloading from KV"
$Auth = Get-CIPPAuthentication
}
} catch {
Write-LogMessage -message "Could not retrieve keys from Keyvault: $($_.Exception.Message)" -Sev 'CRITICAL'
}
# Uncomment the next line to enable legacy AzureRm alias in Azure PowerShell.
# Enable-AzureRmAlias
# You can also define functions or aliases that can be referenced in any of your PowerShell functions.