【问题标题】:how can i make a text file on azure blob storage by using PowerShell Runbook?如何使用 PowerShell Runbook 在 azure blob 存储上创建文本文件?
【发布时间】:2021-12-12 16:47:12
【问题描述】:

我正在使用 Azure 并尝试通过 PowerShell Runbook 在 azure blob strage 上创建一个文本文件,如下所示: echo "test" > test.txt

但我不能。我认为Set-AzStorageBlobContent 这样做很好,但我不知道应该指定哪些参数。

以下命令行应该添加哪些参数?

$ctx = New-AzStorageContext -StorageAccountName "test123" -UseConnectedAccount
Set-AzStorageBlobContent -Container "test_files" -Context $ctx (what should I add here?)

【问题讨论】:

  • 你在哪里运行 PowerShell?您希望在哪里创建文件?请向我们提供足够的(相关)信息并参考How to Ask。主题:查看Set-AzStorageBlobContent documentation
  • 您是否尝试从 blob 存储创建 txt 文件?你到底在找什么?能否请您提供更多详细信息
  • 我正在 PowerShell Runbook 上运行 powershell。
  • 我的老板要求我在 blob strage 上创建一个文件,而不是创建一个物理文件。我需要直接从变量中制作 bolb 文件。

标签: azure powershell azure-blob-storage


【解决方案1】:

您首先需要创建一个临时文件,因为Set-AzStorageBlobContent 命令需要一个文件。

Set-AzStorageBlobContent -Container "ContosoUpload" -File ".\PlanningData" -Blob "Planning2015"

如果您需要创建临时文件作为 Runbook 逻辑的一部分,您可以使用 Azure 沙盒中的 Temp 文件夹(即$env:TEMP)来存储在 Azure 中运行的 Runbook。唯一的限制是您不能使用超过 1 GB 的磁盘空间,这是每个沙盒的配额。在使用 PowerShell 工作流时,这种情况可能会导致问题,因为 PowerShell 工作流使用检查点,并且可以在不同的沙箱中重试脚本。

https://docs.microsoft.com/en-us/azure/automation/automation-runbook-execution#temporary-storage-in-a-sandbox

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-11
    • 2021-11-07
    • 2014-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-31
    相关资源
    最近更新 更多