【发布时间】:2017-10-27 11:52:19
【问题描述】:
有没有办法使用 Azure 存储 Java API 确定存储帐户是 Blob 存储还是通用存储
【问题讨论】:
标签: java azure azure-storage azure-blob-storage
有没有办法使用 Azure 存储 Java API 确定存储帐户是 Blob 存储还是通用存储
【问题讨论】:
标签: java azure azure-storage azure-blob-storage
根据 Azure Storage REST API Create Storage Account(仅限版本 2016-01-01 及更高版本),您可以看到一个参数 kind 确定什么样的存储帐户(Storage 或 BlobStorage)在请求正文中创建。
为了使用Azure Storage Java API,有一个枚举类Kind包含两种存储账户,你可以通过@987654334的两个接口(@987654323@和WithBlobStorageAccountKind)选择你想要的一种@接口。
这是它们的常用用法。
通过define方法创建一个默认种类的存储账户,见完整示例代码here。
StorageAccount storageAccount = azure.storageAccounts().define(storageAccountName)
.withRegion(Region.US_EAST)
.withNewResourceGroup(rgName)
.create();
根据define方法的源码,默认的存储账户类型是Storage via WithGeneralPurposeAccountKind。
创建BlobStorage 种类的存储帐户。
StorageAccount storageAccount = azure.storageAccounts().define(storageAccountName)
.withBlobStorageAccountKind() // Set the kind as `BlobStorage`
.withRegion(Region.US_EAST)
.withNewResourceGroup(rgName)
.create();
【讨论】: