【发布时间】:2019-08-04 17:58:11
【问题描述】:
我正在尝试使用 MSI 访问 Azure Blob 存储容器以生成共享访问签名。但是每次我尝试访问时,都会出现以下错误:
`java.lang.IllegalArgumentException: Cannot create Shared Access Signature unless the Account Key credentials are used by the ServiceClient.`
我不想使用凭据或 AAD 访问 blob 存储容器。只想使用 MSI,因为这是我们想要在应用程序中调整以访问 Azure 资源的独特模式。我错过了什么。我在我的 Splunk 日志中检查了 MSI 令牌正在成功生成。以下是我创建 CloudBlobClient 以访问 Blob 容器的方式:
public CloudBlobClient cloudBlobClient() throws URISyntaxException {
String storageAccountName = propertyUtil.getStorageAccountName();
// Implemented some logic in AzureStorageMSICredential class to fetch access
// token, and its working correctly
String msiToken = azureStorageMSICredentials.getToken();
LOG.info("Initiating CloudBlobClient.... msitoken = " + msiToken);
StorageCredentials storageCredentials =
new StorageCredentialsToken(storageAccountName, msiToken);
URI storageAccountURI = URIUtils.getStorageAccountURI(storageAccountName);
CloudBlobClient cloudBlobClient = new CloudBlobClient(storageAccountURI,
storageCredentials);
return cloudBlobClient;
}
我在 stackoverflow 上搜索了很多线程,这似乎与这个重复,但不是真的。有些是 2017 年的。
【问题讨论】:
标签: azure azure-devops azure-blob-storage azure-managed-identity