Using curl to get Azure Storage file timeout

Someone 20 Reputation points
2024-06-25T10:49:47.66+00:00

OS: Ubuntu 18.04
curl with SAS get Connection timed out. None of below work. How could I fix it?

curl -o /home/user/test https://bucket.file.core.windows.net/folder/file?SAS

curl -H "x-ms-version: 2019-07-07" "https://bucket.file.core.windows.net/folder/file?SAS"

Paste same curl URL in browser download file success, but use curl will timed out.
The file lacks an extension, which might be the reason for the download failure.

Azure Storage Accounts
Azure Storage Accounts
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
2,854 questions
0 comments No comments
{count} votes

Accepted answer
  1. Nehruji R 3,971 Reputation points Microsoft Vendor
    2024-06-26T07:26:43.32+00:00

    Hello Someone,

    Greetings! Welcome to Microsoft Q&A Platform.

    I understand that you’re encountering connection timeouts when using curl to download a file with a shared access signature (SAS) URL.

    1.The timeouts you’re experiencing might be due to various factors, such as network latency, server load, or firewall restrictions. To prevent timeouts, consider adjusting the connection timeout using the --connect-timeout option. For example:

    curl --connect-timeout 300 -o /home/user/test 
    "https://bucket.file.core.windows.net/folder/file?SAS"
     
    

    This sets a 5-minute timeout (300 seconds) for the connection.

    2.As you mentioned it may be due to the file lacks an extension. Ensure that the server correctly identifies the file type based on its content. If the server doesn’t provide a Content-Type header, you can specify it explicitly using the -H option

    curl -H "Content-Type: application/octet-stream" -o /home/user/test "https://bucket.file.core.windows.net/folder/file?SAS"
    
    
    

    3.Check your DNS settings. Sometimes DNS resolution issues can cause timeouts and verify that the hostname in the URL (bucket.file.core.windows.net) resolves correctly.

    Similar thread for reference - https://stackoverflow.com/questions/59080379/why-does-my-curl-command-fail-to-download-a-file-most-of-the-time-but-sometimes

    Hope this answer helps! Please let us know if you have any further queries. I’m happy to assist you further.


    Please "Accept the answer” and “up-vote” wherever the information provided helps you, this can be beneficial to other community members.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful