Closed root-11 closed 1 month ago
@EmmaZhu Would you please help to look?
@root-11 Would you please share Azurite debug log (start Azurite with parameter like "--debug c:\logfile.log"), then we can do more investigation.
This log ends with the error. Action performed:
@root-11
I see in the 2 failed (400) request, the resource Uri are incorrect, they both missed the storage account name.
"RequestURL=http://localhost/testcontainer/testfile.txt?st=2024-09-09T11%3A03%3A37Z&se=..." "RequestURL=http://localhost/favicon.ico"
The correct Uri should look like:
"RequestURL=http://localhost/devstoreaccount1/testcontainer/testfile.txt?st=2024-09-09T11%3A03%3A37Z&se=..." "RequestURL=http://localhost/devstoreaccount1/favicon.ico"
A fully formed sas-token was craeted by including the blob service url with port for azurite and adding the storage account name as advised.
functioning example:
http://127.0.0.1:10000/devstoreaccount1/testcontainer/ok_rpi.csv?st=2024-09-10T10%3A45%3A42Z&se=2024-09-10T11%3A55%3A42Z&sp=r&spr=http&sv=2024-08-04&sr=b&sig=tYQCmhkWE3tXbFrlA15DhLwYitHKkSuj6OJmBdk3ikE%3D
For effect see:
blob_service = "127.0.0.1:10000"
sas_url = f"http://{blob_service}/{STORAGE_ACCOUNT_NAME}/{container_name}/{blob_name}?{sas_token}"
in the function below:
@app.route(route="make_sas_token")
def make_sas_token(req: func.HttpRequest) -> func.HttpResponse:
blob_name = req.params.get('filename')
#< ... cut for brevity ...>
sas_token = generate_blob_sas(
account_name=STORAGE_ACCOUNT_NAME, # Real account name for the token
container_name=container_name,
blob_name=blob_name,
account_key=STORAGE_ACCOUNT_KEY,
permission=BlobSasPermissions(read=True),
expiry=datetime.now(UTC) + timedelta(hours=1), # Token valid for 1 hour
protocol="http",
start=datetime.now(UTC) - timedelta(minutes=10),
version="2020-02-10" # Ensure this is a supported version
)
blob_service = "127.0.0.1:10000"
sas_url = f"http://{blob_service}/{STORAGE_ACCOUNT_NAME}/{container_name}/{blob_name}?{sas_token}"
return func.HttpResponse(sas_url, status_code=200)
Thank you for helping out with the missing manual!
@bjornmadsen
I will close this issue as the problem is resolved. Feel free to contact us again if need any further assistance on Azurite.
Hello, I am encountering an
InvalidResourceName
error when trying to access Azure Blob Storage using Shared Access Signature (SAS) tokens generated by my Azure Function app in a local development environment with Azurite.Which service(blob, file, queue, table) does this issue concern?
generate_blob_sas
fromazure.storage.blob
Which version of the Azurite was used?
3.32.0
Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)
npm
What's the Node.js version?
v20.17.0
What problem was encountered?
Steps to Reproduce:
Expected Behavior: The blob should be accessible using the SAS token without any errors.
Actual Behavior: The system returns an
InvalidResourceName
error. Here is the error detail:Steps to reproduce the issue?
start azurite, upload
hello world!
as filetest.txt, attempt to create a sas-token for it.Logs created using:
azurite --silent --location ./azurite --debug azurite-debug.log
: azurite-debug.logQ: Please be sure to remove any PII or sensitive information before sharing!
A: All information is demo information.
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 I'm stuck.
Attempts to Resolve:
What i see:
http://localhost:7071/api/sastoken?filename=testfile.txt&container=testcontainer
SAS URL: http://devstoreaccount1:10000/testcontainer/testfile.txt?st=2024-09-02T17%3A49%3A30Z&se=2024-09-02T18%3A50%3A30Z&sp=r&spr=http&sv=2024-08-04&sr=b&sig=jPWqfhesz8gxP1d6Mbzx8hZ51fNy1PU99KOnBu5Spa8%3D
devstoreaccount
withlocalhost
and enter the sas url in chrome and get this:Could you help me understand what might be causing this issue or if there's a configuration with Azurite that I might be missing? Thank you for your assistance!
Additional details:
I've verified that the blob and container names do not contain special characters. I've checked and rechecked the SAS token parameters and encoding. Could you help me understand what might be causing this issue or if there's a configuration with Azurite that I might be missing?
Thank you for your assistance!