Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create container from external azure cli doesn't work #2044

Closed
Slach opened this issue Jul 10, 2023 · 6 comments
Closed

create container from external azure cli doesn't work #2044

Slach opened this issue Jul 10, 2023 · 6 comments
Assignees
Labels
blob-storage question Further information is requested

Comments

@Slach
Copy link
Contributor

Slach commented Jul 10, 2023

Which service(blob, file, queue, table) does this issue concern?

azure blob

Which version of the Azurite was used?

mcr.microsoft.com/azure-storage/azurite:3.24.0

Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)

I use the following docker-compose.yaml
which found here #1665 (comment)

services:
  azure:
    image: mcr.microsoft.com/azure-storage/azurite:latest
    container_name: azure
    hostname: devstoreaccount1.blob.azure
    healthcheck:
      test: nc 127.0.0.1 10000 -z
      interval: 1s
      retries: 30
    networks:
      - clickhouse-backup

  azure_init:
    image: mcr.microsoft.com/azure-cli:latest
    command:
      - /bin/sh
      - -xc
      - |
        az storage container create --debug --name azure-backup-disk &&
        az storage container create --debug --name azure-disk
    depends_on:
      azure:
        condition: service_healthy
    environment:
      # https://github.com/Azure/Azurite/blob/main/README.md#usage-with-azure-storage-sdks-or-tools
      AZURE_STORAGE_CONNECTION_STRING: DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://azure:10000/devstoreaccount1;
    networks:
      - clickhouse-backup
  

What problem was encountered?

az storage container create failed with following error

cli.azure.cli.core.azclierror: The value for one of the HTTP headers is not in the correct format.
RequestId:6bc6b6f9-c7f2-4e9d-81d2-14a4df9eb8a1
Time:2023-07-10T14:11:44.435Z
ErrorCode:InvalidHeaderValue
headername:x-ms-version
headervalue:2022-11-02
az_command_data_logger: The value for one of the HTTP headers is not in the correct format.
RequestId:6bc6b6f9-c7f2-4e9d-81d2-14a4df9eb8a1
Time:2023-07-10T14:11:44.435Z
ErrorCode:InvalidHeaderValue
headername:x-ms-version
headervalue:2022-11-02

Steps to reproduce the issue?

docker-compose run --rm azure_init

Have you found a mitigation/solution?

No ;(

@blueww
Copy link
Member

blueww commented Jul 11, 2023

@Slach
Would you please share the azurite debug log for the failed request?
We need it to continue investigation.

@blueww blueww added question Further information is requested blob-storage labels Jul 11, 2023
@blueww blueww self-assigned this Jul 11, 2023
@Slach
Copy link
Contributor Author

Slach commented Jul 11, 2023

@blueww there is debug log

2023-07-11T06:25:36.868Z         info: Azurite Blob service is starting on 0.0.0.0:10000
2023-07-11T06:25:36.869Z         info: AccountDataStore:init() Refresh accounts from environment variable AZURITE_ACCOUNTS with value undefined
2023-07-11T06:25:36.869Z         info: AccountDataStore:init() Fallback to default emulator account devstoreaccount1.
2023-07-11T06:25:36.884Z         info: BlobGCManager:start() Starting BlobGCManager. Set status to Initializing.
2023-07-11T06:25:36.884Z         info: BlobGCManager:start() Trigger mark and sweep loop. Set status to Running.
2023-07-11T06:25:36.885Z         info: BlobGCManager:markSweepLoop() Start next mark and sweep.
2023-07-11T06:25:36.885Z         info: BlobGCManager:markSweep() Get all extents.
2023-07-11T06:25:36.886Z         info: BlobGCManager:start() BlobGCManager successfully started.
2023-07-11T06:25:36.887Z         info: BlobGCManager:markSweep() Got 0 extents.
2023-07-11T06:25:36.887Z         info: BlobGCManager:markSweep() Get referred extents.
2023-07-11T06:25:36.888Z         info: BlobGCManager:markSweep() Got referred extents, unreferenced extents count is 0.
2023-07-11T06:25:36.888Z         info: BlobGCManager:markSweepLoop() Mark and sweep finished, taken 3ms.
2023-07-11T06:25:36.888Z         info: BlobGCManager:markSweepLoop() Sleep for 600000ms.
2023-07-11T06:25:36.890Z         info: Azurite Blob service successfully listens on http://0.0.0.0:10000
2023-07-11T06:25:36.890Z         info: Azurite Queue service is starting on 0.0.0.0:10001
2023-07-11T06:25:36.890Z         info: AccountDataStore:init() Refresh accounts from environment variable AZURITE_ACCOUNTS with value undefined
2023-07-11T06:25:36.890Z         info: AccountDataStore:init() Fallback to default emulator account devstoreaccount1.
2023-07-11T06:25:36.898Z         info: QueueGCManager:start() Starting QueueGCManager, set status to Initializing
2023-07-11T06:25:36.898Z         info: QueueGCManager:start() Trigger mark and sweep loop, set status to Running.
2023-07-11T06:25:36.899Z         info: QueueGCManager:markSweepLoop() Start new mark and sweep.
2023-07-11T06:25:36.899Z         info: QueueGCManger:markSweep() Get all extents.
2023-07-11T06:25:36.899Z         info: QueueGCManager:start() QueueGCManager successfully started.
2023-07-11T06:25:36.899Z         info: QueueGCManager:marksweep() Get 0 extents.
2023-07-11T06:25:36.899Z         info: QueueGCManager:markSweep() Get referred extents, then remove from allExtents.
2023-07-11T06:25:36.900Z         info: QueueGCManager:markSweep() Got referred extents, unreferenced extents count is 0.
2023-07-11T06:25:36.900Z         info: QueueGCManager:markSweepLoop() Mark and sweep finished, take 1ms.
2023-07-11T06:25:36.900Z         info: QueueGCManager:markSweepLoop() Sleep for 60000
2023-07-11T06:25:36.900Z         info: Azurite Queue service successfully listens on http://0.0.0.0:10001
2023-07-11T06:25:36.900Z         info: Azurite Table service is starting on 0.0.0.0:10002
2023-07-11T06:25:36.900Z         info: AccountDataStore:init() Refresh accounts from environment variable AZURITE_ACCOUNTS with value undefined
2023-07-11T06:25:36.900Z         info: AccountDataStore:init() Fallback to default emulator account devstoreaccount1.
2023-07-11T06:25:36.904Z         info: Azurite Table service successfully listens on http://0.0.0.0:10002
2023-07-11T06:26:08.445Z         error: ErrorMiddleware: Received a MiddlewareError, fill error information to HTTP response
2023-07-11T06:26:08.445Z         error: ErrorMiddleware: 
ErrorName=StorageError ErrorMessage=The 
value for one of the HTTP headers is not in the correct format.  
ErrorHTTPStatusCode=400 
ErrorHTTPStatusMessage=The value for one of the HTTP headers is not in the correct format.
ErrorHTTPHeaders={"x-ms-error-code":"InvalidHeaderValue","x-ms-request-id":"7ac32c82-ea2c-4751-991d-9d341eca71c8"} 
ErrorHTTPBody="<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Error>\n  <Code>InvalidHeaderValue</Code>\n  <Message>The value for one of the HTTP headers is not in the correct format.\nRequestId:7ac32c82-ea2c-4751-991d-9d341eca71c8\nTime:2023-07-11T06:26:08.440Z</Message>\n  <HeaderName>x-ms-version</HeaderName>\n  <HeaderValue>2022-11-02</HeaderValue>\n</Error>" 

ErrorStack="StorageError: The value for one of the HTTP headers is not in the correct format.\n
    at Function.getInvalidHeaderValue (/opt/azurite/dist/src/blob/errors/StorageErrorFactory.js:210:16)\n
    at Object.checkApiVersion (/opt/azurite/dist/src/blob/utils/utils.js:9:45)\n
    at blobStorageContextMiddleware (/opt/azurite/dist/src/blob/middlewares/blobStorageContext.middleware.js:34:21)\n
    at /opt/azurite/dist/src/blob/middlewares/blobStorageContext.middleware.js:15:16\n
    at Layer.handle [as handle_request] (/opt/azurite/node_modules/express/lib/router/layer.js:95:5)\n
    at trim_prefix (/opt/azurite/node_modules/express/lib/router/index.js:323:13)\n
    at /opt/azurite/node_modules/express/lib/router/index.js:284:7\n
    at Function.process_params (/opt/azurite/node_modules/express/lib/router/index.js:341:12)\n
    at next (/opt/azurite/node_modules/express/lib/router/index.js:275:10)\n
    at logger (/opt/azurite/node_modules/morgan/index.js:144:5)"
2023-07-11T06:26:08.445Z         error: ErrorMiddleware: Set HTTP code: 400
2023-07-11T06:26:08.446Z         error: ErrorMiddleware: Set HTTP status message: The value for one of the HTTP headers is not in the correct format.
2023-07-11T06:26:08.446Z         error: ErrorMiddleware: Set HTTP Header: x-ms-error-code=InvalidHeaderValue
2023-07-11T06:26:08.446Z         error: ErrorMiddleware: Set HTTP Header: x-ms-request-id=7ac32c82-ea2c-4751-991d-9d341eca71c8
2023-07-11T06:26:08.446Z         error: ErrorMiddleware: Set content type: application/xml
2023-07-11T06:26:08.446Z         error: ErrorMiddleware: Set HTTP body: "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<Error>\n  <Code>InvalidHeaderValue</Code>\n  <Message>The value for one of the HTTP headers is not in the correct format.\nRequestId:7ac32c82-ea2c-4751-991d-9d341eca71c8\nTime:2023-07-11T06:26:08.440Z</Message>\n  <HeaderName>x-ms-version</HeaderName>\n  <HeaderValue>2022-11-02</HeaderValue>\n</Error>"
2023-07-11T06:26:08.447Z         info: EndMiddleware: End response. TotalTimeInMS=undefined StatusCode=400 StatusMessage=The value for one of the HTTP headers is not in the correct format. Headers={"server":"Azurite-Blob/3.16.0","x-ms-error-code":"InvalidHeaderValue","x-ms-request-id":"7ac32c82-ea2c-4751-991d-9d341eca71c8","content-type":"application/xml"}

@blueww
Copy link
Member

blueww commented Jul 11, 2023

@Slach

I notice you use a different docker-compose.yaml file than #1665 (comment), like you missed the storage: section.

As the error is "x-ms-version" header is invalid, you might not use latest Azure docker image.
Would you please try again after delete the local cached Azurite lastest docker image, to make sure the real latest Azurite docker will be download.
If still fail, we are not docker-compose expert, so we might be the best person to suggest how to change the file.
For you reference, following docker-compose.yaml file works in my test.

services:
    app:
        image: mcr.microsoft.com/azure-storage/azurite:latest
        depends_on:
            storage_init:
                condition: service_completed_successfully
    # Azure Blob Storage stuff here
    storage:
        image: mcr.microsoft.com/azure-storage/azurite:latest
        # required, see https://github.com/Azure/Azurite/issues/1666
        healthcheck:
            test: nc 127.0.0.1 10000 -z
            interval: 1s
            retries: 30
    storage_init:
        image: mcr.microsoft.com/azure-cli:latest
        command:
            - /bin/sh
            - -c
            - |
                az storage container create --debug --name azure-backup-disk &&
                az storage container create --debug --name azure-disk
        depends_on:
            storage:
                condition: service_healthy
        environment:
            # https://github.com/Azure/Azurite/blob/main/README.md#usage-with-azure-storage-sdks-or-tools
            AZURE_STORAGE_CONNECTION_STRING: DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://storage:10000/devstoreaccount1;

@Slach
Copy link
Contributor Author

Slach commented Jul 11, 2023

I didn't miss a storage section

I created azure and azure_init services in my docker-compose.yaml

your app service has no sense, it just run a separatelly start another azurite instance which not described in storage_init

@Slach
Copy link
Contributor Author

Slach commented Jul 11, 2023

looks like you right, i run docker-compose pull azure && docker-compose run --rm azure_init
all looks good now

@Slach Slach closed this as completed Jul 11, 2023
@blueww
Copy link
Member

blueww commented Jul 11, 2023

@Slach
Great to know it work for you now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blob-storage question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants