团队,我正在尝试将文件从本地计算机上传到 azure blob 存储帐户。我可以通过在本地电源 shell 中运行脚本来上传文件。但是,当我在 Azure Automation Power shell Runbook 中尝试相同的脚本时,出现错误。
Test-Path -Path 'D:\UploadFolder\Sample.txt' -- Returns True in local powershell while uploading
Test-Path -Path 'D:\UploadFolder\Sample.txt' -- Returns False in azure automation powershell runbook while uploading
错误:未找到驱动器“D”
我在 Runbook 中检查了以下代码,它返回 false。
Get-PSDrive -Name 'D' -- Return false
我的问题:
1) 我们如何访问 Runbook 中的任何本地文件路径?
2) 我们在 azure 中是否有任何 Blade 可以在自动化帐户本身中存储/创建文件? (此询问的目的是“我想在 Azure 自动化中手动/脚本方式创建文件,以向其中写入一些内容,然后在 Azure Blob 存储中上传相同的文件。)
提前致谢
最佳答案
您无法通过 Azure 自动化访问本地系统文件。如果您有键值之类的小信息,请存储在Azure自动化变量部分
//获取Automation PowerShell脚本中的变量值
$cosmosDbAccountName = Get-AutomationVariable -Name 'CosmosDbAccountName'
$databaseName = Get-AutomationVariable -Name 'DatabaseName'
选项 1
您可以上传 blob 格式的文件并从 Azure 自动化脚本读取 blob。
选项 2
您可以使用WebJob(应用服务)运行PowerShell脚本,并且可以在WebJob中上传脚本和文件。
关于azure - 如何访问 Azure powershell Runbook 中的本地文件路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61115904/