Skip to content
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

BlobClient hangs if storage account doesn't exist #1797

Open
aochagavia opened this issue Sep 11, 2024 · 0 comments
Open

BlobClient hangs if storage account doesn't exist #1797

aochagavia opened this issue Sep 11, 2024 · 0 comments

Comments

@aochagavia
Copy link

aochagavia commented Sep 11, 2024

Problem description

I'm using BlobClient together with storage account keys. When issuing a request to the API (e.g. get_properties for a blob), the program hangs for ~80 seconds if a non-existing account name was provided.

Reproducer

This assumes you have tokio, azure_storage and azure_storage_blobs available to your crate.

use std::time::Instant;
use azure_storage::StorageCredentials;
use azure_storage_blobs::prelude::{BlobClient, BlobServiceClient};

fn main() {
    let account = "this-account-does-not-exist-1234";

    // The provided key is a real one, but has been invalidated for security
    let credentials = StorageCredentials::access_key(account, "7+iu4f92PM6yp0RcMMpRFxMHImIPNaqrxkXNVUoqZZVfdRwgXFTQYPbuUIukX8L+lqmSlVNXFB0/+AStcAn91g==");
    let client = BlobServiceClient::new(account, credentials)
        .container_client("my-container")
        .blob_client("my-blob");

    let rt = tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap();
    rt.block_on(get_properties(client));
}

async fn get_properties(client: BlobClient) {
    let start = Instant::now();
    println!("Start streaming");
    let blob_stream = client.get_properties().await;
    println!("Done streaming after {:.2} seconds: success = {}", start.elapsed().as_secs_f64(), blob_stream.is_ok());
}

Probable cause

Behind the scenes, the client uses the account name to build the API url when issuing a specific request (e.g. GETting a blog would go to https://<my-account>.blob.core.windows.net/<container-name>/<blob-path>). I assume the DNS resolver hangs for some reason, instead of giving up quickly.

Suggested solution

Ensure the request times out earlier. If the problem lies indeed in DNS resolving, maybe we should give up after 5 seconds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant