Giter Club home page Giter Club logo

Comments (5)

blueww avatar blueww commented on September 18, 2024 1

@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"

from azurite.

blueww avatar blueww commented on September 18, 2024 1

@bjornmadsen

I will close this issue as the problem is resolved.
Feel free to contact us again if need any further assistance on Azurite.

from azurite.

blueww avatar blueww commented on September 18, 2024

@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.

from azurite.

root-11 avatar root-11 commented on September 18, 2024

This log ends with the error. Action performed:

  1. attempt to upload file (file already existed in the container, so ignore this error)
  2. create the sas-token
  3. replace devstore with localhost in the url
  4. open incognito window to try the sas-token (fails)

logfile.log

from azurite.

bjornmadsen avatar bjornmadsen commented on September 18, 2024

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!

from azurite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.