azure - 如何访问 Azure powershell Runbook 中的本地文件路径

标签 azure powershell azure-blob-storage azure-automation azure-runbook

团队,我正在尝试将文件从本地计算机上传到 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/

相关文章:

Azure 托管磁盘。访问底层 blob?

c# - 将多个文件上传到 Azure Blob 存储

azure - 使用 Azure 数据工厂中的复制数据工具导入由事件中心存档生成的 Avro 文件时出错

Azure SQL 数据库 : Can I share stored procedures between master DB and all DB's in the server?

azure - Azure WAF 中的自定义 IP 范围

java - 如何将 ADLS 帐户与 Azure VM 连接

wcf - 如何使用fdder2检查Windows Azure https请求

powershell - 根据列表替换 PSObj 属性值

winforms - 使用 PowerShell 访问 WebView2 中的 cookie

asp.net-mvc - PDFTron WebViewer - 尝试显示存储在 Azure BLOB 存储中的 XOD 文件时出现 CORS 错误