I am using Azurite in docker-compose for local development. I have a simple application that talks to it using the Java Azure SDK. I am trying to connect using the default Azurite connection string DefaultEndpointsProtocol=https;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==
but when I try and connect I get an Authentication error:
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>"]
I am unsure what the issue and I have not found a solution online as yet. Any thoughts would be appreciated.
I am using the following dependencies:
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-storage-blob</artifactId>
<version>12.3.0</version>
</dependency>
and this is my simple Controller:
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()
}
}
And the env variable is set in 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
Further investigation shows that I get the same issue when I run both Azurite and my application directly on my local machine.