I am trying to access files in the same function folder in a function app time trigger. I am using Powershell code.
How do I access the file
In an HTTP trigger I was able to access the script in the same folder by doing this
$script_path = ".$($TriggerMetadata.FunctionName)scriptfile.ps1"
However, this does not work if I am using a time trigger function as the $TriggerMetadata is not being passed when the function is triggered.
I want a way to be able to get the function name of the time trigger dynamically so I can access the script in the same folder.
How can I do this?
2
Answers
Try this:
If you are using Functions V2, You can get the function directory via
$PSScriptRoot
variable which is documented here.For Functions V1, You can use the
EXECUTION_CONTEXT_FUNCTIONDIRECTORY
environment variable to access the function directory.