【问题标题】:Uploading A File To A Folder In An Azure Blob Container Using Powershell使用 Powershell 将文件上传到 Azure Blob 容器中的文件夹
【发布时间】:2020-08-05 18:45:42
【问题描述】:

我需要将文件上传到 blob 容器内的文件夹(BlobContainer\Files\ 其中BlobContainer 是容器名称,Files 是容器内的文件夹),但是当我将它传递到 @987654324 @ 参数,它失败是因为它找不到那个 blob 容器。有没有办法在使用Set-AzureStorageBlobContent 上传文件时在 blob 容器中指定一个特定文件夹,或者如果没有,另一种方法可以做到这一点?

以下是我登录后调用的sn-p:

$storageacct = New-AzureStorageContext -ConnectionString "CONNECTIONSTRING"
Set-AzureStorageBlobContent -File "E:\Files\file.txt" -Container "BlobContainer" -Context $storageacct

【问题讨论】:

    标签: azure powershell


    【解决方案1】:

    在 Azure 存储中,您没有文件夹。在容器内,您上传 Blob。您可以为 blob 名称添加一个“前缀”,从而给出以下文件夹的概念:

    $containerName = "blobcontainer"
    New-AzStorageContainer -Name $containerName -Context $ctx -Permission blob
    
    # upload a file
    Set-AzStorageBlobContent -File "D:\_TestImages\Image001.jpg" `
      -Container $containerName `
      -Blob "Foldername/Image003.jpg" `
      -Context $ctx 
    

    【讨论】:

      猜你喜欢
      • 2021-03-05
      • 2022-01-12
      • 2020-02-17
      • 2022-11-30
      • 1970-01-01
      • 2019-01-20
      • 2021-04-30
      • 1970-01-01
      • 2018-01-10
      相关资源
      最近更新 更多