Ferhi Malek
Ferhi Malek

Reputation: 514

Customized storage account for Azurite on docker compose

I am trying to use Azurite for my testing environment , I added it to the docker compose file , and it worked fine, code below :

azurite:
image: mcr.microsoft.com/azure-storage/azurite
container_name: test-azurite
ports:
  - '10001:10001'
  - '10000:10000'

I need to use a custom storage account name other than the default one "devstoreaccount1" , so I updated the account name on the different connection strings, and I added the account name as environment variable for the azurite container , now it looks like below :

azurite:
image: mcr.microsoft.com/azure-storage/azurite
container_name: test-azurite
ports:
  - '10001:10001'
  - '10000:10000'
environment:
  - AZURITE_ACCOUNTS="newstorageaccount:newkey"

I tried also adding it as command :

commands:
- export AZURITE_ACCOUNTS="newstorageaccount:newkey"

But that didn't work , any help on how to get Azurite to work with a customized storage account on docker compose is appreciated, Thanks

Upvotes: 4

Views: 2459

Answers (1)

Alex
Alex

Reputation: 18526

Works for me like this, even if I don't use a valid base64 encoded string as a key:

version: '2'
services:
  azurite:
    image: mcr.microsoft.com/azure-storage/azurite:3.19.0
    container_name: test-azurite
    ports:
      - '10001:10001'
      - '10000:10000'
    environment:
      - AZURITE_ACCOUNTS=myaccountname:ZGV2c3RvcmVhY2NvdW50Mw==
var accountName = "myaccountname";
var key = "ZGV2c3RvcmVhY2NvdW50Mw==";
var connectionString = $"DefaultEndpointsProtocol=http;AccountName={accountName};AccountKey={key};BlobEndpoint=http://127.0.0.1:10000/{accountName};";

BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
await blobServiceClient.GetBlobContainerClient("test2").CreateIfNotExistsAsync();

Upvotes: 2

Related Questions