通过存储 uri 获取 azure 订阅 ID

Get azure subscription id by storage uri

我需要检查提供的 blob 是否已分配给租户 ID 所代表的组织。 提供的资料是: - 存储 URI - SAS 令牌

我的解决方案是列出组织内的所有订阅,获取提供的 blob 的订阅并找到匹配项。

问题是,在 Azure SDK 中我找不到任何获取订阅信息的方法。

我可以列出有关我的存储帐户的属性的唯一方法是通过 运行 命令使用 azure CLI

az storage account show

有没有什么办法可以得到这些参数的订阅信息? 如果没有,你能建议我一些检查 blob 归属感的解决方案吗?

在您的情况下,您需要拥有租户中所有订阅的权限(例如,您是订阅的 owners)。

我的解决方法是调用 REST API Subscriptions - List in java(seems there is no sdk to list subscriptions), to call the rest api in java, you could refer to this link.

然后List resource groups in every subscription, after that you can List all storage accounts in a resource group。然后检查存储帐户是否存在。

Could you recommend me some other solution to confirm blob belongingness? Maybe I need more input data? If so, what kind of data?

首先,您的目的是反向搜索,所以我们无法知道订阅、资源组。所以我们无法知道有关存储帐户的详细信息,例如存储帐户的资源 ID,因为资源 ID 包括订阅 ID 和资源组名称。因此,即使您有其他与存储帐户不直接相关的输入数据,我们也可以使用上述解决方法。