How to access local file path in Azure power shell 运行 一书

How to access local file path in Azure power shell Run book

团队成员,我正在尝试将文件从本地计算机上传到 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 中检查了以下代码,其中 return 错误。

Get-PSDrive -Name 'D' -- Return false

我的问题:

1) 我们如何访问 runbook 中的任何本地文件路径?

2) Automation Account 本身是否有任何 blade 到 store/create 的文件?。 (这个问题的目的是“我想在 azure 自动化中创建文件 manually/script 明智地向其中写入一些内容,然后在 Azure blob 存储中上传相同的文件。)

提前致谢

您无法通过 Azure 自动化访问您的本地系统文件。如果你有像键值这样的小信息,你存储在 Azure 自动化变量部分

//在 Automation PowerShell 脚本中获取变量值

$cosmosDbAccountName = Get-AutomationVariable -Name 'CosmosDbAccountName'
$databaseName = Get-AutomationVariable -Name 'DatabaseName'

选项 1

您可以在 blob 中上传文件并从 Azure Automation Script 中读取 blob。

选项 2

您可以将 WebJob(应用服务)用于 运行 PowerShell 脚本,您可以在 WebJob 中上传脚本和文件。