0

I am creating an Azure Function that must be connected to a local storage account. It's for study purpose. The problem does not exists if I run the function with "default" options, the ones are set when I create an Azure function that connect to a containerized local storage.

But now I want to customize my project using the docker compose. Forget the function, In this moment is not a problem and I don't care about it. Here the compose file:

version: '3.4'

services:
  functionapp4:
    image: ${DOCKER_REGISTRY-}functionapp4
    container_name: MyFunction
    build:
      context: .
      dockerfile: FunctionApp4/Dockerfile

  storage:
    image: mcr.microsoft.com/azure-storage/azurite
    container_name: MyStorage
    restart: always
    ports:
      - 127.0.0.1:10000:10000
      - 127.0.0.1:10001:10001
      - 127.0.0.1:10002:10002
    environment:
      - AZURITE_ACCOUNTS="devst******:Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="
    volumes: 
      - azurite:/data

volumes:
  azurite: 

When I run the project, both the containers (function and storage) start. But here I can see immediately a problem:

enter image description here

the services have been started at http://0.0.0.0 even if I set 127.0.0.1 in the compose file. I also tried with "127.0.0.1:{portNumber}"

Now, I open the Storage Explorer, where I created the storage with the same name and key I set in the compose:

enter image description here

Now, when I click on queue I get this error:

{
  "name": "RestError",
  "message": "Invalid storage account.\nRequestId:a20dea2a-2535-4098-950e-33a7f44ceca1\nTime:2023-02-08T07:36:52.554Z",
  "code": "InvalidOperation",
  "statusCode": 400,
  "request": {
    "streamResponseStatusCodes": {},
    "url": "http://127.0.0.1:10001/devst*****?timeout=30",
    
       ...
   }
}

I also tried to set the command in docker compose file:

command: 'azurite'

In this case, the service starts listening at the correct host, but it is worst because I get the error I cannot connect to the storge account either:

enter image description here enter image description here

The problem seems to be in my environment variable:

environment:
      - AZURITE_ACCOUNTS="devst******:Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="

But it is correclty set:

enter image description here

I tryed both with quotation marks and without them. No change

If I remove the env variable, I can connect to the default storage account correctly.

What's wrong in my configuration? Any suggestion please?

Thank you

Simone
  • 2,304
  • 6
  • 30
  • 79

1 Answers1

0

Just one small error in my configuration.

This line

- AZURITE_ACCOUNTS="devst******:Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="

must be

- "AZURITE_ACCOUNTS=devst******:Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw=="

Please, note the quotation marks.

Simone
  • 2,304
  • 6
  • 30
  • 79