[团队,我正在尝试从本地计算机上载文件到Azure Blob存储帐户。我可以通过在本地Power 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)我们是否有天蓝色的刀片可以在Automation Account本身中存储/创建文件? (此询问的目的是“我想手动/以脚本方式在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中上载脚本和文件。