【发布时间】:2021-09-09 07:55:03
【问题描述】:
我正在尝试从 Azure 函数连接到 Azure Blob 存储服务,但它返回的所有内容都是 BlobStorageException
我用了这个例子:Azure Storage Blob client library for Java (Create a BlobServiceClient)
这是我的代码:
String MY_BLOB_ENDPOINT = "https://mystorageaccount.z13.web.core.windows.net/"
String MY_BLOB_SAS_TOKEN = "?sv=2017-07-29&ss=b&srt=s&sp=rwdc&se=2022-06-10T00:00:00Z&st=2021-06-10T00:00:00Z&spr=https&sig=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
String MY_DEFAULT_CONTAINER_NAME = "test"
BlobServiceClient serviceClient = new BlobServiceClientBuilder()
.endpoint(MY_BLOB_ENDPOINT)
.sasToken(MY_BLOB_SAS_TOKEN)
.buildClient();
this.containerClient = serviceClient.
getBlobContainerClient(MY_DEFAULT_CONTAINER_NAME);
if (!this.containerClient.exists()) {
this.containerClient.create();
}
这里是日志:
... (omitted logs)
[2021-06-26T03:36:28.671Z] Executed 'Functions.upload' (Failed, Id=ffdff367-242e-494a-8303-e9ceeee6a2d7, Duration=5919ms)
[2021-06-26T03:36:28.671Z] System.Private.CoreLib: Exception while executing function: Functions.upload. System.Private.CoreLib: Result: Failure
[2021-06-26T03:36:28.671Z] Exception: BlobStorageException: Status code 405,
"<!DOCTYPE html>
<html>
<head>
<title>UnsupportedHttpVerb</title>
</head>
<body>
<h1>The resource doesn't support specified Http Verb.</h1>
<p>
<ul>
<li>HttpStatusCode: 405</li>
<li>ErrorCode: UnsupportedHttpVerb</li>
<li>RequestId : 05ac7acf-701e-0026-213c-6adf7e000000</li><li>TimeStamp : 2021-06-26T03:36:28.4852611Z</li>
</ul>
</p>
</body>
</html>"
[2021-06-26T03:36:28.671Z] Stack: java.lang.IllegalStateException: Failed to initialize
[2021-06-26T03:36:28.671Z] at org.springframework.cloud.function.adapter.azure.FunctionInvoker.<init>(FunctionInvoker.java:90)
[2021-06-26T03:36:28.671Z] at org.springframework.cloud.function.adapter.azure.FunctionInvoker.<init>(FunctionInvoker.java:95)
... (omitted logs)
Blob 存储依赖关系
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.11.1</version>
</dependency>
我不知道为什么它不起作用。我需要配置一些其他设置吗?
【问题讨论】:
-
这很奇怪!您能否编辑您的问题并包含
MY_BLOB_ENDPOINT、MY_BLOB_SAS_TOKEN和MY_DEFAULT_CONTAINER_NAME的值。请在共享之前混淆帐户名称,sig部分您的 SAS 令牌。 -
@GauravMantri 我改变了他们。
-
谢谢。我已经提供了答案。 HTH。
标签: java azure azure-blob-storage