【问题标题】:Azure: find if storage is general purpose or blob storage using storage APIAzure:使用存储 API 查找存储是通用存储还是 blob 存储
【发布时间】:2017-10-27 11:52:19
【问题描述】:

有没有办法使用 Azure 存储 Java API 确定存储帐户是 Blob 存储还是通用存储

【问题讨论】:

    标签: java azure azure-storage azure-blob-storage


    【解决方案1】:

    根据 Azure Storage REST API Create Storage Account(仅限版本 2016-01-01 及更高版本),您可以看到一个参数 kind 确定什么样的存储帐户(StorageBlobStorage)在请求正文中创建。

    为了使用Azure Storage Java API,有一个枚举类Kind包含两种存储账户,你可以通过@987654334的两个接口(@98​​7654323@和WithBlobStorageAccountKind)选择你想要的一种@接口。

    这是它们的常用用法。

    1. 通过define方法创建一个默认种类的存储账户,见完整示例代码here

      StorageAccount storageAccount = azure.storageAccounts().define(storageAccountName)
                      .withRegion(Region.US_EAST)
                      .withNewResourceGroup(rgName)
                      .create();
      

      根据define方法的源码,默认的存储账户类型是Storage via WithGeneralPurposeAccountKind

    2. 创建BlobStorage 种类的存储帐户。

      StorageAccount storageAccount = azure.storageAccounts().define(storageAccountName)
                          .withBlobStorageAccountKind() // Set the kind as `BlobStorage`
                          .withRegion(Region.US_EAST)
                          .withNewResourceGroup(rgName)
                          .create();
      

    【讨论】:

    • 这根本不能回答问题。 OP 询问的是如何获取现有存储帐户的类型,而不是如何创建特定类型的新帐户。
    猜你喜欢
    • 2015-08-05
    • 1970-01-01
    • 2011-02-08
    • 2013-07-05
    • 2017-11-10
    • 2012-11-20
    • 2019-05-01
    • 2020-06-04
    • 2011-01-14
    相关资源
    最近更新 更多