【发布时间】:2020-02-06 10:25:31
【问题描述】:
我在 docker-compose 中使用 Azurite 进行本地开发。我有一个使用 Java Azure SDK 与之对话的简单应用程序。我正在尝试使用默认的 Azurite 连接字符串 DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw== 进行连接,但是当我尝试连接时出现身份验证错误:
app | RequestId:648770d1-301e-00a3-28d6-dcfab7000000
app | Time:2020-02-06T10:19:10.6959018Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request 'vSVMXMpgTMISc9Fgx2bu0kg7uu0duhmdn6dllfc4r1g=' is not the same as any computed signature. Server used following string to sign: 'GET
app |
app |
app |
app |
app |
app | Thu, 06 Feb 2020 10:19:09 GMT
app |
app |
app |
app |
app |
app | x-ms-client-request-id:4bd883d4-229a-4dec-bf6f-221f3636dccf
app | x-ms-version:2019-02-02
app | /devstoreaccount1/
app | comp:list'.</AuthenticationErrorDetail></Error>"; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Status code 403, "<?xml version="1.0" encoding="utf-8"?><Error><Code>AuthenticationFailed</Code><Message>Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature.
app | RequestId:648770d1-301e-00a3-28d6-dcfab7000000
app | Time:2020-02-06T10:19:10.6959018Z</Message><AuthenticationErrorDetail>The MAC signature found in the HTTP request 'vSVMXMpgTMISc9Fgx2bu0kg7uu0duhmdn6dllfc4r1g=' is not the same as any computed signature. Server used following string to sign: 'GET
app |
app |
app |
app |
app |
app | Thu, 06 Feb 2020 10:19:09 GMT
app |
app |
app |
app |
app |
app | x-ms-client-request-id:4bd883d4-229a-4dec-bf6f-221f3636dccf
app | x-ms-version:2019-02-02
app | /devstoreaccount1/
app | comp:list'.</AuthenticationErrorDetail></Error>"]
我不确定是什么问题,我还没有在网上找到解决方案。任何想法将不胜感激。
我正在使用以下依赖项:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.3.0</version>
</dependency>
这是我的简单控制器:
package com.sky.video.azuritedemo
import com.azure.core.http.rest.PagedIterable
import com.azure.storage.blob.BlobServiceClientBuilder
import com.azure.storage.blob.models.BlobContainerItem
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
@RestController
class AzureController() {
@GetMapping("/container")
fun getContainers(): PagedIterable<BlobContainerItem>? {
val connectionString = System.getenv("AZURE_STORAGE_CONNECTION_STRING")
val client = BlobServiceClientBuilder()
.connectionString(connectionString)
.buildClient()
return client
.listBlobContainers()
}
}
并且 env 变量是在 docker-compose 中设置的:
version: '3'
services:
app:
build:
context: .
command: "mvn spring-boot:run"
container_name: app
depends_on:
- azure
environment:
AZURE_STORAGE_CONNECTION_STRING: "DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
links:
- azure
ports:
- 5005:5005
- 8080:8080
volumes:
- ~/.m2:/root/.m2
- .:/app
azure:
command: "azurite --blobHost 0.0.0.0 --queueHost 0.0.0.0 -d /tmp/logs/debug.log"
container_name: azure
environment:
EXECUTABLE: blob
image: mcr.microsoft.com/azure-storage/azurite
ports:
- "10000:10000"
- "10001:10001"
volumes:
- ./logs:/tmp/logs
进一步调查表明,当我直接在本地计算机上运行 Azurite 和我的应用程序时,我遇到了同样的问题。
【问题讨论】:
-
在这里看起来像同样的问题:stackoverflow.com/questions/59615330/…