Skip to content

Commit

Permalink
Optimize module loading performance (#484)
Browse files Browse the repository at this point in the history
  • Loading branch information
PlagueHO authored May 19, 2024
1 parent a83196e commit 91a3622
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added new utillity function `Get-CosmosDbAuthorizationHeaderFromContextEntraId` to generate the authorization
header when an Entra ID Token is provided in the context. This function is used by `Invoke-CosmosDbRequest` to
generate the authorization header when an Entra ID Token is provided.
- Changed module import process to load the `Az.Accounts` and `Az.Resources` modules
only if they haven't already been loaded to support saving the module and storing in
folders.

### Added

Expand Down
13 changes: 10 additions & 3 deletions source/prefix.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,16 @@ $script:moduleRoot = Split-Path `
-Path $MyInvocation.MyCommand.Path `
-Parent

# Import dependent Az modules
Import-Module -Name Az.Accounts -MinimumVersion 2.19.0 -Scope Global
Import-Module -Name Az.Resources -MinimumVersion 6.16.2 -Scope Global
# Import dependent Az modules ifthey are not already imported
if (-not (Get-Module -Name Az.Accounts))
{
Import-Module -Name Az.Accounts -MinimumVersion 2.19.0 -Scope Global
}

if (-not (Get-Module -Name Az.Resources))
{
Import-Module -Name Az.Resources -MinimumVersion 6.16.2 -Scope Global
}

#region LocalizedData
$culture = $PSUICulture
Expand Down

0 comments on commit 91a3622

Please sign in to comment.