我正在尝试访问函数应用时间触发器中同一函数文件夹中的文件。我正在使用 Powershell 代码。
如何访问该文件
在 HTTP 触发器中,我可以通过执行此操作来访问同一文件夹中的脚本
$script_path = ".$($TriggerMetadata.FunctionName)\scriptfile.ps1"
但是,如果我使用时间触发函数,则这不起作用,因为触发函数时未传递 $TriggerMetadata。
我想要一种能够动态获取时间触发器的函数名称的方法,以便我可以访问同一文件夹中的脚本。
我该怎么做?
最佳答案
试试这个:
# Get the current directory path
$currentPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
# Construct the file path for your script
$scriptPath = Join-Path -Path $currentPath -ChildPath "scriptfile.ps1"
# Use the $scriptPath to access the file
关于azure - 获取Azure时间触发函数的当前函数名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76586356/