Az module not loading when adding custom ,odules in Azure Function - Runs ok in Local Azure Function Core Tools but not when deployed to Azure Environment
miniGweek opened this issue · 1 comments
Issue Description
I have a simple HTTP-triggered Azure Function with PowerShell where I am loading a simple custom-developed PowerShell module.
I have enabled the managedDependency to true and enabled the Az.Accounts module in the requirements.psd1 file.
Here's the solution folder structure
Function Folder
| .funcignore
| .gitignore
| host.json
| local.settings.json
| profile.ps1
| requirements.psd1
|
+---.vscode
| extensions.json
| launch.json
| settings.json
| tasks.json
|
+---AutoStartStop
| function.json
| run.ps1
| sample.dat
|
\---Modules
\---DevDebug
DevDebug.psd1
DevDebug.psm1
Using the Azure function core tools, I can run the function locally.
I can list subscriptions using Get-AzSubscription and also execute the custom function that's in my custom module.
Once I deploy it to Azure Environment, I can see that Azure Function fails to load the Az.Accounts module and after that, it fails to use the MSI to login to the Azure Environment. Also subsequently the Get-AzSubscription command fails with error ERROR: The term 'Get-AzSubscription' is not recognized as a name of a cmdlet, function, script file, or executable program.
When I disable my custom PowerShell module in the requirements.psd1 file - Az.Accounts module loads, and the Azure PowerShell module function works fine. What I am doing wrong?
Runtime Details
FUNCTIONS_EXTENSION_VERSION=~4
FUNCTIONS_WORKER_RUNTIME=powershell
PowerShell Core Version set to 7.2
Code
The source code is in the repository https://github.com/miniGweek/azure-function-powershell-custom-modules/
host.json
{
"version": "2.0",
"logging": {
"applicationInsights": {
"samplingSettings": {
"isEnabled": true,
"excludedTypes": "Request"
}
}
},
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[3.*, 4.0.0)"
},
"managedDependency": {
"enabled": true
}
}run.ps1 - Entry point for the HTTP Triggerred function
using namespace System.Net
# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
$OutPutLogs = @();
Function Log($Text) {
Write-Host $Text
return $Text
}
$OutPutLogs += Log "List modules loaded."
Get-Module
$OutPutLogs += Log "List modules loaded. -ListAvailable switch"
Get-Module -ListAvailable
$OutPutLogs += Log "Import Az.Accounts"
Import-Module Az.Accounts
$OutPutLogs += Log "Invoke Get-AzSubscription"
Get-AzSubscription
$OutPutLogs += Log "Invoke DevDebug.Get-LocalHelp"
Get-LocalHelp
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = [HttpStatusCode]::OK
Body = $OutPutLogs
})
requirements.psd1
@{
'Az.Accounts' = '2.*'
DevDebug = '1.0.0'
}
profile.ps1
if ($env:MSI_SECRET) {
Disable-AzContextAutosave -Scope Process | Out-Null
Connect-AzAccount -Identity
}
Modules directory
Folder DevDebug
DevDebug.psd1 Manifest file
#
# Module manifest for module 'Debug'
#
# Generated by: Rahul Sarkar
#
# Generated on: 29/09/2023
#
@{
# Script module or binary module file associated with this manifest.
RootModule = 'DevDebug.psm1'
# Version number of this module.
ModuleVersion = '1.0.0'
# Supported PSEditions
CompatiblePSEditions = @('Core')
# ID used to uniquely identify this module
GUID = 'c2748df4-4e2e-403a-a2cb-e1afdecd727f'
# Author of this module
Author = 'DevOps Team'
# Company or vendor of this module
CompanyName = 'miniGweek'
# Copyright statement for this module
# Copyright = '(c) Rahul Sarkar. All rights reserved.'
# Description of the functionality provided by this module
Description = 'Debug Azure Function with PowerShell + Custom Module.'
# Minimum version of the PowerShell engine required by this module
PowerShellVersion = '7.0'
# Name of the PowerShell host required by this module
# PowerShellHostName = ''
# Minimum version of the PowerShell host required by this module
# PowerShellHostVersion = ''
# Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# DotNetFrameworkVersion = ''
# Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only.
# ClrVersion = ''
# Processor architecture (None, X86, Amd64) required by this module
# ProcessorArchitecture = ''
# Modules that must be imported into the global environment prior to importing this module
# RequiredModules = @('Az.Accounts','Az.Resources', 'Az.Compute')
# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
# Script files (.ps1) that are run in the caller's environment prior to importing this module.
# ScriptsToProcess = @()
# Type files (.ps1xml) to be loaded when importing this module
# TypesToProcess = @()
# Format files (.ps1xml) to be loaded when importing this module
# FormatsToProcess = @()
# Modules to import as nested modules of the module specified in RootModule/ModuleToProcess
# NestedModules = @()
# Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export.
FunctionsToExport = @(
'Get-LocalHelp'
)
# Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export.
CmdletsToExport = '*'
# Variables to export from this module
VariablesToExport = '*'
# Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export.
AliasesToExport = '*'
# DSC resources to export from this module
# DscResourcesToExport = @()
# List of all modules packaged with this module
# ModuleList = @()
# List of all files packaged with this module
# FileList = @()
# Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell.
PrivateData = @{
PSData = @{
# Tags applied to this module. These help with module discovery in online galleries.
# Tags = @()
# A URL to the license for this module.
# LicenseUri = ''
# A URL to the main website for this project.
# ProjectUri = ''
# A URL to an icon representing this module.
# IconUri = ''
# ReleaseNotes of this module
# ReleaseNotes = ''
# Prerelease string of this module
# Prerelease = ''
# Flag to indicate whether the module requires explicit user acceptance for install/update/save
# RequireLicenseAcceptance = $false
# External dependent modules of this module
# ExternalModuleDependencies = @('Az.Accounts','Az.Resources', 'Az.Compute')
} # End of PSData hashtable
} # End of PrivateData hashtable
# HelpInfo URI of this module
# HelpInfoURI = ''
# Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix.
# DefaultCommandPrefix = ''
}DevDebug.psm1 Module file
Function Get-LocalHelp{
Write-Host "Help! I ran!"
}Error Text
2023-09-29T08:05:24Z [Warning] The Function app may be missing a module containing the 'Disable-AzContextAutosave' command definition. If this command belongs to a module available on the PowerShell Gallery, add a reference to this module to requirements.psd1. Make sure this module is compatible with PowerShell 7. For more details, see https://aka.ms/functions-powershell-managed-dependency. If the module is installed but you are still getting this error, try to import the module explicitly by invoking Import-Module just before the command that produces the error: this will not fix the issue but will expose the root cause.
2023-09-29T08:05:26Z [Error] ERROR: The term 'Disable-AzContextAutosave' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Exception :
Type : System.Management.Automation.CommandNotFoundException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : The term 'Disable-AzContextAutosave' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
HResult : -2146233087
TargetObject : Disable-AzContextAutosave
CategoryInfo : ObjectNotFound: (Disable-AzContextAutosave:String) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : CommandNotFoundException
InvocationInfo :
ScriptLineNumber : 15
OffsetInLine : 5
HistoryId : 1
ScriptName : /home/site/wwwroot/profile.ps1
Line : Disable-AzContextAutosave -Scope Process | Out-Null
PositionMessage : At /home/site/wwwroot/profile.ps1:15 char:5
+ Disable-AzContextAutosave -Scope Process | Out-Null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : /home/site/wwwroot
PSCommandPath : /home/site/wwwroot/profile.ps1
InvocationName : Disable-AzContextAutosave
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, /home/site/wwwroot/profile.ps1: line 15
CommandName : Disable-AzContextAutosave
TargetSite :
Name : LookupCommandInfo
DeclaringType : System.Management.Automation.CommandDiscovery, System.Management.Automation, Version=7.2.13.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
MemberType : Method
Module : System.Management.Automation.dll
Message : The term 'Disable-AzContextAutosave' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Data : System.Collections.ListDictionaryInternal
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin, ExecutionContext context)
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)
at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)
at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject : Disable-AzContextAutosave
CategoryInfo : ObjectNotFound: (Disable-AzContextAutosave:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
InvocationInfo :
ScriptLineNumber : 15
OffsetInLine : 5
HistoryId : 1
ScriptName : /home/site/wwwroot/profile.ps1
Line : Disable-AzContextAutosave -Scope Process | Out-Null
PositionMessage : At /home/site/wwwroot/profile.ps1:15 char:5
+ Disable-AzContextAutosave -Scope Process | Out-Null
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : /home/site/wwwroot
PSCommandPath : /home/site/wwwroot/profile.ps1
InvocationName : Disable-AzContextAutosave
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, /home/site/wwwroot/profile.ps1: line 15
2023-09-29T08:05:26Z [Warning] The Function app may be missing a module containing the 'Connect-AzAccount' command definition. If this command belongs to a module available on the PowerShell Gallery, add a reference to this module to requirements.psd1. Make sure this module is compatible with PowerShell 7. For more details, see https://aka.ms/functions-powershell-managed-dependency. If the module is installed but you are still getting this error, try to import the module explicitly by invoking Import-Module just before the command that produces the error: this will not fix the issue but will expose the root cause.
2023-09-29T08:05:26Z [Error] ERROR: The term 'Connect-AzAccount' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Exception :
Type : System.Management.Automation.CommandNotFoundException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : The term 'Connect-AzAccount' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
HResult : -2146233087
TargetObject : Connect-AzAccount
CategoryInfo : ObjectNotFound: (Connect-AzAccount:String) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : CommandNotFoundException
InvocationInfo :
ScriptLineNumber : 16
OffsetInLine : 5
HistoryId : 1
ScriptName : /home/site/wwwroot/profile.ps1
Line : Connect-AzAccount -Identity
PositionMessage : At /home/site/wwwroot/profile.ps1:16 char:5
+ Connect-AzAccount -Identity
+ ~~~~~~~~~~~~~~~~~
PSScriptRoot : /home/site/wwwroot
PSCommandPath : /home/site/wwwroot/profile.ps1
InvocationName : Connect-AzAccount
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, /home/site/wwwroot/profile.ps1: line 16
CommandName : Connect-AzAccount
TargetSite :
Name : LookupCommandInfo
DeclaringType : System.Management.Automation.CommandDiscovery, System.Management.Automation, Version=7.2.13.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
MemberType : Method
Module : System.Management.Automation.dll
Message : The term 'Connect-AzAccount' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Data : System.Collections.ListDictionaryInternal
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin, ExecutionContext context)
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)
at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)
at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject : Connect-AzAccount
CategoryInfo : ObjectNotFound: (Connect-AzAccount:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
InvocationInfo :
ScriptLineNumber : 16
OffsetInLine : 5
HistoryId : 1
ScriptName : /home/site/wwwroot/profile.ps1
Line : Connect-AzAccount -Identity
PositionMessage : At /home/site/wwwroot/profile.ps1:16 char:5
+ Connect-AzAccount -Identity
+ ~~~~~~~~~~~~~~~~~
PSScriptRoot : /home/site/wwwroot
PSCommandPath : /home/site/wwwroot/profile.ps1
InvocationName : Connect-AzAccount
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, /home/site/wwwroot/profile.ps1: line 16
2023-09-29T08:05:26Z [Error] Errors reported while executing profile.ps1. See logs for detailed errors. Profile location: /home/site/wwwroot/profile.ps1.
2023-09-29T08:05:27Z [Information] INFORMATION: List modules loaded.
2023-09-29T08:05:27Z [Information] OUTPUT:
2023-09-29T08:05:27Z [Information] OUTPUT: ModuleType Version PreRelease Name ExportedCommands
2023-09-29T08:05:27Z [Information] OUTPUT: ---------- ------- ---------- ---- ----------------
2023-09-29T08:05:27Z [Information] OUTPUT: Manifest 0.3.0 Microsoft.Azure.Functions.PowerShe… {Get-DurableTaskResult, Get-OutputBinding, Invoke-…
2023-09-29T08:05:27Z [Information] INFORMATION: List modules loaded. -ListAvailable switch
2023-09-29T08:05:27Z [Information] OUTPUT: Manifest 7.0.0.0 Microsoft.PowerShell.Host {Start-Transcript, Stop-Transcript}
2023-09-29T08:05:27Z [Information] OUTPUT: Manifest 7.0.0.0 Microsoft.PowerShell.Management {Add-Content, Clear-Content, Clear-ItemProperty, J…
2023-09-29T08:05:27Z [Information] OUTPUT: Manifest 7.0.0.0 Microsoft.PowerShell.Security {Get-Credential, Get-ExecutionPolicy, Set-Executio…
2023-09-29T08:05:27Z [Information] OUTPUT: Manifest 7.0.0.0 Microsoft.PowerShell.Utility {Export-Alias, Get-Alias, Import-Alias, New-Alias…}
2023-09-29T08:05:27Z [Information] OUTPUT: Script 1.0.0 DevDebug Get-LocalHelp
2023-09-29T08:05:27Z [Information] OUTPUT: Manifest 0.3.0 Microsoft.Azure.Functions.PowerShe… {Get-OutputBinding, Get-DurableTaskResult, Invoke-…
2023-09-29T08:05:27Z [Information] OUTPUT: Manifest 1.2.5 Microsoft.PowerShell.Archive {Compress-Archive, Expand-Archive}
2023-09-29T08:05:27Z [Information] OUTPUT: Script 1.4.8.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, G…
2023-09-29T08:05:27Z [Information] OUTPUT: Script 1.4.7 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, G…
2023-09-29T08:05:27Z [Information] OUTPUT: Script 2.2.5 PowerShellGet {Find-Command, Find-DSCResource, Find-Module, Find…
2023-09-29T08:05:27Z [Information] OUTPUT: Binary 2.0.3 ThreadJob Start-ThreadJob
2023-09-29T08:05:27Z [Information] INFORMATION: Import Az.Accounts
2023-09-29T08:05:28Z [Warning] The Function app may be missing the 'Az.Accounts' module. If 'Az.Accounts' is available on the PowerShell Gallery, add a reference to this module to requirements.psd1. Make sure this module is compatible with PowerShell 7. For more details, see https://aka.ms/functions-powershell-managed-dependency.
2023-09-29T08:05:28Z [Error] ERROR: The specified module 'Az.Accounts' was not loaded because no valid module file was found in any module directory.
Exception :
Type : System.IO.FileNotFoundException
Message : The specified module 'Az.Accounts' was not loaded because no valid module file was found in any module directory.
HResult : -2147024894
TargetObject : Az.Accounts
CategoryInfo : ResourceUnavailable: (Az.Accounts:String) [Import-Module], FileNotFoundException
FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
InvocationInfo :
MyCommand : Import-Module
ScriptLineNumber : 20
OffsetInLine : 1
HistoryId : 1
ScriptName : /home/site/wwwroot/AutoStartStop/run.ps1
Line : Import-Module Az.Accounts
PositionMessage : At /home/site/wwwroot/AutoStartStop/run.ps1:20 char:1
+ Import-Module Az.Accounts
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
PSScriptRoot : /home/site/wwwroot/AutoStartStop
PSCommandPath : /home/site/wwwroot/AutoStartStop/run.ps1
InvocationName : Import-Module
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, /home/site/wwwroot/AutoStartStop/run.ps1: line 20
PipelineIterationInfo :
2023-09-29T08:05:28Z [Information] INFORMATION: Invoke Get-AzSubscription
2023-09-29T08:05:28Z [Warning] The Function app may be missing a module containing the 'Get-AzSubscription' command definition. If this command belongs to a module available on the PowerShell Gallery, add a reference to this module to requirements.psd1. Make sure this module is compatible with PowerShell 7. For more details, see https://aka.ms/functions-powershell-managed-dependency. If the module is installed but you are still getting this error, try to import the module explicitly by invoking Import-Module just before the command that produces the error: this will not fix the issue but will expose the root cause.
2023-09-29T08:05:28Z [Error] ERROR: The term 'Get-AzSubscription' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Exception :
Type : System.Management.Automation.CommandNotFoundException
ErrorRecord :
Exception :
Type : System.Management.Automation.ParentContainsErrorRecordException
Message : The term 'Get-AzSubscription' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
HResult : -2146233087
TargetObject : Get-AzSubscription
CategoryInfo : ObjectNotFound: (Get-AzSubscription:String) [], ParentContainsErrorRecordException
FullyQualifiedErrorId : CommandNotFoundException
InvocationInfo :
ScriptLineNumber : 23
OffsetInLine : 1
HistoryId : 1
ScriptName : /home/site/wwwroot/AutoStartStop/run.ps1
Line : Get-AzSubscription
PositionMessage : At /home/site/wwwroot/AutoStartStop/run.ps1:23 char:1
+ Get-AzSubscription
+ ~~~~~~~~~~~~~~~~~~
PSScriptRoot : /home/site/wwwroot/AutoStartStop
PSCommandPath : /home/site/wwwroot/AutoStartStop/run.ps1
InvocationName : Get-AzSubscription
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, /home/site/wwwroot/AutoStartStop/run.ps1: line 23
CommandName : Get-AzSubscription
TargetSite :
Name : LookupCommandInfo
DeclaringType : System.Management.Automation.CommandDiscovery, System.Management.Automation, Version=7.2.13.500, Culture=neutral, PublicKeyToken=31bf3856ad364e35
MemberType : Method
Module : System.Management.Automation.dll
Message : The term 'Get-AzSubscription' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Data : System.Collections.ListDictionaryInternal
Source : System.Management.Automation
HResult : -2146233087
StackTrace :
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin, ExecutionContext context)
at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)
at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)
at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)
at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
TargetObject : Get-AzSubscription
CategoryInfo : ObjectNotFound: (Get-AzSubscription:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
InvocationInfo :
ScriptLineNumber : 23
OffsetInLine : 1
HistoryId : 1
ScriptName : /home/site/wwwroot/AutoStartStop/run.ps1
Line : Get-AzSubscription
PositionMessage : At /home/site/wwwroot/AutoStartStop/run.ps1:23 char:1
+ Get-AzSubscription
+ ~~~~~~~~~~~~~~~~~~
PSScriptRoot : /home/site/wwwroot/AutoStartStop
PSCommandPath : /home/site/wwwroot/AutoStartStop/run.ps1
InvocationName : Get-AzSubscription
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, /home/site/wwwroot/AutoStartStop/run.ps1: line 23
2023-09-29T08:05:28Z [Information] INFORMATION: Invoke KalliprDebug.Get-LocalHelp
2023-09-29T08:05:28Z [Information] INFORMATION: Help! I ran!
2023-09-29T08:05:28Z [Information] OUTPUT:
2023-09-29T08:05:28Z [Information] Executed 'Functions.AutoStartStop' (Succeeded, Id=6fbfac04-9b6f-4f31-a65e-2eb89dffa077, Duration=5202ms)
This is resolved.
Custom written modules that's packaged and deployed as part of the .\Modules directory, are auto loaded by the Azure Function Runtime. Should not be added to the functions' requirements.psd1 file.
MS Should probably make a note of this in the azure docs.