Azure / Azurite

A lightweight server clone of Azure Storage that simulates most of the commands supported by it with minimal dependencies
MIT License
1.8k stars 320 forks source link

Cannot add --skipApiVersionCheck when using testcontainers #2432

Open ShaharPrishMSFT opened 1 month ago

ShaharPrishMSFT commented 1 month ago

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

Blobs

Which version of the Azurite was used?

Latest - there's no version listed here: https://hub.docker.com/r/microsoft/azure-storage-azurite, but that's what I am using.

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

DockerHub

What's the Node.js version?

What's inside the image

What problem was encountered?

Cannot figure out how to pass in --skipApiVersionCheck

Steps to reproduce the issue?

If possible, please provide the debug log using the -d parameter, replacing \<pathtodebuglog> with an appropriate path for your OS, or review the instructions for docker containers:

            var builder = new ContainerBuilder()
                .WithImage("mcr.microsoft.com/azure-storage/azurite")
                .WithPortBinding(10000, true)
                .WithPortBinding(10001, true)
                .WithPortBinding(10002, true)
                .WithName($"{_namePrefix}-azurite")
                .WithWaitStrategy(Wait.ForUnixContainer().UntilMessageIsLogged("Azurite Table service is successfully listening at"));

            if (_skipVersionCheck)
            {
                builder.WithCommand("--skipApiVersionCheck");
            }

            Container = builder.Build();

            await Container.StartAsync();

Getting the following error:

   Azure.RequestFailedException : The API version 2024-08-04 is not supported by Azurite. Please upgrade Azurite to latest version and retry. If you are using Azurite in Visual Studio, please check you have installed latest Visual Studio patch. Azurite command line parameter "--skipApiVersionCheck" or Visual Studio Code configuration "Skip Api Version Check" can skip this error. 
   RequestId:7146ecf5-712b-4593-b754-61959a659270
   Time:2024-07-19T08:43:03.147Z

Please be sure to remove any PII or sensitive information before sharing!
The debug log will log raw request headers and bodies, so that we can replay these against Azurite using REST and create tests to validate resolution.

Have you found a mitigation/solution?

No - tried adding it via WithEntryPoint and that didn't work either.

blueww commented 1 month ago

@ShaharPrishMSFT This doc has show how to start Azurite docker with "--skipApiVersionCheck" https://hub.docker.com/r/microsoft/azure-storage-azurite#:~:text=tableHost%200.0.0.0%20%2D%2Dloose%20%2D%2D-,skipApiVersionCheck,-%2D%2DdisableProductStyleUrl

For how to input the parameter with the API you shows above, this is out of Azurite scope. You might can contact the API owner to get it.

josebarros2025 commented 1 month ago

If you are using Testcontainers you should take a look on this https://java.testcontainers.org/features/commands/

this is how you pass commands at least this is what its documented there.

This code example may help you a bit since we are using GenericContainers

public class AzuriteContainer extends GenericContainer<AzuriteContainer> {

    public Integer DEFAULT_PORT = 10000;

    AzuriteContainer(final DockerImageName dockerImageName) {
        super(dockerImageName);
    }

    public static AzuriteContainer create() {
        return new AzuriteContainer(DockerImageName.parse("mcr.microsoft.com/azure-storage/azurite:latest"));
    }

    @Override
    protected void configure() {
        addExposedPort(DEFAULT_PORT);
        waitingFor(Wait.forLogMessage(".*Azurite Blob service successfully listens on .*", 1)); //specific wait condition
        setCommand("azurite-blob --blobHost 0.0.0.0 --blobPort " + DEFAULT_PORT + " --skipApiVersionCheck"); //the docker command
    }
}
matt-goldman commented 1 week ago

@ShaharPrishMSFT is it possible your _skipVersionCheck is false here? This works for me:

private readonly AzuriteContainer _azuriteContainer = new AzuriteBuilder()
    .WithImage("mcr.microsoft.com/azure-storage/azurite:latest")
    .WithCommand("--skipApiVersionCheck")
    .Build();