Skip to content

Commit 185a7f9

Browse files
author
rvdwegen
committed
More explicit module imports
1 parent 928abeb commit 185a7f9

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

profile.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@ try {
1111
}
1212

1313
# Import modules
14+
$ModulesPath = Join-Path $PSScriptRoot 'Modules'
1415
$Modules = @('CIPPCore', 'CippExtensions', 'Az.Accounts', 'Az.KeyVault', 'AzBobbyTables')
1516
foreach ($Module in $Modules) {
1617
try {
17-
Import-Module -Name $Module -ErrorAction Stop
18+
Import-Module -Name (Join-Path $ModulesPath $Module) -ErrorAction Stop
1819
} catch {
1920
Write-LogMessage -message "Failed to import module - $Module" -LogData (Get-CippException -Exception $_) -Sev 'debug'
2021
Write-Error $_.Exception.Message
@@ -69,7 +70,7 @@ try {
6970
Write-LogMessage -message 'Could not retrieve keys from Keyvault' -LogData (Get-CippException -Exception $_) -Sev 'debug'
7071
}
7172

72-
$CurrentVersion = (Get-Content -Path "$($PSScriptRoot)\version_latest.txt" -Raw).Trim()
73+
$CurrentVersion = (Get-Content -Path (Join-Path $PSScriptRoot 'version_latest.txt') -Raw).Trim()
7374
$Table = Get-CippTable -tablename 'Version'
7475
Write-Information "Function App: $($env:WEBSITE_SITE_NAME) | API Version: $CurrentVersion | PS Version: $($PSVersionTable.PSVersion)"
7576
$global:CippVersion = $CurrentVersion

requirements.psd1

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
# This file enables modules to be automatically managed by the Functions service.
22
# See https://aka.ms/functionsmanageddependency for additional information.
33
#
4-
@{
5-
# For latest supported version, go to 'https://www.powershellgallery.com/packages/Az'.
6-
# To use the Az module in your function app, please uncomment the line below.
7-
'Az.accounts' = '2.*'
8-
'Az.Keyvault' = '3.*'
9-
'AzBobbyTables' = '2.*'
10-
}
4+
# CIPP bundles all modules locally in the Modules folder and imports them explicitly.
5+
# managedDependency is disabled in host.json - this file is intentionally empty.
6+
@{}

0 commit comments

Comments
 (0)