-
Notifications
You must be signed in to change notification settings - Fork 341
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
Allow "startup commands" #1665
Comments
Full example how to create storage containers with approach 2: services:
app:
image: my/app:version
depends_on:
storage_init:
condition: service_completed_successfully
# Azure Blob Storage stuff here
storage:
image: mcr.microsoft.com/azure-storage/azurite:3.19.0
# 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 --name version
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; |
@dkarlovi It looks you have already found a way to resolve this. Feel free to raise if need any further assistance on Azurite. |
Hey @blueww, you mistakenly tagged both of my created issues as questions, these are feature suggestions, there's no question asked here. |
I have re-tag the issue to enhancement. Azurite currently doesn't support pre-create data when start. You need to add your own code/config to create it. |
I understand it doesn't do it now, this is why I've created this feature suggestion.
This is an interesting proposal which I've also considered, but dismissed then because it relied on the workspace storage format being backward / forward compatible, maybe I was wrong. 🤔 Do you think Azurite could add a feature to facilitate this in some way? Something like "dump workspace / restore workspace" command? Maybe the direction might be to allow the user to deserialize into the workspace, so it the user's dump doesn't need to be exactly the same as the workspace format (avoiding the compatibility issue), it can be a much more simplified format which gets converted into the current storage format by Azurite. |
Let's say I have a file like this: blob:
containers:
files:
access: public
blobs:
files/aaa.jpeg: ~ which Azurite takes and applies to its storage on startup, this would mean Azurite's internal storage format can evolve as required and the dump file would still work, as opposed to using the storage file directly. |
For data structure Azurite used to save blob/containers are much different than the structure of blob/container you can see. So currently we don't see an easy way to do the format transfer to prepare the test data, instead you need call rest API to Azurite to create them. |
☝🏼 sure; The reason is that in production, containers are pre-created by admins (or terraform) and the client (my code) should not attempt to create containers. Meanwhile in local dev and CI, This mismatch forces 2 code paths (test, prod), which almost bit us in production. |
Absolutely required feature. <3 |
@dkarlovi, @dimaqq , @oleg-andreyev, Thanks for the suggestion! But currently we don't see an easy solution to implement it, since the data structure Azurite used to save blob/containers are much different than the structure of blob/container (or local folder) you can see. And there are also requests of pre-prepare Azurite data to map different source, like local folder, Azure Blob storage, or a defined structure of container/blob. So there are also no simple way to fulfill all the requests. Then currently a more proper way to prepare the data is still prepare it with some Azure Tools, like Azcopy, Powershell script ... If the data need to prepare is always the same for every Azurite instance, an alternative way is you can just prepare it once, and backup the workspace folder of the Azurite. Then start Azurite with a new copy of the workspace backup. |
@blueww maybe Azurite could bundle the client SDK and call it on itself? Then it's just a matter of configuring the client in some way. |
Azurite is an Azure storage server emulator, we don't prefer to bundle the client SDK into Azurite for prepare the data, since it will take many issues, such like the package size increase, the dependency issues (dependency breaking, deprecation ....) Currently the preferred way is: customer can prepare the data with some Azure Tools, like Azcopy, Powershell script ... |
I understand, it was just an idea to keep the separation clean.
The way I'm reading this is: we don't want to add the feature to support putting Azurite into a known state. That's a reasonable stance since you get to decide where to spend the resources 👍, but since you have at least 3 Azure customers in this thread asking about it, the feature aligns with what they want to use Azurite for (testing their apps, which involves putting the storage in a known state in some way), I think it's reasonable to at least consider it seriously before rejecting it. |
@dkarlovi We will keep the issue open to track this request. Azurite welcome contribution. |
@blueww @dkarlovi but azure CLI got error
any workaround for it? should i create separate issue? |
Answer in #2044 (comment). |
Which service(blob, file, queue, table) does this issue concern?
Blob.
Which version of the Azurite was used?
3.19.0
Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)
DockerHub
What's the Node.js version?
In Docker image.
What problem was encountered?
When trying to set up Azurite for my app's functional tests (app uses Azure blob storage), I need to have a few containers created in the storage. The real containers are typically created with Terraform on deployment, the app itself doesn't create the containers.
It would make sense to be able to do a similar thing with Azurite: being able to have a basic "startup commands" feature where the user can list some pre-requisites and Azurite itself creates them.
Steps to reproduce the issue?
Run Azurite container and use the container
thumbnails
. The container doesn't exists and I can't make Azurite create it when starting up.Have you found a mitigation/solution?
Two ways:
az
CLI tool) to run the commands, this is tricky to coordinate and quite convoluted overall, but seems like the direction which I'll probably takeThe text was updated successfully, but these errors were encountered: