当我尝试从 Azure Function (Java) 中删除 Azure 存储帐户中的 blob 时,程序只是卡在 blob.deleteIfExists();
当我在本地存储模拟器上执行相同的操作时,它运行得很好并从容器中删除了 blob。
这是我用来删除 blob 的代码。
// Retrieve storage account from connection-string.
CloudStorageAccount storageAccount = CloudStorageAccount.parse(System.getenv("STORAGE"));
// Create the blob client.
CloudBlobClient blobClient = storageAccount.createCloudBlobClient();
// Retrieve reference to a previously created container.
CloudBlobContainer container = blobClient.getContainerReference("container-name");
// Retrieve reference to a blob named fileName.
CloudBlockBlob blob = container.getBlockBlobReference(fileName);
context.getLogger().info(blob.getName());
// Delete the blob.
blob.deleteIfExists();
我所在的行 context.getLogger().info(blob.getName());
工作正常并返回正确的 blob 但 blob.deleteIfExists();
只是导致程序挂起。
最佳答案
这是本地测试时的权限问题。当部署到 Azure 时,blob 删除按其应有的方式发生。
关于java - 无法从 Azure 存储帐户中删除 blob - Azure Function (Java),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72968825/