【问题标题】:How to implement batch operations with storage如何使用存储实现批量操作
【发布时间】:2019-12-15 05:14:55
【问题描述】:

我们使用 Azure CLI 编写脚本来删除存储帐户容器的内容并将目录的内容上传到容器

az storage blob delete-batch --account-name $ACCOUNT_NAME --source $web
az storage blob upload-batch --account-name $ACCOUNT_NAME -s $SOURCE_PATH -d $web

现在,我们想在 Azure 上托管脚本。根据我们的搜索,我们不能直接在 Azure 上托管 Azure CLI 脚本,我们必须将脚本迁移到 powershell。但是我们找不到类似的 powershell 命令。有人可以帮助我吗?

【问题讨论】:

    标签: azure powershell


    【解决方案1】:

    在撰写此答案时,Azure PowerShell 的当前版本是 3.1 (https://docs.microsoft.com/en-us/powershell/module/az.storage/?view=azps-3.1.0#storage),不幸的是,那里不支持对 blob 的批处理操作。

    因此,从 3.1 版开始,无法使用 Azure PowerShell Cmdlet 对 blob 执行批处理操作。

    您的一个选择是使用Azure Storage Blobs Batch client library for .NET。您可以编写 PowerShell 脚本,利用此库对 blob 执行批处理操作。您可以在此处找到更多信息和代码示例:https://github.com/Azure/azure-sdk-for-net/blob/master/sdk/storage/Azure.Storage.Blobs.Batch/README.md

    其他选项是使用 REST API。同样,您可以编写 PowerShell 脚本来发出 HTTP 请求以对您的存储帐户执行批处理操作。您可以在此处找到有关 REST API 的更多信息:https://docs.microsoft.com/en-us/rest/api/storageservices/blob-batch

    P.S:我会包含代码,但不幸的是我在 PowerShell 方面的知识非常有限:)。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-03
      • 1970-01-01
      • 2019-11-28
      • 2019-12-15
      • 2023-01-19
      相关资源
      最近更新 更多